@adonis-agora/authkit-react
Version:
Frontend ergonomics over AuthKit for AdonisJS + Inertia + React apps: a typed useAuth() hook, role-gating hooks and gating components.
201 lines (200 loc) • 11.2 kB
TypeScript
import type { AcceptOrgInvitationResult, AccountAgentsResult, AccountAppsResult, AccountLoginMethodsResult, AccountMe, AccountMfaStatus, AccountOrgDetail, AccountOrgInvitationsResult, AccountOrgsResult, AccountPasskeysResult, AccountSecurityOverview, AccountSessionsResult, AccountTokensResult, ActivateOrgResult, AdminClient, AdminClientListResult, AdminOrgDetail, AdminOrgEntry, AdminOrgInvitation, AdminOrgListResult, AdminOverview, AdminUser, AdminUserListResult, AuditListParams, AuditListResult, ChangePasswordInput, CreateAccountOrgInput, CreateClientInput, CreatedAccountOrgResult, CreatedClientResult, CreatedOrgInvitationResult, CreatedPatResult, CreateOrgInput, CreateRoleInput, CreateTokenInput, CreateUserInput, DeactivateOrgResult, DeletedResult, EmailChangeResult, ImpersonationPanel, InviteOrgMemberInput, KeysRotateInput, KeysRotateResult, KeysStatus, LeaveOrgResult, MfaConfirmResult, MfaDisableResult, MfaEnrollResult, MfaRecoveryCodesResult, OkResult, PasskeyRegistrationOptions, PersonalAgentConnectionsParams, PersonalAgentConnectionsResult, PersonalAgentRegistryInput, PersonalAgentRegistryResult, PersonalAgentsOverview, RegenerateSecretResult, RemoveOrgMemberResult, RemovePasskeyResult, RequestEmailChangeInput, ResetPasswordResult, RevokeAllResult, RevokeAppResult, RevokeOrgInvitationResult, RevokeOthersResult, RevokeSessionResult, RevokeSessionsResult, RevokeTokenResult, RoleCatalogEntry, RoleListResult, SettingEntry, SettingListResult, UpdateClientInput, UpdateLoginMethodsResult, UpdateOrgInput, UpdateOrgMemberRoleResult, UpdateProfileInput, UpdateProfileResult, UpdateRoleInput, UpdateUserInput, UserLoginMethodsInput, UserSessionsResult } from './types.js';
export declare class AuthkitClientError extends Error {
readonly status: number;
readonly code?: string | undefined;
readonly body?: unknown;
constructor(status: number, message: string, code?: string | undefined, body?: unknown);
readonly isUnauthorized: boolean;
}
export interface AuthkitClientOptions {
baseUrl?: string;
accountBaseUrl?: string;
csrfToken?: string;
fetch?: typeof fetch;
}
declare class AuthkitClient {
private readonly _baseUrl;
private readonly _accountBaseUrl;
private readonly _csrfToken;
private readonly _fetch;
constructor(opts?: AuthkitClientOptions);
request<T>(method: string, url: string, body?: unknown, extraHeaders?: Record<string, string>): Promise<T>;
private get;
private post;
private patch;
private put;
private delete;
private b;
private a;
readonly admin: {
readonly overview: () => Promise<AdminOverview>;
readonly users: {
readonly list: (params?: {
search?: string;
page?: number;
size?: number;
}) => Promise<AdminUserListResult>;
readonly get: (id: string) => Promise<AdminUser>;
readonly create: (data: CreateUserInput) => Promise<AdminUser & {
invited?: boolean;
}>;
readonly update: (id: string, data: UpdateUserInput) => Promise<AdminUser>;
readonly disable: (id: string) => Promise<AdminUser>;
readonly enable: (id: string) => Promise<AdminUser>;
readonly resetPassword: (id: string) => Promise<ResetPasswordResult>;
readonly remove: (id: string) => Promise<DeletedResult>;
readonly getSessions: (id: string) => Promise<UserSessionsResult>;
readonly revokeSessions: (id: string) => Promise<RevokeSessionsResult>;
};
readonly sessions: {
readonly list: (accountId?: string) => Promise<UserSessionsResult>;
readonly revokeAll: (accountId?: string) => Promise<RevokeSessionsResult>;
};
readonly clients: {
readonly list: () => Promise<AdminClientListResult>;
readonly get: (id: string) => Promise<AdminClient>;
readonly create: (data?: CreateClientInput) => Promise<CreatedClientResult>;
readonly update: (id: string, data?: UpdateClientInput) => Promise<AdminClient>;
readonly remove: (id: string) => Promise<DeletedResult>;
readonly disable: (id: string) => Promise<AdminClient>;
readonly enable: (id: string) => Promise<AdminClient>;
readonly regenerateSecret: (id: string) => Promise<RegenerateSecretResult>;
};
readonly roles: {
readonly list: () => Promise<RoleListResult>;
readonly create: (data: CreateRoleInput) => Promise<RoleCatalogEntry>;
readonly update: (name: string, data: UpdateRoleInput) => Promise<RoleCatalogEntry>;
readonly remove: (name: string) => Promise<{
ok: boolean;
deleted: string;
}>;
};
readonly orgs: {
readonly list: () => Promise<AdminOrgListResult>;
readonly create: (data: CreateOrgInput) => Promise<AdminOrgEntry>;
readonly get: (id: string) => Promise<AdminOrgDetail>;
readonly update: (id: string, data: UpdateOrgInput) => Promise<AdminOrgEntry>;
readonly remove: (id: string) => Promise<{
id: string;
deleted: boolean;
}>;
readonly addMember: (orgId: string, data: {
accountId: string;
role: string;
}) => Promise<{
ok: boolean;
}>;
readonly removeMember: (orgId: string, accountId: string) => Promise<{
ok: boolean;
}>;
readonly updateMemberRole: (orgId: string, accountId: string, role: string) => Promise<{
ok: boolean;
}>;
readonly createInvitation: (orgId: string, data: {
email: string;
role: string;
}) => Promise<{
ok: boolean;
invitation: AdminOrgInvitation;
}>;
readonly revokeInvitation: (orgId: string, invitationId: string) => Promise<{
ok: boolean;
}>;
};
readonly audit: {
readonly list: (params?: AuditListParams) => Promise<AuditListResult>;
};
readonly settings: {
readonly list: (orgId?: string | null) => Promise<SettingListResult>;
readonly set: (key: string, value: unknown, orgId?: string | null) => Promise<SettingEntry>;
readonly remove: (key: string, orgId?: string | null) => Promise<{
key: string;
organizationId: string | null;
deleted: boolean;
}>;
};
readonly impersonation: {
readonly get: (userId: string) => Promise<ImpersonationPanel>;
};
readonly keys: {
readonly status: () => Promise<KeysStatus>;
readonly rotate: (input?: KeysRotateInput) => Promise<KeysRotateResult>;
};
readonly personalAgents: {
readonly overview: () => Promise<PersonalAgentsOverview>;
readonly connections: (params?: PersonalAgentConnectionsParams) => Promise<PersonalAgentConnectionsResult>;
readonly revokeConnection: (grantId: string) => Promise<{
revoked: true;
}>;
readonly setStatus: (input: PersonalAgentRegistryInput) => Promise<PersonalAgentRegistryResult>;
readonly removeEntry: (id: string) => Promise<{
removed: true;
}>;
};
};
readonly account: {
readonly me: () => Promise<AccountMe>;
readonly security: () => Promise<AccountSecurityOverview>;
readonly updateProfile: (data: UpdateProfileInput) => Promise<UpdateProfileResult>;
readonly changePassword: (data: ChangePasswordInput) => Promise<OkResult>;
readonly emailChange: (data: RequestEmailChangeInput) => Promise<EmailChangeResult>;
readonly cancelEmailChange: () => Promise<OkResult>;
readonly sessions: {
readonly list: () => Promise<AccountSessionsResult>;
readonly revoke: (id: string) => Promise<RevokeSessionResult>;
readonly revokeOthers: () => Promise<RevokeOthersResult>;
readonly revokeAll: () => Promise<RevokeAllResult>;
};
readonly apps: {
readonly list: () => Promise<AccountAppsResult>;
readonly revoke: (clientId: string) => Promise<RevokeAppResult>;
};
readonly agents: {
readonly list: () => Promise<AccountAgentsResult>;
readonly revoke: (grantId: string) => Promise<{
ok: true;
}>;
};
readonly mfa: (() => Promise<AccountMfaStatus>) & {
enroll: () => Promise<MfaEnrollResult>;
confirm: (code: string) => Promise<MfaConfirmResult>;
disable: () => Promise<MfaDisableResult>;
regenerateRecoveryCodes: () => Promise<MfaRecoveryCodesResult>;
passkeys: {
options: () => Promise<PasskeyRegistrationOptions>;
verify: (response: unknown) => Promise<OkResult>;
};
};
readonly loginMethods: {
readonly get: () => Promise<AccountLoginMethodsResult>;
readonly update: (data: {
methods: UserLoginMethodsInput;
}) => Promise<UpdateLoginMethodsResult>;
};
readonly passkeys: {
readonly list: () => Promise<AccountPasskeysResult>;
readonly remove: (id: string) => Promise<RemovePasskeyResult>;
};
readonly tokens: {
readonly list: () => Promise<AccountTokensResult>;
readonly create: (data?: CreateTokenInput) => Promise<CreatedPatResult>;
readonly remove: (id: string) => Promise<RevokeTokenResult>;
};
readonly orgs: {
readonly list: () => Promise<AccountOrgsResult>;
readonly invitations: () => Promise<AccountOrgInvitationsResult>;
readonly get: (id: string) => Promise<AccountOrgDetail>;
readonly create: (data: CreateAccountOrgInput) => Promise<CreatedAccountOrgResult>;
readonly activate: (id: string) => Promise<ActivateOrgResult>;
readonly deactivate: () => Promise<DeactivateOrgResult>;
readonly leave: (id: string) => Promise<LeaveOrgResult>;
readonly invite: (orgId: string, data: InviteOrgMemberInput) => Promise<CreatedOrgInvitationResult>;
readonly revokeInvitation: (orgId: string, invitationId: string) => Promise<RevokeOrgInvitationResult>;
readonly updateMemberRole: (orgId: string, accountId: string, role: string) => Promise<UpdateOrgMemberRoleResult>;
readonly removeMember: (orgId: string, accountId: string) => Promise<RemoveOrgMemberResult>;
readonly acceptInvitation: (token: string) => Promise<AcceptOrgInvitationResult>;
};
};
}
export declare function createAuthkitClient(opts?: AuthkitClientOptions): AuthkitClient;
export type { AuthkitClient };