const AWS = require('aws-sdk');
const fs = require('fs');
const path = require('path');

const vaultPath = path.join(process.env.USERPROFILE || process.env.HOME, '.ssh', 'vault');

// Civo config
const civo = new AWS.S3({
  endpoint: 'https://objectstore.nyc1.civo.com',
  accessKeyId: '0UZ69TH03Q292DMTB82B',
  secretAccessKey: 'JJ5XXZYvoWdnqBCNP5oREjACyrXeH6EgSqeSybT7',
  s3ForcePathStyle: true,
  signatureVersion: 'v4'
});

async function listObjects(s3, bucket, prefix) {
  return new Promise((resolve, reject) => {
    s3.listObjectsV2({ Bucket: bucket, Prefix: prefix }, (err, data) => {
      if (err) reject(err);
      else resolve(data.Contents || []);
    });
  });
}

async function main() {
  console.log("=== Listando arquivos no Civo ===");
  const civoFiles = await listObjects(civo, 'rede5', 'vault/ssh/');
  console.log(`Civo: ${civoFiles.length} arquivos`);
  civoFiles.forEach(f => console.log(`  ${f.Key}`));
}

main().catch(console.error);
