"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const actions_core_1 = require("@segment/actions-core");
const sts_1 = require("../../lib/AWS/sts");
const utils_1 = require("./utils");
const utils_2 = require("../../lib/AWS/utils");
const send_1 = __importDefault(require("./send"));
const destination = {
    name: 'Aws Kinesis',
    slug: 'actions-aws-kinesis',
    mode: 'cloud',
    authentication: {
        scheme: 'custom',
        fields: {
            iamRoleArn: {
                label: 'IAM Role ARN',
                description: 'The ARN of the IAM Role to assume for sending data to Kinesis.',
                type: 'string',
                required: true
            },
            iamExternalId: {
                label: 'IAM External ID',
                description: 'The external ID to use when assuming the IAM Role. Generate a secure string and treat it like a password.  This is often used as an additional security measure.',
                type: 'password',
                required: true
            }
        },
        testAuthentication: async (_, { settings }) => {
            const { iamRoleArn, iamExternalId } = settings;
            if (!(0, utils_1.validateIamRoleArnFormat)(iamRoleArn)) {
                throw new actions_core_1.IntegrationError('The provided IAM Role ARN format is not valid', 'INVALID_IAM_ROLE_ARN_FORMAT', 400);
            }
            await (0, sts_1.assumeRole)(iamRoleArn, iamExternalId, utils_2.APP_AWS_REGION);
        }
    },
    actions: {
        send: send_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map