/**
 * Configuration options for the ExternalE2EEKeyProvider.
 */
export interface E2EEKeyProviderOptions {
  /**
   * The window size used for key ratcheting.
   *
   * @default 0
   */
  ratchetWindowSize?: number;

  /**
   * The number of tolerated decryption failures before taking action.
   *
   * @default -1
   */
  failureTolerance?: number;

  /**
   * Determines whether frames should be discarded when the cryptor is not ready.
   *
   * @default false
   */
  discardFrameWhenCryptorNotReady?: boolean;
}

/**
 * Provides end-to-end encryption (E2EE) key management using a shared passphrase
 * across all participants.
 */
export class ExternalE2EEKeyProvider {
  /**
   * Creates a new instance of `ExternalE2EEKeyProvider`.
   *
   * @param options - Optional configuration settings for the key provider.
   */
  constructor(options?: E2EEKeyProviderOptions);

  /**
   * Sets the shared encryption key used for end-to-end encryption.
   *
   * @param key - The shared encryption key. Can be a string or an ArrayBuffer.
   * @returns A promise that resolves once the key has been successfully set.
   *
   * @example
   * ```ts
   * const keyProvider = new ExternalE2EEKeyProvider({
   *   discardFrameWhenCryptorNotReady: true,
   * });
   *
   * await keyProvider.setSharedKey("<SECRET_KEY>");
   * ```
   */
  setSharedKey(key: string | ArrayBuffer): Promise<void>;
}
