import * as plugins from '../plugins.js';
import * as data from '../data/index.js';

export type TAdminAuthState = 'setupRequired' | 'ready' | 'configurationRequired';

export interface IReq_GetAdminAuthState extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetAdminAuthState
> {
  method: 'getAdminAuthState';
  request: {
    origin: string;
  };
  response: {
    state: TAdminAuthState;
    bootstrapCodeExpired: boolean;
    message?: string;
  };
}

export interface IReq_BeginAdminPasskeyRegistration extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_BeginAdminPasskeyRegistration
> {
  method: 'beginAdminPasskeyRegistration';
  request: {
    origin: string;
    bootstrapToken: string;
  };
  response: {
    ceremonyId: string;
    options: plugins.PublicKeyCredentialCreationOptionsJSON;
  };
}

export interface IReq_FinishAdminPasskeyRegistration extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_FinishAdminPasskeyRegistration
> {
  method: 'finishAdminPasskeyRegistration';
  request: {
    ceremonyId: string;
    bootstrapToken: string;
    response: plugins.RegistrationResponseJSON;
  };
  response: {
    identity: data.IIdentity;
  };
}

export interface IReq_BeginAdminPasskeyAuthentication extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_BeginAdminPasskeyAuthentication
> {
  method: 'beginAdminPasskeyAuthentication';
  request: {
    origin: string;
  };
  response: {
    ceremonyId: string;
    options: plugins.PublicKeyCredentialRequestOptionsJSON;
  };
}

export interface IReq_FinishAdminPasskeyAuthentication extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_FinishAdminPasskeyAuthentication
> {
  method: 'finishAdminPasskeyAuthentication';
  request: {
    ceremonyId: string;
    response: plugins.AuthenticationResponseJSON;
  };
  response: {
    identity: data.IIdentity;
  };
}

export interface IReq_AdminLogout extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_AdminLogout
> {
  method: 'adminLogout';
  request: {
    identity: data.IIdentity;
  };
  response: {
    ok: boolean;
  };
}

export interface IReq_VerifyIdentity extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_VerifyIdentity
> {
  method: 'verifyIdentity';
  request: {
    identity: data.IIdentity;
  };
  response: {
    valid: boolean;
    identity?: data.IIdentity;
  };
}
