"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.detectAwsAccount = detectAwsAccount;
const client_sts_1 = require("@aws-sdk/client-sts");
const credential_providers_1 = require("@aws-sdk/credential-providers");
/**
 * Detect AWS account ID from current credentials using STS GetCallerIdentity.
 * This call always succeeds if credentials are valid (cannot be denied by IAM).
 * Returns null if credentials are not available or invalid.
 */
async function detectAwsAccount() {
    try {
        const client = new client_sts_1.STSClient({
            credentials: (0, credential_providers_1.fromNodeProviderChain)(),
            region: process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION ?? 'us-east-1',
        });
        const response = await client.send(new client_sts_1.GetCallerIdentityCommand({}));
        return response.Account ?? null;
    }
    catch {
        return null;
    }
}
//# sourceMappingURL=aws-account.js.map