UNPKG

botframework-connector

Version:

Bot Connector is autorest generated connector client.

74 lines 3.87 kB
"use strict"; /** * @module botframework-connector */ // 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.FederatedServiceClientCredentialsFactory = void 0; const assert_1 = require("assert"); const serviceClientCredentialsFactory_1 = require("./serviceClientCredentialsFactory"); const federatedAppCredentials_1 = require("./federatedAppCredentials"); /** * A Federated Credentials implementation of the [ServiceClientCredentialsFactory](xref:botframework-connector.ServiceClientCredentialsFactory) interface. */ class FederatedServiceClientCredentialsFactory extends serviceClientCredentialsFactory_1.ServiceClientCredentialsFactory { /** * Initializes a new instance of the [FederatedServiceClientCredentialsFactory](xref:botframework-connector.FederatedServiceClientCredentialsFactory) class. * * @param {string} appId App ID for the Application. * @param {string} clientId Client ID for the managed identity assigned to the bot. * @param {string} tenantId Tenant ID of the Azure AD tenant where the bot is created. * - **Required** for SingleTenant app types. * - **Optional** for MultiTenant app types. **Note**: '_botframework.com_' is the default tenant when no value is provided. * * More information: https://learn.microsoft.com/en-us/security/zero-trust/develop/identity-supported-account-types. * @param {string} clientAudience **Optional**. The Audience used in the Client's Federated Credential. **Default** (_api://AzureADTokenExchange_). */ constructor(appId, clientId, tenantId, clientAudience) { super(); this.appId = appId; this.clientId = clientId; this.tenantId = tenantId; this.clientAudience = clientAudience; (0, assert_1.ok)(appId === null || appId === void 0 ? void 0 : appId.trim(), 'FederatedServiceClientCredentialsFactory.constructor(): missing appId.'); (0, assert_1.ok)(clientId === null || clientId === void 0 ? void 0 : clientId.trim(), 'FederatedServiceClientCredentialsFactory.constructor(): missing clientId.'); } /** * @inheritdoc */ isValidAppId(appId = '') { return __awaiter(this, void 0, void 0, function* () { return appId === this.appId; }); } /** * @inheritdoc */ isAuthenticationDisabled() { return __awaiter(this, void 0, void 0, function* () { // Auth is always enabled for FIC. return; }); } /** * @inheritdoc */ createCredentials(appId, audience) { return __awaiter(this, void 0, void 0, function* () { (0, assert_1.ok)(yield this.isValidAppId(appId), 'FederatedServiceClientCredentialsFactory.createCredentials(): Invalid App ID.'); return new federatedAppCredentials_1.FederatedAppCredentials(this.appId, this.clientId, this.tenantId, audience, this.clientAudience); }); } } exports.FederatedServiceClientCredentialsFactory = FederatedServiceClientCredentialsFactory; //# sourceMappingURL=federatedServiceClientCredentialsFactory.js.map