botframework-connector
Version:
Bot Connector is autorest generated connector client.
75 lines • 3.53 kB
JavaScript
;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BotFrameworkAuthentication = void 0;
const botframework_schema_1 = require("botframework-schema");
const jwtTokenValidation_1 = require("./jwtTokenValidation");
const skillValidation_1 = require("./skillValidation");
/**
* Represents a Cloud Environment used to authenticate Bot Framework Protocol network calls within this environment.
*/
class BotFrameworkAuthentication {
// eslint-disable-next-line jsdoc/require-returns-check
/**
* Creates a BotFrameworkClient for calling Skills.
*
* @returns A [BotFrameworkClient](xref:botframework-connector.BotFrameworkClient).
*/
createBotFrameworkClient() {
throw new Error('NotImplemented');
}
// eslint-disable-next-line jsdoc/require-returns-check
/**
* Gets the originating audience from Bot OAuth scope.
*
* @returns The originating audience.
*/
getOriginatingAudience() {
throw new Error('NotImplemented');
}
// TODO: Update docstring - this is a direct port from .NET
// eslint-disable-next-line jsdoc/require-returns-check
/**
* Authenticate Bot Framework Protocol request to Skills.
*
* @param authHeader The HTTP auth header in the skill request.
* @returns {Promise<ClaimsIdentity>} A [ClaimsIdentity](xref:botframework-connector.ClaimsIdentity).
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
authenticateChannelRequest(authHeader) {
throw new Error('NotImplemented');
}
/**
* Generates the appropriate callerId to write onto the Activity, this might be null.
*
* @param credentialFactory A ServiceClientCredentialsFactory to use.
* @param claimsIdentity The inbound claims.
* @param callerId The default callerId to use if this is not a skill.
* @returns The callerId, this might be null.
*/
generateCallerId(credentialFactory, claimsIdentity, callerId) {
return __awaiter(this, void 0, void 0, function* () {
// Is the bot accepting all incoming messages?
if (yield credentialFactory.isAuthenticationDisabled()) {
// Return null so that the callerId is cleared.
return null;
}
// Is the activity from another bot?
return skillValidation_1.SkillValidation.isSkillClaim(claimsIdentity.claims)
? `${botframework_schema_1.CallerIdConstants.BotToBotPrefix}${jwtTokenValidation_1.JwtTokenValidation.getAppIdFromClaims(claimsIdentity.claims)}`
: callerId;
});
}
}
exports.BotFrameworkAuthentication = BotFrameworkAuthentication;
//# sourceMappingURL=botFrameworkAuthentication.js.map