"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createApiClient = void 0;
const docusign_esign_1 = __importDefault(require("docusign-esign"));
/**
 * Creates a DocuSign `ApiClient` and authorizes with JWT
 */
const createApiClient = async ({ integrationKey, userId, rsaKey, baseUrl, }) => {
    var _a, _b;
    const client = new docusign_esign_1.default.ApiClient();
    client.setBasePath(`${baseUrl}/restapi`);
    const authResult = await client.requestJWTUserToken(integrationKey, userId, ['signature'], Buffer.from(rsaKey, 'base64'), 6000);
    client.addDefaultHeader('Authorization', `Bearer ${(_b = (_a = authResult === null || authResult === void 0 ? void 0 : authResult.body) === null || _a === void 0 ? void 0 : _a.access_token) !== null && _b !== void 0 ? _b : ''}`);
    return client;
};
exports.createApiClient = createApiClient;
//# sourceMappingURL=createClient.js.map