/* eslint-disable @typescript-eslint/no-unused-vars */
import { EventTemplate, UnsignedEvent } from 'nostr-tools'
import { SignedEvent } from '../../types/nostr'

/**
 * This interface holds all operations that are dependant on the login method and is used as the basis for the login strategies.
 */
export interface LoginMethodOperations {
  nip04Encrypt(receiver: string, content: string): Promise<string>
  nip04Decrypt(sender: string, content: string): Promise<string>
  nip44Encrypt(receiver: string, content: string): Promise<string>
  nip44Decrypt(sender: string, content: string): Promise<string>
  signEvent(event: UnsignedEvent | EventTemplate): Promise<SignedEvent>
}

/**
 * This is the fallback class that provides base implementation for the {@link LoginMethodOperations login method operations} . Only used to throw errors in case when the LoginMethod is missing (login context not set).
 * @see {@link LoginMethodOperations}
 */
export class LoginMethodStrategy implements LoginMethodOperations {
  async nip04Encrypt(_receiver: string, _content: string): Promise<string> {
    throw new Error('Login method strategy is undefined')
  }
  async nip04Decrypt(_sender: string, _content: string): Promise<string> {
    throw new Error('Login method strategy is undefined')
  }
  async nip44Encrypt(_receiver: string, _content: string): Promise<string> {
    throw new Error('Login method strategy is undefined')
  }
  async nip44Decrypt(_sender: string, _content: string): Promise<string> {
    throw new Error('Login method strategy is undefined')
  }
  async signEvent(_event: UnsignedEvent | EventTemplate): Promise<SignedEvent> {
    return Promise.reject(
      `We could not sign the event, none of the signing methods are available`
    )
  }
}
