"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getS3Client = void 0;
const client_s3_1 = require("@aws-sdk/client-s3");
const aws4_1 = __importDefault(require("aws4"));
async function generateS3RequestOptions(bucketName, region, path, method, body, accessKeyId, secretAccessKey) {
    const opts = {
        host: `${bucketName}.s3.amazonaws.com`,
        path,
        body,
        method,
        region
    };
    return aws4_1.default.sign(opts, {
        accessKeyId,
        secretAccessKey
    });
}
exports.default = generateS3RequestOptions;
const AWS_REGION = process.env['AWS_REGION'] || `us-west-2`;
const s3ClientCache = {};
const getS3Client = (targetService) => {
    if (s3ClientCache[targetService]) {
        return s3ClientCache[targetService];
    }
    const client = new client_s3_1.S3Client({ region: AWS_REGION });
    s3ClientCache[targetService] = client;
    return client;
};
exports.getS3Client = getS3Client;
//# sourceMappingURL=s3.js.map