@microsoft/teams-ai
Version:
SDK focused on building AI based applications for Microsoft Teams.
55 lines • 2.3 kB
JavaScript
;
/**
* @module teams-ai
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TeamsAdapter = void 0;
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* Note: this class should never modify the way `CloudAdapter` is
* intended to work.
*/
const botbuilder_1 = require("botbuilder");
const package_json_1 = __importDefault(require("../package.json"));
const USER_AGENT = `teamsai-js/${package_json_1.default.version}`;
/**
* An adapter that implements the Bot Framework Protocol and can be hosted in different cloud environments both public and private.
*/
class TeamsAdapter extends botbuilder_1.CloudAdapter {
botFrameworkAuthConfig;
/**
* The credentials factory used by the bot adapter to create a [ServiceClientCredentials](xref:botframework-connector.ServiceClientCredentials) object.
*/
credentialsFactory;
get userAgent() {
return USER_AGENT;
}
constructor(botFrameworkAuthConfig, credentialsFactory, authConfiguration, connectorClientOptions) {
super(new botbuilder_1.ConfigurationBotFrameworkAuthentication(botFrameworkAuthConfig || {}, credentialsFactory, authConfiguration, undefined, {
...(connectorClientOptions || {}),
userAgent: USER_AGENT,
userAgentHeaderName: undefined
}));
this.botFrameworkAuthConfig = botFrameworkAuthConfig;
this.credentialsFactory =
credentialsFactory ??
new botbuilder_1.ConfigurationServiceClientCredentialFactory(botFrameworkAuthConfig);
}
async process(req, resOrSocket, logicOrHead, maybeLogic) {
if ('header' in resOrSocket && typeof logicOrHead === 'function') {
resOrSocket.header('User-Agent', USER_AGENT);
return super.process(req, resOrSocket, logicOrHead);
}
if ('connecting' in resOrSocket && typeof logicOrHead !== 'function' && !!maybeLogic) {
return super.process(req, resOrSocket, logicOrHead, maybeLogic);
}
}
}
exports.TeamsAdapter = TeamsAdapter;
//# sourceMappingURL=TeamsAdapter.js.map