From b6b56e55cc160e9b33f79ab31290e0cde68627fc Mon Sep 17 00:00:00 2001 From: Emiliano Quiroga Date: Wed, 4 May 2022 16:40:16 -0300 Subject: [PATCH 1/7] Warnings fixed in botbuilder-ai-orchestrator --- .../etc/botbuilder-ai-orchestrator.api.md | 2 +- libraries/botbuilder-ai-orchestrator/package.json | 12 ++++++------ .../src/orchestratorBotComponent.ts | 7 +++++++ .../src/orchestratorRecognizer.ts | 4 ++++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/libraries/botbuilder-ai-orchestrator/etc/botbuilder-ai-orchestrator.api.md b/libraries/botbuilder-ai-orchestrator/etc/botbuilder-ai-orchestrator.api.md index 77188c0319..333d898e85 100644 --- a/libraries/botbuilder-ai-orchestrator/etc/botbuilder-ai-orchestrator.api.md +++ b/libraries/botbuilder-ai-orchestrator/etc/botbuilder-ai-orchestrator.api.md @@ -28,7 +28,7 @@ export enum LabelType { Intent = 1 } -// @public (undocumented) +// @public class OrchestratorBotComponent extends BotComponent { // (undocumented) configureServices(services: ServiceCollection, _configuration: Configuration): void; diff --git a/libraries/botbuilder-ai-orchestrator/package.json b/libraries/botbuilder-ai-orchestrator/package.json index 2defa69874..e39387f104 100644 --- a/libraries/botbuilder-ai-orchestrator/package.json +++ b/libraries/botbuilder-ai-orchestrator/package.json @@ -31,16 +31,16 @@ "dependencies": { "botbuilder-dialogs-adaptive": "4.1.6", "@microsoft/orchestrator-core": "~4.14.3", - "uuid": "^8.3.2" + "uuid": "^8.3.2", + "adaptive-expressions": "4.1.6", + "botbuilder-core": "4.1.6", + "botbuilder-dialogs-declarative": "4.1.6", + "botbuilder-dialogs-adaptive-runtime-core": "4.1.6", + "botbuilder-dialogs": "4.1.6" }, "peerDependencies": { - "botbuilder-dialogs-declarative": "4.1.6", - "botbuilder-dialogs-adaptive-runtime-core": "4.1.6" }, "devDependencies": { - "adaptive-expressions": "4.1.6", - "botbuilder-core": "4.1.6", - "botbuilder-dialogs": "4.1.6" }, "scripts": { "build": "tsc -b", diff --git a/libraries/botbuilder-ai-orchestrator/src/orchestratorBotComponent.ts b/libraries/botbuilder-ai-orchestrator/src/orchestratorBotComponent.ts index 598a7b7435..ebde0032d9 100644 --- a/libraries/botbuilder-ai-orchestrator/src/orchestratorBotComponent.ts +++ b/libraries/botbuilder-ai-orchestrator/src/orchestratorBotComponent.ts @@ -6,7 +6,14 @@ import { ComponentDeclarativeTypes } from 'botbuilder-dialogs-declarative'; import { OrchestratorRecognizer } from './orchestratorRecognizer'; import { ServiceCollection, Configuration } from 'botbuilder-dialogs-adaptive-runtime-core'; +/** + * Define component assets for Orchestrator. + */ export class OrchestratorBotComponent extends BotComponent { + /** + * @param services Services collection. + * @param _configuration Configuration for the bot component. + */ configureServices(services: ServiceCollection, _configuration: Configuration): void { services.composeFactory('declarativeTypes', (declarativeTypes) => declarativeTypes.concat({ diff --git a/libraries/botbuilder-ai-orchestrator/src/orchestratorRecognizer.ts b/libraries/botbuilder-ai-orchestrator/src/orchestratorRecognizer.ts index da14c357d5..e571ef22ee 100644 --- a/libraries/botbuilder-ai-orchestrator/src/orchestratorRecognizer.ts +++ b/libraries/botbuilder-ai-orchestrator/src/orchestratorRecognizer.ts @@ -120,6 +120,10 @@ export class OrchestratorRecognizer extends AdaptiveRecognizer implements Orches */ readonly entityProperty = 'entityResult'; + /** + * @param property The key of the conditional selector configuration. + * @returns The converter for the selector configuration. + */ getConverter(property: keyof OrchestratorRecognizerConfiguration): Converter | ConverterFactory { switch (property) { case 'modelFolder': From f9bd07b7da10d11dc59f732a4cf08cb68df23d73 Mon Sep 17 00:00:00 2001 From: Emiliano Quiroga Date: Fri, 6 May 2022 14:49:30 -0300 Subject: [PATCH 2/7] Warnings in botbuilder fixed. --- libraries/botbuilder/etc/botbuilder.api.md | 4 ++-- libraries/botbuilder/src/inspectionMiddleware.ts | 4 ++-- libraries/botbuilder/src/teamsActivityHelpers.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/botbuilder/etc/botbuilder.api.md b/libraries/botbuilder/etc/botbuilder.api.md index 31e0c90bbf..e79e5d208e 100644 --- a/libraries/botbuilder/etc/botbuilder.api.md +++ b/libraries/botbuilder/etc/botbuilder.api.md @@ -269,7 +269,7 @@ export class HandoffEventNames { // Warning: (ae-forgotten-export) The symbol "InterceptionMiddleware" needs to be exported by the entry point index.d.ts // -// @public +// @public @deprecated export class InspectionMiddleware extends InterceptionMiddleware { constructor(inspectionState: InspectionState, userState?: UserState, conversationState?: ConversationState, credentials?: Partial); protected inbound(turnContext: TurnContext, traceActivity: Partial): Promise; @@ -278,7 +278,7 @@ export class InspectionMiddleware extends InterceptionMiddleware { protected traceState(turnContext: TurnContext): Promise; } -// @public +// @public @deprecated export class InspectionState extends BotState { constructor(storage: Storage_2); protected getStorageKey(_turnContext: TurnContext): string; diff --git a/libraries/botbuilder/src/inspectionMiddleware.ts b/libraries/botbuilder/src/inspectionMiddleware.ts index b3af0b721c..0214548065 100644 --- a/libraries/botbuilder/src/inspectionMiddleware.ts +++ b/libraries/botbuilder/src/inspectionMiddleware.ts @@ -169,7 +169,7 @@ abstract class InterceptionMiddleware implements Middleware { * @remarks * InspectionMiddleware for emulator inspection of runtime Activities and BotState. * - * @obsolete This class will be removed in a future version of the framework. + * @deprecated This class will be removed in a future version of the framework. */ export class InspectionMiddleware extends InterceptionMiddleware { private static readonly command = '/INSPECT'; @@ -445,7 +445,7 @@ class InspectionSessionsByStatus { * @remarks * InspectionState for use by the InspectionMiddleware for emulator inspection of runtime Activities and BotState. * - * @obsolete This class will be removed in a future version of the framework. + * @deprecated This class will be removed in a future version of the framework. */ export class InspectionState extends BotState { /** diff --git a/libraries/botbuilder/src/teamsActivityHelpers.ts b/libraries/botbuilder/src/teamsActivityHelpers.ts index 87b98fc466..df8ad07c1b 100644 --- a/libraries/botbuilder/src/teamsActivityHelpers.ts +++ b/libraries/botbuilder/src/teamsActivityHelpers.ts @@ -106,7 +106,7 @@ export function teamsGetChannelId(activity: Activity): string | null { */ export function teamsNotifyUser( activity: Partial, - alertInMeeting: boolean = false, + alertInMeeting = false, externalResourceUrl?: string ): void { validateActivity(activity); From 920ee948efeba83c93e2a715874b80806150559c Mon Sep 17 00:00:00 2001 From: Emiliano Quiroga Date: Mon, 9 May 2022 10:37:27 -0300 Subject: [PATCH 3/7] Warnings fixed in adaptive-expressions --- libraries/adaptive-expressions/.eslintrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/adaptive-expressions/.eslintrc.json b/libraries/adaptive-expressions/.eslintrc.json index 5cd03b02d6..f0aaebfc16 100644 --- a/libraries/adaptive-expressions/.eslintrc.json +++ b/libraries/adaptive-expressions/.eslintrc.json @@ -1,5 +1,5 @@ { "extends": "../../.eslintrc.json", "plugins": ["only-warn"], - "ignorePatterns": ["**/generated/*"] + "ignorePatterns": ["**/generated/*", "expressionProperty.test.js"] } \ No newline at end of file From 7f9eec6de465ef0fad66ca86c9050af520024382 Mon Sep 17 00:00:00 2001 From: Emiliano Quiroga Date: Mon, 9 May 2022 14:52:19 -0300 Subject: [PATCH 4/7] Warnings fixed in botframework-connector --- .../src/auth/appCredentials.ts | 8 +++ .../auth/botFrameworkAuthenticationFactory.ts | 16 +++++ .../src/auth/botFrameworkClientImpl.ts | 17 ++++++ .../src/auth/claimsIdentity.ts | 5 ++ .../src/auth/connectorFactory.ts | 3 + .../src/auth/connectorFactoryImpl.ts | 16 +++++ .../src/auth/endorsementsValidator.ts | 3 + ...IdentityServiceClientCredentialsFactory.ts | 2 +- ...parameterizedBotFrameworkAuthentication.ts | 57 ++++++++++++++++++ .../passwordServiceClientCredentialFactory.ts | 20 +++++++ .../src/auth/userTokenClientImpl.ts | 59 +++++++++++++++++++ .../src/teams/operations/teams.ts | 13 ++++ 12 files changed, 218 insertions(+), 1 deletion(-) diff --git a/libraries/botframework-connector/src/auth/appCredentials.ts b/libraries/botframework-connector/src/auth/appCredentials.ts index 3faf06bbac..f1f747331c 100644 --- a/libraries/botframework-connector/src/auth/appCredentials.ts +++ b/libraries/botframework-connector/src/auth/appCredentials.ts @@ -117,6 +117,9 @@ export abstract class AppCredentials implements msrest.ServiceClientCredentials * @param {Date} expiration? The expiration date after which this service url is not trusted anymore */ public static trustServiceUrl(serviceUrl: string, expiration?: Date): void; + /** + * Adds the host of service url to MicrosoftAppCredentials trusted hosts. + */ public static trustServiceUrl(): void { // no-op } @@ -130,6 +133,11 @@ export abstract class AppCredentials implements msrest.ServiceClientCredentials * @returns {boolean} True if the host of the service url is trusted; False otherwise. */ public static isTrustedServiceUrl(serviceUrl: string): boolean; + /** + * Checks if the service url is for a trusted host or not. + * + * @returns True if the host of the service url is trusted; False otherwise. + */ public static isTrustedServiceUrl(): boolean { return true; } diff --git a/libraries/botframework-connector/src/auth/botFrameworkAuthenticationFactory.ts b/libraries/botframework-connector/src/auth/botFrameworkAuthenticationFactory.ts index c3c9070f5c..a80e5b6e8b 100644 --- a/libraries/botframework-connector/src/auth/botFrameworkAuthenticationFactory.ts +++ b/libraries/botframework-connector/src/auth/botFrameworkAuthenticationFactory.ts @@ -55,6 +55,22 @@ export class BotFrameworkAuthenticationFactory { connectorClientOptions?: ConnectorClientOptions ): BotFrameworkAuthentication; + /** + * @param maybeChannelService The Channel Service. + * @param maybeValidateAuthority The validate authority value to use. + * @param maybeToChannelFromBotLoginUrl The to Channel from bot login url. + * @param maybeToChannelFromBotOAuthScope The to Channel from bot oauth scope. + * @param maybeToBotFromChannelTokenIssuer The to bot from Channel Token Issuer. + * @param maybeOAuthUrl The oAuth url. + * @param maybeToBotFromChannelOpenIdMetadataUrl The to bot from Channel Open Id Metadata url. + * @param maybeToBotFromEmulatorOpenIdMetadataUrl The to bot from Emulator Open Id Metadata url. + * @param maybeCallerId The callerId set on on authenticated [Activities](xref:botframework-schema.Activity). + * @param maybeCredentialFactory The [ServiceClientCredentialsFactory](xref:botframework-connector.ServiceClientCredentialsFactory) to use to create credentials. + * @param maybeAuthConfiguration The [AuthenticationConfiguration](xref:botframework-connector.AuthenticationConfiguration) to use. + * @param maybeBotFrameworkClientFetch The fetch to use in BotFrameworkClient. + * @param maybeConnectorClientOptions The [ConnectorClientOptions](xref:botframework-connector.ConnectorClientOptions) to use when creating ConnectorClients. + * @returns A new [BotFrameworkAuthentication](xref:botframework-connector.BotFrameworkAuthentication) instance. + */ static create( maybeChannelService?: string, maybeValidateAuthority?: boolean, diff --git a/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts b/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts index 7efb6303d8..c0ced23513 100644 --- a/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts +++ b/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts @@ -27,7 +27,15 @@ const botFrameworkClientFetchImpl: typeof fetch = async (input, init) => { }; // Internal +/** + * Implementation of BotFrameworkClient. + */ export class BotFrameworkClientImpl implements BotFrameworkClient { + /** + * @param credentialsFactory A [ServiceClientCredentialsFactory](xref:botframework-connector.ServiceClientCredentialsFactory) instance. + * @param loginEndpoint The login url. + * @param botFrameworkClientFetch A custom Fetch implementation to be used in the [BotFrameworkClient](xref:botframework-connector.BotFrameworkClient). + */ constructor( private readonly credentialsFactory: ServiceClientCredentialsFactory, private readonly loginEndpoint: string, @@ -36,6 +44,15 @@ export class BotFrameworkClientImpl implements BotFrameworkClient { ok(typeof botFrameworkClientFetch === 'function'); } + /** + * @param fromBotId The MicrosoftAppId of the bot sending the activity. + * @param toBotId The MicrosoftAppId of the bot receiving the activity. + * @param toUrl The URL of the bot receiving the activity. + * @param serviceUrl The callback Url for the skill host. + * @param conversationId A conversation ID to use for the conversation with the skill. + * @param activity The Activity to send to forward. + * @returns Promise with optional invokeResponse. + */ async postActivity( fromBotId: string, toBotId: string, diff --git a/libraries/botframework-connector/src/auth/claimsIdentity.ts b/libraries/botframework-connector/src/auth/claimsIdentity.ts index 8b9a591a5c..37a9627552 100644 --- a/libraries/botframework-connector/src/auth/claimsIdentity.ts +++ b/libraries/botframework-connector/src/auth/claimsIdentity.ts @@ -26,6 +26,11 @@ export class ClaimsIdentity { */ constructor(public readonly claims: Claim[], private readonly authenticationType?: string | boolean) {} + /** + * Returns authentication status. + * + * @returns True if is authenticated. + */ public get isAuthenticated(): boolean { if (typeof this.authenticationType === 'boolean') { return this.authenticationType; diff --git a/libraries/botframework-connector/src/auth/connectorFactory.ts b/libraries/botframework-connector/src/auth/connectorFactory.ts index 645c5803fa..48fbae9007 100644 --- a/libraries/botframework-connector/src/auth/connectorFactory.ts +++ b/libraries/botframework-connector/src/auth/connectorFactory.ts @@ -3,6 +3,9 @@ import { ConnectorClient } from '../connectorApi/connectorClient'; +/** + * A factory class used to create ConnectorClients with appropriate credentials for the current appId. + */ export abstract class ConnectorFactory { /** * A factory method used to create [ConnectorClient](xref:botframework-connector.ConnectorClient) instances. diff --git a/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts b/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts index aa81c24253..0c4bb04605 100644 --- a/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts +++ b/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts @@ -14,7 +14,18 @@ export const USER_AGENT = `Microsoft-BotFramework/3.1 ${packageInfo.name}/${ } ${getDefaultUserAgentValue()} `; // Internal +/** + * Implementation of ConnectorFactory. + */ export class ConnectorFactoryImpl extends ConnectorFactory { + /** + * @param appId The AppID. + * @param toChannelFromBotOAuthScope The to Channel from bot oauth scope. + * @param loginEndpoint The login url. + * @param validateAuthority The validate authority value to use. + * @param credentialFactory A ServiceClientCredentialsFactory to use. + * @param connectorClientOptions The [ConnectorClientOptions](xref:botframework-connector.ConnectorClientOptions) to use when creating ConnectorClients. + */ constructor( private readonly appId: string, private readonly toChannelFromBotOAuthScope: string, @@ -26,6 +37,11 @@ export class ConnectorFactoryImpl extends ConnectorFactory { super(); } + /** + * @param serviceUrl The client's service URL. + * @param audience The audience to use for outbound communication. The will vary by cloud environment. + * @returns The new instance of the ConnectorClient class. + */ async create(serviceUrl: string, audience?: string): Promise { // Use the credentials factory to create credentails specific to this particular cloud environment. const credentials = await this.credentialFactory.createCredentials( diff --git a/libraries/botframework-connector/src/auth/endorsementsValidator.ts b/libraries/botframework-connector/src/auth/endorsementsValidator.ts index 7369417ee0..9cf92da1e9 100644 --- a/libraries/botframework-connector/src/auth/endorsementsValidator.ts +++ b/libraries/botframework-connector/src/auth/endorsementsValidator.ts @@ -10,6 +10,9 @@ import { StatusCodes } from 'botframework-schema'; * Licensed under the MIT License. */ +/** + * Contains helper methods for verifying JWT endorsements. + */ export class EndorsementsValidator { /** * Verify that the set of ChannelIds, which come from the incoming activities, diff --git a/libraries/botframework-connector/src/auth/managedIdentityServiceClientCredentialsFactory.ts b/libraries/botframework-connector/src/auth/managedIdentityServiceClientCredentialsFactory.ts index a9c2edf141..00d5b9b047 100644 --- a/libraries/botframework-connector/src/auth/managedIdentityServiceClientCredentialsFactory.ts +++ b/libraries/botframework-connector/src/auth/managedIdentityServiceClientCredentialsFactory.ts @@ -12,7 +12,7 @@ import { ManagedIdentityAppCredentials } from './managedIdentityAppCredentials'; import { ServiceClientCredentialsFactory } from './serviceClientCredentialsFactory'; import { ok } from 'assert'; -/* +/** * A Managed Identity implementation of the [ServiceClientCredentialsFactory](xref:botframework-connector.ServiceClientCredentialsFactory) abstract class. */ export class ManagedIdentityServiceClientCredentialsFactory extends ServiceClientCredentialsFactory { diff --git a/libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts b/libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts index 8db578437d..e039d19836 100644 --- a/libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts +++ b/libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts @@ -35,7 +35,24 @@ function getAppId(claimsIdentity: ClaimsIdentity): string | undefined { } // Internal +/** + * Parametrized Cloud Environment used to authenticate Bot Framework Protocol network calls within this environment. + */ export class ParameterizedBotFrameworkAuthentication extends BotFrameworkAuthentication { + /** + * @param validateAuthority The validate authority value to use. + * @param toChannelFromBotLoginUrl The to Channel from bot login url. + * @param toChannelFromBotOAuthScope The to Channel from bot oauth scope. + * @param toBotFromChannelTokenIssuer The to bot from Channel Token Issuer. + * @param oAuthUrl The OAuth url. + * @param toBotFromChannelOpenIdMetadataUrl The to bot from Channel Open Id Metadata url. + * @param toBotFromEmulatorOpenIdMetadataUrl The to bot from Emulator Open Id Metadata url. + * @param callerId The callerId set on on authenticated [Activities](xref:botframework-schema.Activity). + * @param credentialsFactory The [ServiceClientCredentialsFactory](xref:botframework-connector.ServiceClientCredentialsFactory) to use to create credentials. + * @param authConfiguration The [AuthenticationConfiguration](xref:botframework-connector.AuthenticationConfiguration) to use. + * @param botFrameworkClientFetch The fetch to use in BotFrameworkClient. + * @param connectorClientOptions The [ConnectorClientOptions](xref:botframework-connector.ConnectorClientOptions) to use when creating ConnectorClients. + */ constructor( private readonly validateAuthority: boolean, private readonly toChannelFromBotLoginUrl: string, @@ -53,10 +70,19 @@ export class ParameterizedBotFrameworkAuthentication extends BotFrameworkAuthent super(); } + /** + * Gets the originating audience from Bot OAuth scope. + * + * @returns The originating audience. + */ getOriginatingAudience(): string { return this.toChannelFromBotOAuthScope; } + /** + * @param authHeader The http auth header received in the skill request. + * @returns The identity validation result. + */ async authenticateChannelRequest(authHeader: string): Promise { if (!authHeader.trim()) { const isAuthDisabled = await this.credentialsFactory.isAuthenticationDisabled(); @@ -76,6 +102,13 @@ export class ParameterizedBotFrameworkAuthentication extends BotFrameworkAuthent return this.JwtTokenValidation_validateAuthHeader(authHeader, 'unknown', null); } + /** + * Validate Bot Framework Protocol requests. + * + * @param activity The inbound Activity. + * @param authHeader The http auth header received in the skill request. + * @returns Promise with AuthenticateRequestResult. + */ async authenticateRequest(activity: Activity, authHeader: string): Promise { const claimsIdentity = await this.JwtTokenValidation_authenticateRequest(activity, authHeader); @@ -101,6 +134,13 @@ export class ParameterizedBotFrameworkAuthentication extends BotFrameworkAuthent }; } + /** + * Validate Bot Framework Protocol requests. + * + * @param authHeader The http auth header received in the skill request. + * @param channelIdHeader The channel Id HTTP header. + * @returns Promise with AuthenticateRequestResult. + */ async authenticateStreamingRequest( authHeader: string, channelIdHeader: string @@ -118,6 +158,12 @@ export class ParameterizedBotFrameworkAuthentication extends BotFrameworkAuthent return { audience: outboundAudience, callerId, claimsIdentity }; } + /** + * Creates the appropriate UserTokenClient instance. + * + * @param claimsIdentity The inbound Activity's ClaimsIdentity. + * @returns Promise with UserTokenClient instance. + */ async createUserTokenClient(claimsIdentity: ClaimsIdentity): Promise { const appId = getAppId(claimsIdentity); const credentials = await this.credentialsFactory.createCredentials( @@ -130,6 +176,12 @@ export class ParameterizedBotFrameworkAuthentication extends BotFrameworkAuthent return new UserTokenClientImpl(appId, credentials, this.oAuthUrl, this.connectorClientOptions); } + /** + * Creates a ConnectorFactory that can be used to create IConnectorClient that use credentials from this particular cloud environment. + * + * @param claimsIdentity The inbound Activity's ClaimsIdentity. + * @returns A ConnectorFactory. + */ createConnectorFactory(claimsIdentity: ClaimsIdentity): ConnectorFactory { return new ConnectorFactoryImpl( getAppId(claimsIdentity), @@ -140,6 +192,11 @@ export class ParameterizedBotFrameworkAuthentication extends BotFrameworkAuthent ); } + /** + * Creates a BotFrameworkClient used for calling Skills. + * + * @returns A BotFrameworkClient instance to call Skills. + */ createBotFrameworkClient(): BotFrameworkClient { return new BotFrameworkClientImpl( this.credentialsFactory, diff --git a/libraries/botframework-connector/src/auth/passwordServiceClientCredentialFactory.ts b/libraries/botframework-connector/src/auth/passwordServiceClientCredentialFactory.ts index efcffc2cd8..ad768c15b9 100644 --- a/libraries/botframework-connector/src/auth/passwordServiceClientCredentialFactory.ts +++ b/libraries/botframework-connector/src/auth/passwordServiceClientCredentialFactory.ts @@ -65,14 +65,34 @@ export class PasswordServiceClientCredentialFactory implements ServiceClientCred this.tenantId = tenantId ?? null; } + /** + * Validates an app ID. + * + * @param appId The appId to validate. + * @returns Promise with the validation result. + */ async isValidAppId(appId = ''): Promise { return appId === this.appId; } + /** + * Checks whether bot authentication is disabled. + * + * @returns Promise with the validation result. + */ async isAuthenticationDisabled(): Promise { return stringExt.isNilOrEmpty(this.appId); } + /** + * A factory method for creating ServiceClientCredentials. + * + * @param appId The appId. + * @param audience The audience. + * @param loginEndpoint The login url. + * @param validateAuthority The validate authority vale to use. + * @returns A Promise representing the result of the operation. + */ async createCredentials( appId: string, audience: string, diff --git a/libraries/botframework-connector/src/auth/userTokenClientImpl.ts b/libraries/botframework-connector/src/auth/userTokenClientImpl.ts index 882f14928d..337f8e278d 100644 --- a/libraries/botframework-connector/src/auth/userTokenClientImpl.ts +++ b/libraries/botframework-connector/src/auth/userTokenClientImpl.ts @@ -9,8 +9,17 @@ import { TokenApiClient } from '../tokenApi/tokenApiClient'; import { UserTokenClient } from './userTokenClient'; // Internal +/** + * Implementation of the Client for access user token service. + */ export class UserTokenClientImpl extends UserTokenClient { private readonly client: TokenApiClient; + /** + * @param appId The appId. + * @param credentials AppCredentials for OAuth. + * @param oauthEndpoint The OAuth API endpoint. + * @param connectorClientOptions A ConnectorClientOptions object. + */ constructor( private readonly appId: string, credentials: ServiceClientCredentials, @@ -24,6 +33,15 @@ export class UserTokenClientImpl extends UserTokenClient { ); } + /** + * Attempts to retrieve the token for a user that's in a login flow. + * + * @param userId The user id that will be associated with the token. + * @param connectionName Name of the auth connection to use. + * @param channelId The channel Id that will be associated with the token. + * @param magicCode (Optional) Optional user entered code to validate. + * @returns The token Response. + */ async getUserToken( userId: string, connectionName: string, @@ -44,6 +62,14 @@ export class UserTokenClientImpl extends UserTokenClient { return result._response.parsedBody; } + /** + * A Task representing the result of the asynchronous operation. + * + * @param connectionName Name of the auth connection to use + * @param activity The Activity from which to derive the token exchange state. + * @param finalRedirect The final URL that the OAuth flow will redirect to. + * @returns A promise representing the result of the operation. + */ async getSignInResource( connectionName: string, activity: Activity, @@ -65,6 +91,13 @@ export class UserTokenClientImpl extends UserTokenClient { return result._response.parsedBody; } + /** + * Signs the user out with the token server. + * + * @param userId The user id that will be associated with the token. + * @param connectionName Name of the auth connection to use. + * @param channelId The channel Id that will be associated with the token. + */ async signOutUser(userId: string, connectionName: string, channelId: string): Promise { z.object({ userId: z.string(), @@ -79,6 +112,14 @@ export class UserTokenClientImpl extends UserTokenClient { await this.client.userToken.signOut(userId, { channelId, connectionName }); } + /** + * Retrieves the token status for each configured connection for the given user. + * + * @param userId The user id that will be associated with the token. + * @param channelId The channel Id that will be associated with the token. + * @param includeFilter The includeFilter. + * @returns A promise of Array of TokenStatus. + */ async getTokenStatus(userId: string, channelId: string, includeFilter: string): Promise { z.object({ userId: z.string(), @@ -95,6 +136,15 @@ export class UserTokenClientImpl extends UserTokenClient { return result._response.parsedBody; } + /** + * Retrieves Azure Active Directory tokens for particular resources on a configured connection. + * + * @param userId The user id that will be associated with the token. + * @param connectionName Name of the auth connection to use. + * @param resourceUrls The list of resource URLs to retrieve tokens for. + * @param channelId The channel Id that will be associated with the token. + * @returns A promise of Dictionary of resourceUrl to the corresponding TokenResponse. + */ async getAadTokens( userId: string, connectionName: string, @@ -120,6 +170,15 @@ export class UserTokenClientImpl extends UserTokenClient { return result._response.parsedBody as Record; } + /** + * Performs a token exchange operation such as for single sign-on. + * + * @param userId The user id that will be associated with the token. + * @param connectionName Name of the auth connection to use. + * @param channelId The channel Id that will be associated with the token. + * @param exchangeRequest The exchange request details, either a token to exchange or a uri to exchange + * @returns A promise representing the result of the operation. + */ async exchangeToken( userId: string, connectionName: string, diff --git a/libraries/botframework-connector/src/teams/operations/teams.ts b/libraries/botframework-connector/src/teams/operations/teams.ts index f368a9540c..19bc854794 100644 --- a/libraries/botframework-connector/src/teams/operations/teams.ts +++ b/libraries/botframework-connector/src/teams/operations/teams.ts @@ -166,6 +166,13 @@ export class Teams { options: Models.TeamsFetchMeetingParticipantOptionalParams, callback: msRest.ServiceCallback ): void; + /** + * @param meetingId Meeting Id. + * @param participantId Participant Id. + * @param options The optional parameters. + * @param callback The callback. + * @returns Promise with TeamsFetchMeetingParticipantResponse. + */ fetchMeetingParticipant( meetingId: string, participantId: string, @@ -213,6 +220,12 @@ export class Teams { options: msRest.RequestOptionsBase | msRest.ServiceCallback, callback: msRest.ServiceCallback ): void; + /** + * @param meetingId Meeting Id. + * @param options The optional parameters. + * @param callback The callback. + * @returns Promise with TeamsFetchMeetingInfoResponse. + */ fetchMeetingInfo( meetingId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, From 2a1bc82d91254dccb9a32e035dc3a3f573144576 Mon Sep 17 00:00:00 2001 From: Emiliano Quiroga Date: Tue, 10 May 2022 10:56:06 -0300 Subject: [PATCH 5/7] Suggested changes applied. --- libraries/botbuilder-ai-orchestrator/package.json | 14 +++++--------- .../src/auth/botFrameworkClientImpl.ts | 7 +++---- .../src/auth/connectorFactoryImpl.ts | 7 +++---- .../parameterizedBotFrameworkAuthentication.ts | 9 ++++----- .../passwordServiceClientCredentialFactory.ts | 2 +- .../src/auth/userTokenClientImpl.ts | 15 +++++++-------- 6 files changed, 23 insertions(+), 31 deletions(-) diff --git a/libraries/botbuilder-ai-orchestrator/package.json b/libraries/botbuilder-ai-orchestrator/package.json index e39387f104..b21aa98d2b 100644 --- a/libraries/botbuilder-ai-orchestrator/package.json +++ b/libraries/botbuilder-ai-orchestrator/package.json @@ -29,18 +29,14 @@ } }, "dependencies": { - "botbuilder-dialogs-adaptive": "4.1.6", - "@microsoft/orchestrator-core": "~4.14.3", - "uuid": "^8.3.2", "adaptive-expressions": "4.1.6", "botbuilder-core": "4.1.6", - "botbuilder-dialogs-declarative": "4.1.6", + "botbuilder-dialogs": "4.1.6", + "botbuilder-dialogs-adaptive": "4.1.6", "botbuilder-dialogs-adaptive-runtime-core": "4.1.6", - "botbuilder-dialogs": "4.1.6" - }, - "peerDependencies": { - }, - "devDependencies": { + "botbuilder-dialogs-declarative": "4.1.6", + "@microsoft/orchestrator-core": "~4.14.3", + "uuid": "^8.3.2" }, "scripts": { "build": "tsc -b", diff --git a/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts b/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts index c0ced23513..697baeedf7 100644 --- a/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts +++ b/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts @@ -26,9 +26,8 @@ const botFrameworkClientFetchImpl: typeof fetch = async (input, init) => { } as Response; }; -// Internal -/** - * Implementation of BotFrameworkClient. +/**@internal + * Implementation of [BotFrameworkClient](xref:botframework-connector.BotFrameworkClient). */ export class BotFrameworkClientImpl implements BotFrameworkClient { /** @@ -51,7 +50,7 @@ export class BotFrameworkClientImpl implements BotFrameworkClient { * @param serviceUrl The callback Url for the skill host. * @param conversationId A conversation ID to use for the conversation with the skill. * @param activity The Activity to send to forward. - * @returns Promise with optional invokeResponse. + * @returns {Promise>} A promise representing the asynchronous operation. */ async postActivity( fromBotId: string, diff --git a/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts b/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts index 0c4bb04605..711dc9e206 100644 --- a/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts +++ b/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts @@ -13,9 +13,8 @@ export const USER_AGENT = `Microsoft-BotFramework/3.1 ${packageInfo.name}/${ packageInfo.version } ${getDefaultUserAgentValue()} `; -// Internal -/** - * Implementation of ConnectorFactory. +/**@internal + * Implementation of [ConnectorFactory](xref:botframework-connector.ConnectorFactory). */ export class ConnectorFactoryImpl extends ConnectorFactory { /** @@ -39,7 +38,7 @@ export class ConnectorFactoryImpl extends ConnectorFactory { /** * @param serviceUrl The client's service URL. - * @param audience The audience to use for outbound communication. The will vary by cloud environment. + * @param audience The audience to use for outbound communication. It will vary by cloud environment. * @returns The new instance of the ConnectorClient class. */ async create(serviceUrl: string, audience?: string): Promise { diff --git a/libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts b/libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts index e039d19836..2c99499166 100644 --- a/libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts +++ b/libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts @@ -34,9 +34,8 @@ function getAppId(claimsIdentity: ClaimsIdentity): string | undefined { ); } -// Internal -/** - * Parametrized Cloud Environment used to authenticate Bot Framework Protocol network calls within this environment. +/**@internal + * Parameterized [BotFrameworkAuthentication](xref:botframework-connector.BotFrameworkAuthentication) used to authenticate Bot Framework Protocol network calls within this environment. */ export class ParameterizedBotFrameworkAuthentication extends BotFrameworkAuthentication { /** @@ -47,7 +46,7 @@ export class ParameterizedBotFrameworkAuthentication extends BotFrameworkAuthent * @param oAuthUrl The OAuth url. * @param toBotFromChannelOpenIdMetadataUrl The to bot from Channel Open Id Metadata url. * @param toBotFromEmulatorOpenIdMetadataUrl The to bot from Emulator Open Id Metadata url. - * @param callerId The callerId set on on authenticated [Activities](xref:botframework-schema.Activity). + * @param callerId The callerId set on an authenticated [Activities](xref:botframework-schema.Activity). * @param credentialsFactory The [ServiceClientCredentialsFactory](xref:botframework-connector.ServiceClientCredentialsFactory) to use to create credentials. * @param authConfiguration The [AuthenticationConfiguration](xref:botframework-connector.AuthenticationConfiguration) to use. * @param botFrameworkClientFetch The fetch to use in BotFrameworkClient. @@ -177,7 +176,7 @@ export class ParameterizedBotFrameworkAuthentication extends BotFrameworkAuthent } /** - * Creates a ConnectorFactory that can be used to create IConnectorClient that use credentials from this particular cloud environment. + * Creates a ConnectorFactory that can be used to create ConnectorClients that can use credentials from this particular Cloud Environment. * * @param claimsIdentity The inbound Activity's ClaimsIdentity. * @returns A ConnectorFactory. diff --git a/libraries/botframework-connector/src/auth/passwordServiceClientCredentialFactory.ts b/libraries/botframework-connector/src/auth/passwordServiceClientCredentialFactory.ts index ad768c15b9..f7bcc1af3d 100644 --- a/libraries/botframework-connector/src/auth/passwordServiceClientCredentialFactory.ts +++ b/libraries/botframework-connector/src/auth/passwordServiceClientCredentialFactory.ts @@ -90,7 +90,7 @@ export class PasswordServiceClientCredentialFactory implements ServiceClientCred * @param appId The appId. * @param audience The audience. * @param loginEndpoint The login url. - * @param validateAuthority The validate authority vale to use. + * @param validateAuthority The validate authority value to use. * @returns A Promise representing the result of the operation. */ async createCredentials( diff --git a/libraries/botframework-connector/src/auth/userTokenClientImpl.ts b/libraries/botframework-connector/src/auth/userTokenClientImpl.ts index 337f8e278d..b055460755 100644 --- a/libraries/botframework-connector/src/auth/userTokenClientImpl.ts +++ b/libraries/botframework-connector/src/auth/userTokenClientImpl.ts @@ -8,9 +8,8 @@ import { ConnectorClientOptions } from '../connectorApi/models'; import { TokenApiClient } from '../tokenApi/tokenApiClient'; import { UserTokenClient } from './userTokenClient'; -// Internal -/** - * Implementation of the Client for access user token service. +/**@internal + * Implementation of [UserTokenClient](xref:botframework-connector.UserTokenClient) for access user token service. */ export class UserTokenClientImpl extends UserTokenClient { private readonly client: TokenApiClient; @@ -63,12 +62,12 @@ export class UserTokenClientImpl extends UserTokenClient { } /** - * A Task representing the result of the asynchronous operation. + * Asynchronously Get the raw signin resource to be sent to the user for signin. * - * @param connectionName Name of the auth connection to use + * @param connectionName Name of the auth connection to use. * @param activity The Activity from which to derive the token exchange state. * @param finalRedirect The final URL that the OAuth flow will redirect to. - * @returns A promise representing the result of the operation. + * @returns The [SignInUrlResponse](xref:botframework-schema.SignInUrlResponse) resource. */ async getSignInResource( connectionName: string, @@ -118,7 +117,7 @@ export class UserTokenClientImpl extends UserTokenClient { * @param userId The user id that will be associated with the token. * @param channelId The channel Id that will be associated with the token. * @param includeFilter The includeFilter. - * @returns A promise of Array of TokenStatus. + * @returns A promise with an Array of the Token Status. */ async getTokenStatus(userId: string, channelId: string, includeFilter: string): Promise { z.object({ @@ -176,7 +175,7 @@ export class UserTokenClientImpl extends UserTokenClient { * @param userId The user id that will be associated with the token. * @param connectionName Name of the auth connection to use. * @param channelId The channel Id that will be associated with the token. - * @param exchangeRequest The exchange request details, either a token to exchange or a uri to exchange + * @param exchangeRequest The exchange request details, either a token to exchange or a uri to exchange. * @returns A promise representing the result of the operation. */ async exchangeToken( From 23681028f7a946d05bdd34ec6657498e8c90befb Mon Sep 17 00:00:00 2001 From: Emiliano Quiroga Date: Thu, 12 May 2022 10:19:33 -0300 Subject: [PATCH 6/7] Documentation updated --- .../botframework-connector/src/auth/botFrameworkClientImpl.ts | 3 ++- .../botframework-connector/src/auth/connectorFactoryImpl.ts | 3 ++- .../src/auth/parameterizedBotFrameworkAuthentication.ts | 3 ++- .../botframework-connector/src/auth/userTokenClientImpl.ts | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts b/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts index 697baeedf7..ee01b45aa7 100644 --- a/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts +++ b/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts @@ -26,7 +26,8 @@ const botFrameworkClientFetchImpl: typeof fetch = async (input, init) => { } as Response; }; -/**@internal +/** + * @internal * Implementation of [BotFrameworkClient](xref:botframework-connector.BotFrameworkClient). */ export class BotFrameworkClientImpl implements BotFrameworkClient { diff --git a/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts b/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts index 711dc9e206..bd3ae37ced 100644 --- a/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts +++ b/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts @@ -13,7 +13,8 @@ export const USER_AGENT = `Microsoft-BotFramework/3.1 ${packageInfo.name}/${ packageInfo.version } ${getDefaultUserAgentValue()} `; -/**@internal +/** + * @internal * Implementation of [ConnectorFactory](xref:botframework-connector.ConnectorFactory). */ export class ConnectorFactoryImpl extends ConnectorFactory { diff --git a/libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts b/libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts index 2c99499166..2c41eea4a7 100644 --- a/libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts +++ b/libraries/botframework-connector/src/auth/parameterizedBotFrameworkAuthentication.ts @@ -34,7 +34,8 @@ function getAppId(claimsIdentity: ClaimsIdentity): string | undefined { ); } -/**@internal +/** + * @internal * Parameterized [BotFrameworkAuthentication](xref:botframework-connector.BotFrameworkAuthentication) used to authenticate Bot Framework Protocol network calls within this environment. */ export class ParameterizedBotFrameworkAuthentication extends BotFrameworkAuthentication { diff --git a/libraries/botframework-connector/src/auth/userTokenClientImpl.ts b/libraries/botframework-connector/src/auth/userTokenClientImpl.ts index b055460755..2a8850f5a6 100644 --- a/libraries/botframework-connector/src/auth/userTokenClientImpl.ts +++ b/libraries/botframework-connector/src/auth/userTokenClientImpl.ts @@ -8,7 +8,8 @@ import { ConnectorClientOptions } from '../connectorApi/models'; import { TokenApiClient } from '../tokenApi/tokenApiClient'; import { UserTokenClient } from './userTokenClient'; -/**@internal +/** + * @internal * Implementation of [UserTokenClient](xref:botframework-connector.UserTokenClient) for access user token service. */ export class UserTokenClientImpl extends UserTokenClient { From 02d653d9224307327b77dd85726162065acd9f4f Mon Sep 17 00:00:00 2001 From: Emiliano Quiroga Date: Thu, 12 May 2022 11:25:02 -0300 Subject: [PATCH 7/7] Additional warning fixed. --- .../botframework-connector/src/auth/botFrameworkClientImpl.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts b/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts index ee01b45aa7..26321d4ee4 100644 --- a/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts +++ b/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts @@ -45,6 +45,7 @@ export class BotFrameworkClientImpl implements BotFrameworkClient { } /** + * @template T The type of body in the InvokeResponse. * @param fromBotId The MicrosoftAppId of the bot sending the activity. * @param toBotId The MicrosoftAppId of the bot receiving the activity. * @param toUrl The URL of the bot receiving the activity.