import * as ActionTypes from '../actionTypes'
import { RestoreState, UserLogout } from '../actions'

export enum LoginMethods {
  extension = 'extension',
  privateKey = 'privateKey',
  nsecBunker = 'nsecBunker',
  register = 'register'
}

export interface Keys {
  private: string
  public: string
}

export interface AuthState {
  loggedIn: boolean
  usersPubkey?: string
  loginMethod?: LoginMethods
  keyPair?: Keys
  nsecBunkerPubkey?: string
  nsecBunkerRelays?: string[]
}

export interface SetAuthState {
  type: typeof ActionTypes.SET_AUTH_STATE
  payload: AuthState
}

export interface UpdateLoginMethod {
  type: typeof ActionTypes.UPDATE_LOGIN_METHOD
  payload: LoginMethods | undefined
}

export interface UpdateKeyPair {
  type: typeof ActionTypes.UPDATE_KEYPAIR
  payload: Keys | undefined
}

export interface UpdateNsecBunkerPubkey {
  type: typeof ActionTypes.UPDATE_NSECBUNKER_PUBKEY
  payload: string | undefined
}

export interface UpdateNsecBunkerRelays {
  type: typeof ActionTypes.UPDATE_NSECBUNKER_RELAYS
  payload: string[] | undefined
}

export type AuthDispatchTypes =
  | RestoreState
  | SetAuthState
  | UpdateLoginMethod
  | UpdateKeyPair
  | UpdateNsecBunkerPubkey
  | UpdateNsecBunkerRelays
  | UserLogout
