/**
 * Signature utilities for eIDAS/DID
 */

import { KMSClient } from './kms';

export interface SignatureOptions {
  algorithm: 'RS256' | 'ES256' | 'EdDSA';
  keyId: string;
}

export class SignatureService {
  constructor(private kms: KMSClient) {}

  async sign(data: Buffer, _options: SignatureOptions): Promise<Buffer> {
    return await this.kms.sign(data);
  }

  async verify(
    data: Buffer,
    signature: Buffer,
    _options: SignatureOptions
  ): Promise<boolean> {
    return await this.kms.verify(data, signature);
  }

  async signJSON(data: unknown, options: SignatureOptions): Promise<string> {
    const jsonString = JSON.stringify(data);
    const signature = await this.sign(Buffer.from(jsonString), options);
    return signature.toString('base64');
  }
}

