diff --git a/eslint.config.cjs b/eslint.config.cjs index 0fc0670e19..644791d452 100644 --- a/eslint.config.cjs +++ b/eslint.config.cjs @@ -38,6 +38,7 @@ module.exports = [ '**/*.lu', '**/*.dialog', '**/*.js.map', + '**/vendors' ], }, diff --git a/libraries/botbuilder/eslint.config.cjs b/libraries/botbuilder/eslint.config.cjs deleted file mode 100644 index 63647b52cc..0000000000 --- a/libraries/botbuilder/eslint.config.cjs +++ /dev/null @@ -1,10 +0,0 @@ -const onlyWarn = require("eslint-plugin-only-warn"); -const sharedConfig = require("../../eslint.config.cjs") - -module.exports = [ - ...sharedConfig, - { - plugins: { - "only-warn": onlyWarn, - }, - }]; diff --git a/libraries/botbuilder/package.json b/libraries/botbuilder/package.json index 7d3bf49cfa..ac9b75b479 100644 --- a/libraries/botbuilder/package.json +++ b/libraries/botbuilder/package.json @@ -36,7 +36,6 @@ "botframework-schema": "4.1.6", "botframework-streaming": "4.1.6", "dayjs": "^1.11.13", - "eslint-plugin-only-warn": "^1.1.0", "filenamify": "^6.0.0", "fs-extra": "^11.2.0", "htmlparser2": "^9.0.1", @@ -55,7 +54,7 @@ "build:rollup": "yarn clean && yarn build && api-extractor run --verbose --local", "clean": "rimraf _ts3.4 lib vendors tsconfig.tsbuildinfo", "depcheck": "depcheck --config ../../.depcheckrc", - "lint": "eslint .", + "lint": "eslint . --config ../../eslint.config.cjs", "prebuild": "tsup ./node_modules/filenamify/*.js --format cjs --dts --out-dir vendors/filenamify --clean --sourcemap", "postbuild": "downlevel-dts lib _ts3.4/lib --checksum", "test": "npm-run-all build test:mocha", @@ -73,4 +72,4 @@ "src", "vendors" ] -} \ No newline at end of file +} diff --git a/libraries/botbuilder/src/botFrameworkAdapter.ts b/libraries/botbuilder/src/botFrameworkAdapter.ts index 7df7cc2599..d45f309687 100644 --- a/libraries/botbuilder/src/botFrameworkAdapter.ts +++ b/libraries/botbuilder/src/botFrameworkAdapter.ts @@ -157,7 +157,8 @@ const TYPE = type(); const RELEASE = release(); const NODE_VERSION = process.version; -const pjson: Record<'version', string> = require('../package.json'); // eslint-disable-line @typescript-eslint/no-var-requires +// eslint-disable-next-line @typescript-eslint/no-require-imports +const pjson: Record<'version', string> = require('../package.json'); export const USER_AGENT = `Microsoft-BotFramework/3.1 BotBuilder/${pjson.version} (Node.js,Version=${NODE_VERSION}; ${TYPE} ${RELEASE}; ${ARCHITECTURE})`; const OAUTH_ENDPOINT = 'https://api.botframework.com'; @@ -203,7 +204,8 @@ const US_GOV_OAUTH_ENDPOINT = 'https://api.botframework.azure.us'; */ export class BotFrameworkAdapter extends BotAdapter - implements BotFrameworkHttpAdapter, ConnectorClientBuilder, ExtendedUserTokenProvider, RequestHandler { + implements BotFrameworkHttpAdapter, ConnectorClientBuilder, ExtendedUserTokenProvider, RequestHandler +{ // These keys are public to permit access to the keys from the adapter when it's a being // from library that does not have access to static properties off of BotFrameworkAdapter. // E.g. botbuilder-dialogs @@ -228,7 +230,6 @@ export class BotFrameworkAdapter * Creates a new instance of the [BotFrameworkAdapter](xref:botbuilder.BotFrameworkAdapter) class. * * @param settings Optional. The settings to use for this adapter instance. - * * @remarks * If the `settings` parameter does not include * [channelService](xref:botbuilder.BotFrameworkAdapterSettings.channelService) or @@ -251,7 +252,7 @@ export class BotFrameworkAdapter this.settings.appId, settings.certificateThumbprint, settings.certificatePrivateKey, - this.settings.channelAuthTenant + this.settings.channelAuthTenant, ); this.credentialsProvider = new SimpleCredentialProvider(this.credentials.appId, ''); } else { @@ -259,18 +260,18 @@ export class BotFrameworkAdapter this.credentials = new MicrosoftGovernmentAppCredentials( this.settings.appId, this.settings.appPassword || '', - this.settings.channelAuthTenant + this.settings.channelAuthTenant, ); } else { this.credentials = new MicrosoftAppCredentials( this.settings.appId, this.settings.appPassword || '', - this.settings.channelAuthTenant + this.settings.channelAuthTenant, ); } this.credentialsProvider = new SimpleCredentialProvider( this.credentials.appId, - this.settings.appPassword || '' + this.settings.appPassword || '', ); } @@ -298,21 +299,19 @@ export class BotFrameworkAdapter // Relocate the tenantId field used by MS Teams to a new location (from channelData to conversation) // This will only occur on activities from teams that include tenant info in channelData but NOT in conversation, // thus should be future friendly. However, once the the transition is complete. we can remove this. - this.use( - async (context, next): Promise => { - if ( - context.activity.channelId === 'msteams' && - context.activity && - context.activity.conversation && - !context.activity.conversation.tenantId && - context.activity.channelData && - context.activity.channelData.tenant - ) { - context.activity.conversation.tenantId = context.activity.channelData.tenant.id; - } - await next(); + this.use(async (context, next): Promise => { + if ( + context.activity.channelId === 'msteams' && + context.activity && + context.activity.conversation && + !context.activity.conversation.tenantId && + context.activity.channelData && + context.activity.channelData.tenant + ) { + context.activity.conversation.tenantId = context.activity.channelData.tenant.id; } - ); + await next(); + }); } /** @@ -330,7 +329,6 @@ export class BotFrameworkAdapter * @param reference A reference to the conversation to continue. * @param oAuthScope The intended recipient of any sent activities. * @param logic The asynchronous method to call after the adapter middleware runs. - * * @remarks * This is often referred to as a _proactive notification_, the bot can proactively * send a message to a conversation or user without waiting for an incoming message. @@ -372,7 +370,7 @@ export class BotFrameworkAdapter */ async continueConversation( reference: Partial, - logic: (context: TurnContext) => Promise + logic: (context: TurnContext) => Promise, ): Promise; /** @@ -385,7 +383,7 @@ export class BotFrameworkAdapter async continueConversation( reference: Partial, oAuthScope: string, - logic: (context: TurnContext) => Promise + logic: (context: TurnContext) => Promise, ): Promise; /** @@ -394,7 +392,7 @@ export class BotFrameworkAdapter async continueConversation( reference: Partial, oAuthScopeOrlogic: string | ((context: TurnContext) => Promise), - maybeLogic?: (context: TurnContext) => Promise + maybeLogic?: (context: TurnContext) => Promise, ): Promise { let audience: string; if (LogicT.safeParse(oAuthScopeOrlogic).success) { @@ -430,7 +428,7 @@ export class BotFrameworkAdapter const request = TurnContext.applyConversationReference( { type: ActivityTypes.Event, name: ActivityEventNames.ContinueConversation }, reference, - true + true, ); const context = this.createContext(request); @@ -447,7 +445,6 @@ export class BotFrameworkAdapter * @param {Partial} reference A reference for the conversation to create. * @param {(context: TurnContext) => Promise} logic The asynchronous method to call after the adapter middleware runs. * @returns {Promise} a promise representing the asynchronous operation - * * @summary * To use this method, you need both the bot's and the user's account information on a channel. * The Bot Connector service supports the creating of group conversations; however, this @@ -488,7 +485,7 @@ export class BotFrameworkAdapter */ createConversation( reference: Partial, - logic: (context: TurnContext) => Promise + logic: (context: TurnContext) => Promise, ): Promise; /** @@ -502,7 +499,7 @@ export class BotFrameworkAdapter createConversation( reference: Partial, parameters: Partial, - logic: (context: TurnContext) => Promise + logic: (context: TurnContext) => Promise, ): Promise; /** @@ -511,7 +508,7 @@ export class BotFrameworkAdapter async createConversation( reference: Partial, parametersOrLogic: Partial | ((context: TurnContext) => Promise), - maybeLogic?: (context: TurnContext) => Promise + maybeLogic?: (context: TurnContext) => Promise, ): Promise { if (!reference.serviceUrl) { throw new Error('BotFrameworkAdapter.createConversation(): missing serviceUrl.'); @@ -534,7 +531,7 @@ export class BotFrameworkAdapter activity: null, channelData: null, }, - parameters + parameters, ); const client = this.createConnectorClient(reference.serviceUrl); @@ -554,7 +551,7 @@ export class BotFrameworkAdapter const request = TurnContext.applyConversationReference( { type: ActivityTypes.Event, name: ActivityEventNames.CreateConversation }, reference, - true + true, ); request.conversation = { @@ -585,7 +582,6 @@ export class BotFrameworkAdapter * * @param context The context object for the turn. * @param reference Conversation reference information for the activity to delete. - * * @remarks * Not all channels support this operation. For channels that don't, this call may throw an exception. */ @@ -602,7 +598,7 @@ export class BotFrameworkAdapter const client: ConnectorClient = this.getOrCreateConnectorClient( context, reference.serviceUrl, - this.credentials + this.credentials, ); await client.conversations.deleteActivity(reference.conversation.id, reference.activityId); } @@ -612,7 +608,6 @@ export class BotFrameworkAdapter * * @param context The context object for the turn. * @param memberId The ID of the member to remove from the conversation. - * * @remarks * Remove a member's identity information from the conversation. * @@ -636,10 +631,8 @@ export class BotFrameworkAdapter * * @param context The context object for the turn. * @param activityId Optional. The ID of the activity to get the members of. If not specified, the current activity ID is used. - * * @returns An array of [ChannelAccount](xref:botframework-schema.ChannelAccount) objects for * the users involved in a given activity. - * * @remarks * Returns an array of [ChannelAccount](xref:botframework-schema.ChannelAccount) objects for * the users involved in a given activity. @@ -659,7 +652,7 @@ export class BotFrameworkAdapter } if (!activityId) { throw new Error( - 'BotFrameworkAdapter.getActivityMembers(): missing both activityId and context.activity.id' + 'BotFrameworkAdapter.getActivityMembers(): missing both activityId and context.activity.id', ); } const serviceUrl: string = context.activity.serviceUrl; @@ -673,10 +666,8 @@ export class BotFrameworkAdapter * Asynchronously lists the members of the current conversation. * * @param context The context object for the turn. - * * @returns An array of [ChannelAccount](xref:botframework-schema.ChannelAccount) objects for * all users currently involved in a conversation. - * * @remarks * Returns an array of [ChannelAccount](xref:botframework-schema.ChannelAccount) objects for * all users currently involved in a conversation. @@ -705,10 +696,8 @@ export class BotFrameworkAdapter * [TurnContext](xref:botbuilder-core.TurnContext) object from a conversation on the channel. * @param continuationToken Optional. The continuation token from the previous page of results. * Omit this parameter or use `undefined` to retrieve the first page of results. - * * @returns A [ConversationsResult](xref:botframework-schema.ConversationsResult) object containing a page of results * and a continuation token. - * * @remarks * The the return value's [conversations](xref:botframework-schema.ConversationsResult.conversations) property contains a page of * [ConversationMembers](xref:botframework-schema.ConversationMembers) objects. Each object's @@ -724,7 +713,7 @@ export class BotFrameworkAdapter */ async getConversations( contextOrServiceUrl: TurnContext | string, - continuationToken?: string + continuationToken?: string, ): Promise { let client: ConnectorClient; if (typeof contextOrServiceUrl === 'object') { @@ -735,7 +724,7 @@ export class BotFrameworkAdapter } return await client.conversations.getConversations( - continuationToken ? { continuationToken: continuationToken } : undefined + continuationToken ? { continuationToken: continuationToken } : undefined, ); } @@ -746,7 +735,6 @@ export class BotFrameworkAdapter * @param connectionName The name of the auth connection to use. * @param magicCode Optional. The validation code the user entered. * @param oAuthAppCredentials AppCredentials for OAuth. - * * @returns A [TokenResponse](xref:botframework-schema.TokenResponse) object that contains the user token. */ async getUserToken(context: TurnContext, connectionName: string, magicCode?: string): Promise; @@ -754,7 +742,7 @@ export class BotFrameworkAdapter context: TurnContext, connectionName: string, magicCode?: string, - oAuthAppCredentials?: CoreAppCredentials + oAuthAppCredentials?: CoreAppCredentials, ): Promise; /** * Asynchronously attempts to retrieve the token for a user that's in a login flow. @@ -763,14 +751,13 @@ export class BotFrameworkAdapter * @param connectionName The name of the auth connection to use. * @param magicCode Optional. The validation code the user entered. * @param oAuthAppCredentials Optional. [AppCredentials](xref:botframework-connector.AppCredentials) for OAuth. - * * @returns A [TokenResponse](xref:botframework-schema.TokenResponse) object that contains the user token. */ async getUserToken( context: TurnContext, connectionName: string, magicCode?: string, - oAuthAppCredentials?: AppCredentials + oAuthAppCredentials?: AppCredentials, ): Promise { if (!context.activity.from || !context.activity.from.id) { throw new Error('BotFrameworkAdapter.getUserToken(): missing from or from.id'); @@ -787,7 +774,7 @@ export class BotFrameworkAdapter const result: TokenApiModels.UserTokenGetTokenResponse = await client.userToken.getToken( userId, connectionName, - { code: magicCode, channelId: context.activity.channelId } + { code: magicCode, channelId: context.activity.channelId }, ); if (!result || !result.token || result._response.status == 404) { return undefined; @@ -809,7 +796,7 @@ export class BotFrameworkAdapter context: TurnContext, connectionName?: string, userId?: string, - oAuthAppCredentials?: CoreAppCredentials + oAuthAppCredentials?: CoreAppCredentials, ): Promise; /** * Asynchronously signs out the user from the token server. @@ -823,7 +810,7 @@ export class BotFrameworkAdapter context: TurnContext, connectionName?: string, userId?: string, - oAuthAppCredentials?: AppCredentials + oAuthAppCredentials?: AppCredentials, ): Promise { if (!context.activity.from || !context.activity.from.id) { throw new Error('BotFrameworkAdapter.signOutUser(): missing from or from.id'); @@ -858,14 +845,14 @@ export class BotFrameworkAdapter connectionName: string, oAuthAppCredentials?: AppCredentials, userId?: string, - finalRedirect?: string + finalRedirect?: string, ): Promise; async getSignInLink( context: TurnContext, connectionName: string, oAuthAppCredentials?: CoreAppCredentials, userId?: string, - finalRedirect?: string + finalRedirect?: string, ): Promise; /** * Asynchronously gets a sign-in link from the token server that can be sent as part @@ -883,11 +870,11 @@ export class BotFrameworkAdapter connectionName: string, oAuthAppCredentials?: AppCredentials, userId?: string, - finalRedirect?: string + finalRedirect?: string, ): Promise { if (userId && userId != context.activity.from.id) { throw new ReferenceError( - "cannot retrieve OAuth signin link for a user that's different from the conversation" + "cannot retrieve OAuth signin link for a user that's different from the conversation", ); } @@ -918,7 +905,6 @@ export class BotFrameworkAdapter * @param includeFilter Optional. A comma-separated list of connection's to include. If present, * the `includeFilter` parameter limits the tokens this method returns. * @param oAuthAppCredentials AppCredentials for OAuth. - * * @returns The [TokenStatus](xref:botframework-connector.TokenStatus) objects retrieved. */ async getTokenStatus(context: TurnContext, userId?: string, includeFilter?: string): Promise; @@ -926,7 +912,7 @@ export class BotFrameworkAdapter context: TurnContext, userId?: string, includeFilter?: string, - oAuthAppCredentials?: CoreAppCredentials + oAuthAppCredentials?: CoreAppCredentials, ): Promise; /** * Asynchronously retrieves the token status for each configured connection for the given user. @@ -937,14 +923,13 @@ export class BotFrameworkAdapter * @param includeFilter Optional. A comma-separated list of connection's to include. If present, * the `includeFilter` parameter limits the tokens this method returns. * @param oAuthAppCredentials Optional. [AppCredentials](xref:botframework-connector.AppCredentials) for OAuth. - * * @returns The [TokenStatus](xref:botframework-connector.TokenStatus) objects retrieved. */ async getTokenStatus( context: TurnContext, userId?: string, includeFilter?: string, - oAuthAppCredentials?: AppCredentials + oAuthAppCredentials?: AppCredentials, ): Promise { if (!userId && (!context.activity.from || !context.activity.from.id)) { throw new Error('BotFrameworkAdapter.getTokenStatus(): missing from or from.id'); @@ -970,19 +955,18 @@ export class BotFrameworkAdapter * @param connectionName The name of the auth connection to use. * @param resourceUrls The list of resource URLs to retrieve tokens for. * @param oAuthAppCredentials AppCredentials for OAuth. - * * @returns A map of the [TokenResponse](xref:botframework-schema.TokenResponse) objects by resource URL. */ async getAadTokens( context: TurnContext, connectionName: string, - resourceUrls: string[] + resourceUrls: string[], ): Promise<{ [propertyName: string]: TokenResponse }>; async getAadTokens( context: TurnContext, connectionName: string, resourceUrls: string[], - oAuthAppCredentials?: CoreAppCredentials + oAuthAppCredentials?: CoreAppCredentials, ): Promise<{ [propertyName: string]: TokenResponse }>; /** * Asynchronously signs out the user from the token server. @@ -991,14 +975,13 @@ export class BotFrameworkAdapter * @param connectionName The name of the auth connection to use. * @param resourceUrls The list of resource URLs to retrieve tokens for. * @param oAuthAppCredentials Optional. [AppCredentials](xref:botframework-connector.AppCredentials) for OAuth. - * * @returns A map of the [TokenResponse](xref:botframework-schema.TokenResponse) objects by resource URL. */ async getAadTokens( context: TurnContext, connectionName: string, resourceUrls: string[], - oAuthAppCredentials?: AppCredentials + oAuthAppCredentials?: AppCredentials, ): Promise<{ [propertyName: string]: TokenResponse }> { if (!context.activity.from || !context.activity.from.id) { throw new Error('BotFrameworkAdapter.getAadTokens(): missing from or from.id'); @@ -1014,7 +997,7 @@ export class BotFrameworkAdapter userId, connectionName, { resourceUrls: resourceUrls }, - { channelId: context.activity.channelId } + { channelId: context.activity.channelId }, ) )._response.parsedBody as { [propertyName: string]: TokenResponse }; } @@ -1034,7 +1017,7 @@ export class BotFrameworkAdapter connectionName: string, userId?: string, finalRedirect?: string, - appCredentials?: CoreAppCredentials + appCredentials?: CoreAppCredentials, ): Promise { if (!connectionName) { throw new Error('getUserToken() requires a connectionName but none was provided.'); @@ -1047,7 +1030,7 @@ export class BotFrameworkAdapter // The provided userId doesn't match the from.id on the activity. (same for finalRedirect) if (userId && context.activity.from.id !== userId) { throw new Error( - 'BotFrameworkAdapter.getSiginInResource(): cannot get signin resource for a user that is different from the conversation' + 'BotFrameworkAdapter.getSiginInResource(): cannot get signin resource for a user that is different from the conversation', ); } @@ -1082,7 +1065,7 @@ export class BotFrameworkAdapter connectionName: string, userId: string, tokenExchangeRequest: TokenExchangeRequest, - appCredentials?: CoreAppCredentials + appCredentials?: CoreAppCredentials, ): Promise; /** * Asynchronously Performs a token exchange operation such as for single sign-on. @@ -1099,7 +1082,7 @@ export class BotFrameworkAdapter connectionName: string, userId: string, tokenExchangeRequest: TokenExchangeRequest, - appCredentials?: AppCredentials + appCredentials?: AppCredentials, ): Promise { if (!connectionName) { throw new Error('exchangeToken() requires a connectionName but none was provided.'); @@ -1111,7 +1094,7 @@ export class BotFrameworkAdapter if (tokenExchangeRequest && !tokenExchangeRequest.token && !tokenExchangeRequest.uri) { throw new Error( - 'BotFrameworkAdapter.exchangeToken(): Either a Token or Uri property is required on the TokenExchangeRequest' + 'BotFrameworkAdapter.exchangeToken(): Either a Token or Uri property is required on the TokenExchangeRequest', ); } @@ -1123,7 +1106,7 @@ export class BotFrameworkAdapter userId, connectionName, context.activity.channelId, - tokenExchangeRequest + tokenExchangeRequest, ) )._response.parsedBody as TokenResponse; } @@ -1135,7 +1118,6 @@ export class BotFrameworkAdapter * * @param contextOrServiceUrl The URL of the emulator. * @param emulate `true` to send an emulated OAuth card to the emulator; or `false` to not send the card. - * * @remarks * When testing a bot in the Bot Framework Emulator, this method can emulate the OAuth card interaction. */ @@ -1151,7 +1133,6 @@ export class BotFrameworkAdapter * @param req An Express or Restify style request object. * @param res An Express or Restify style response object. * @param logic The function to call at the end of the middleware pipeline. - * * @remarks * This is the main way a bot receives incoming messages and defines a turn in the conversation. This method: * @@ -1198,7 +1179,7 @@ export class BotFrameworkAdapter async processActivity( req: WebRequest, res: WebResponse, - logic: (context: TurnContext) => Promise + logic: (context: TurnContext) => Promise, ): Promise { let body: any; let status: number; @@ -1292,7 +1273,6 @@ export class BotFrameworkAdapter * * @param activity The activity to process. * @param logic The function to call at the end of the middleware pipeline. - * * @remarks * This is the main way a bot receives incoming messages and defines a turn in the conversation. This method: * @@ -1342,9 +1322,7 @@ export class BotFrameworkAdapter * * @param context The context object for the turn. * @param activities The activities to send. - * * @returns An array of [ResourceResponse](xref:) - * * @remarks * The activities will be sent one after another in the order in which they're received. A * response object will be returned for each sent activity. For `message` activities this will @@ -1374,7 +1352,7 @@ export class BotFrameworkAdapter if (activity && BotFrameworkAdapter.isStreamingServiceUrl(activity.serviceUrl)) { if (!this.isStreamingConnectionOpen) { throw new Error( - 'BotFrameworkAdapter.sendActivities(): Unable to send activity as Streaming connection is closed.' + 'BotFrameworkAdapter.sendActivities(): Unable to send activity as Streaming connection is closed.', ); } TokenResolver.checkForOAuthCards(this, context, activity as Activity); @@ -1388,12 +1366,12 @@ export class BotFrameworkAdapter await client.conversations.replyToActivity( activity.conversation.id, activity.replyToId, - activity - ) + activity, + ), ); } else { responses.push( - await client.conversations.sendToConversation(activity.conversation.id, activity) + await client.conversations.sendToConversation(activity.conversation.id, activity), ); } break; @@ -1466,7 +1444,7 @@ export class BotFrameworkAdapter async createConnectorClientWithIdentity( serviceUrl: string, identity: ClaimsIdentity, - audience: string + audience: string, ): Promise; /** * Create a [ConnectorClient](xref:botbuilder-connector.ConnectorClient) with a [ClaimsIdentity](xref:botbuilder-connector.ClaimsIdentity). @@ -1482,7 +1460,7 @@ export class BotFrameworkAdapter async createConnectorClientWithIdentity( serviceUrl: string, identity: ClaimsIdentity, - audience?: string + audience?: string, ): Promise { if (!identity) { throw new Error('BotFrameworkAdapter.createConnectorClientWithIdentity(): invalid identity parameter.'); @@ -1506,7 +1484,7 @@ export class BotFrameworkAdapter // for a non-existent streaming connection results in an error if (!this.streamingServer) { throw new Error( - `Cannot create streaming connector client for serviceUrl ${serviceUrl} without a streaming connection. Call 'useWebSocket' or 'useNamedPipe' to start a streaming connection.` + `Cannot create streaming connector client for serviceUrl ${serviceUrl} without a streaming connection. Call 'useWebSocket' or 'useNamedPipe' to start a streaming connection.`, ); } @@ -1576,7 +1554,7 @@ export class BotFrameworkAdapter private getOrCreateConnectorClient( context: TurnContext, serviceUrl: string, - credentials: AppCredentials + credentials: AppCredentials, ): ConnectorClient { if (!context || !context.turnState) throw new Error('invalid context parameter'); if (!serviceUrl) throw new Error('invalid serviceUrl'); @@ -1596,7 +1574,6 @@ export class BotFrameworkAdapter * * @param botAppId The bot's AppId. * @param claims The [Claim](xref:botbuilder-connector.Claim) list to check. - * * @returns The current credentials' OAuthScope. */ private async getOAuthScope(botAppId: string, claims: Claim[]): Promise { @@ -1629,7 +1606,7 @@ export class BotFrameworkAdapter appId, this.settings.certificateThumbprint, this.settings.certificatePrivateKey, - this.settings.channelAuthTenant + this.settings.channelAuthTenant, ); } else { if (JwtTokenValidation.isGovernment(this.settings.channelService)) { @@ -1637,14 +1614,14 @@ export class BotFrameworkAdapter appId, appPassword, this.settings.channelAuthTenant, - oAuthScope + oAuthScope, ); } else { credentials = new MicrosoftAppCredentials( appId, appPassword, this.settings.channelAuthTenant, - oAuthScope + oAuthScope, ); } } @@ -1657,7 +1634,6 @@ export class BotFrameworkAdapter * * @param serviceUrl The client's service URL. * @param oAuthAppCredentials AppCredentials for OAuth. - * * @remarks * Override this in a derived class to create a mock OAuth API client for unit testing. */ @@ -1667,7 +1643,6 @@ export class BotFrameworkAdapter * * @param serviceUrl The client's service URL. * @param oAuthAppCredentials Optional. The [AppCredentials](xref:botframework-connector.AppCredentials)for OAuth. - * * @remarks * Override this in a derived class to create a mock OAuth API client for unit testing. * @returns The client. @@ -1711,7 +1686,7 @@ export class BotFrameworkAdapter authHeader, this.credentialsProvider, this.settings.channelService, - this.authConfiguration + this.authConfiguration, ); } @@ -1770,17 +1745,16 @@ export class BotFrameworkAdapter ? contextOrServiceUrl.activity.serviceUrl : contextOrServiceUrl : this.settings.oAuthEndpoint - ? this.settings.oAuthEndpoint - : JwtTokenValidation.isGovernment(this.settings.channelService) - ? US_GOV_OAUTH_ENDPOINT - : OAUTH_ENDPOINT; + ? this.settings.oAuthEndpoint + : JwtTokenValidation.isGovernment(this.settings.channelService) + ? US_GOV_OAUTH_ENDPOINT + : OAUTH_ENDPOINT; } /** * Checks the environment and can set a flag to emulate OAuth cards. * * @param context The context object for the turn. - * * @remarks * Override this in a derived class to control how OAuth cards are emulated for unit testing. */ @@ -1854,7 +1828,7 @@ export class BotFrameworkAdapter response.setBody( `Invalid verb received for ${request.verb.toLocaleLowerCase()}. Only GET and POST are accepted. Verb: ${ request.verb - }` + }`, ); return response; @@ -1915,7 +1889,7 @@ export class BotFrameworkAdapter req: Request, socket: INodeSocket, head: INodeBuffer, - logic: (context: TurnContext) => Promise + logic: (context: TurnContext) => Promise, ): Promise; /** @@ -1925,14 +1899,14 @@ export class BotFrameworkAdapter req: Request, resOrSocket: Response | INodeSocket, logicOrHead: ((context: TurnContext) => Promise) | INodeBuffer, - maybeLogic?: (context: TurnContext) => Promise + maybeLogic?: (context: TurnContext) => Promise, ): Promise { if (maybeLogic) { return this.useWebSocket( req, INodeSocketT.parse(resOrSocket), INodeBufferT.parse(logicOrHead), - LogicT.parse(maybeLogic) + LogicT.parse(maybeLogic), ); } else { return this.processActivity(req, ResponseT.parse(resOrSocket), LogicT.parse(logicOrHead)); @@ -1951,7 +1925,7 @@ export class BotFrameworkAdapter logic: (context: TurnContext) => Promise, pipeName = defaultPipeName, retryCount = 7, - onListen?: () => void + onListen?: () => void, ): Promise { if (!logic) { throw new Error('Bot logic needs to be provided to `useNamedPipe`'); @@ -1967,7 +1941,7 @@ export class BotFrameworkAdapter // Each BotFrameworkAdapter instance is scoped to a stream, so switching streams // results in dropped conversations that the bot cannot reconnect to. throw new Error( - 'This BotFrameworkAdapter instance is already connected to a different stream. Use a new instance to connect to the provided pipeName.' + 'This BotFrameworkAdapter instance is already connected to a different stream. Use a new instance to connect to the provided pipeName.', ); } } @@ -1989,7 +1963,7 @@ export class BotFrameworkAdapter req: WebRequest, socket: INodeSocket, head: INodeBuffer, - logic: (context: TurnContext) => Promise + logic: (context: TurnContext) => Promise, ): Promise { // Use the provided NodeWebSocketFactoryBase on BotFrameworkAdapter construction, // otherwise create a new NodeWebSocketFactory. @@ -2037,7 +2011,7 @@ export class BotFrameworkAdapter authHeader, this.credentialsProvider, channelService, - channelIdHeader + channelIdHeader, ); if (!claims.isAuthenticated) { @@ -2070,7 +2044,7 @@ export class BotFrameworkAdapter : await attachmentStream.readAsString(); return { contentType, content }; - }) + }), ); return activity; @@ -2078,7 +2052,7 @@ export class BotFrameworkAdapter private async handleVersionRequest( request: IReceiveRequest, - response: StreamingResponse + response: StreamingResponse, ): Promise { if (request.verb.toLocaleUpperCase() === GET) { response.statusCode = StatusCodes.OK; @@ -2105,7 +2079,7 @@ export class BotFrameworkAdapter } else { response.statusCode = StatusCodes.METHOD_NOT_ALLOWED; response.setBody( - `Invalid verb received for path: ${request.path}. Only GET is accepted. Verb: ${request.verb}` + `Invalid verb received for path: ${request.path}. Only GET is accepted. Verb: ${request.verb}`, ); } @@ -2115,8 +2089,8 @@ export class BotFrameworkAdapter /** * Determine if the serviceUrl was sent via an Http/Https connection or Streaming * This can be determined by looking at the ServiceUrl property: - * (1) All channels that send messages via http/https are not streaming - * (2) Channels that send messages via streaming have a ServiceUrl that does not begin with http/https. + * (1) All channels that send messages via http/https are not streaming + * (2) Channels that send messages via streaming have a ServiceUrl that does not begin with http/https. * * @param serviceUrl the serviceUrl provided in the resquest. * @returns True if the serviceUrl is a streaming url, otherwise false. @@ -2169,11 +2143,13 @@ function abortWebSocketUpgrade(socket: INodeSocket, err: any): void { const connectionHeader = "Connection: 'close'\r\n"; let message = ''; - AuthenticationError.isStatusCodeError(err) - ? (message = `HTTP/1.1 ${err.statusCode} ${StatusCodes[err.statusCode]}\r\n${ - err.message - }\r\n${connectionHeader}\r\n`) - : (message = AuthenticationError.determineStatusCodeAndBuildMessage(err)); + if (AuthenticationError.isStatusCodeError(err)) { + message = `HTTP/1.1 ${err.statusCode} ${StatusCodes[err.statusCode]}\r\n${ + err.message + }\r\n${connectionHeader}\r\n`; + } else { + message = AuthenticationError.determineStatusCodeAndBuildMessage(err); + } socket.write(message); } diff --git a/libraries/botbuilder/src/botFrameworkHttpAdapter.ts b/libraries/botbuilder/src/botFrameworkHttpAdapter.ts index 5e174b67db..25b949f6fb 100644 --- a/libraries/botbuilder/src/botFrameworkHttpAdapter.ts +++ b/libraries/botbuilder/src/botFrameworkHttpAdapter.ts @@ -24,7 +24,7 @@ export interface BotFrameworkHttpAdapter { req: Request, socket: INodeSocket, head: INodeBuffer, - logic: (context: TurnContext) => Promise + logic: (context: TurnContext) => Promise, ): Promise; /** @@ -35,6 +35,6 @@ export interface BotFrameworkHttpAdapter { req: Request, socket: INodeDuplex, head: INodeBuffer, - logic: (context: TurnContext) => Promise + logic: (context: TurnContext) => Promise, ): Promise; } diff --git a/libraries/botbuilder/src/botFrameworkHttpClient.ts b/libraries/botbuilder/src/botFrameworkHttpClient.ts index 1586cf64f5..dbcf196cb3 100644 --- a/libraries/botbuilder/src/botFrameworkHttpClient.ts +++ b/libraries/botbuilder/src/botFrameworkHttpClient.ts @@ -69,12 +69,12 @@ export class BotFrameworkHttpClient implements BotFrameworkClient { toUrl: string, serviceUrl: string, conversationId: string, - activity: Activity + activity: Activity, ): Promise> { const appCredentials = await this.getAppCredentials(fromBotId, toBotId); if (!appCredentials) { throw new Error( - 'BotFrameworkHttpClient.postActivity(): Unable to get appCredentials to connect to the skill' + 'BotFrameworkHttpClient.postActivity(): Unable to get appCredentials to connect to the skill', ); } @@ -152,7 +152,6 @@ export class BotFrameworkHttpClient implements BotFrameworkClient { * * @param appId The application id. * @param oAuthScope Optional. The OAuth scope. - * * @returns The app credentials to be used to acquire tokens. */ protected async buildCredentials(appId: string, oAuthScope?: string): Promise { diff --git a/libraries/botbuilder/src/channelServiceHandler.ts b/libraries/botbuilder/src/channelServiceHandler.ts index 1cf75ce0ff..d58d6bc9f4 100644 --- a/libraries/botbuilder/src/channelServiceHandler.ts +++ b/libraries/botbuilder/src/channelServiceHandler.ts @@ -30,7 +30,7 @@ export class ChannelServiceHandler extends ChannelServiceHandlerBase { constructor( private readonly credentialProvider: ICredentialProvider, private readonly authConfig: AuthenticationConfiguration, - protected readonly channelService = process.env[AuthenticationConstants.ChannelService] + protected readonly channelService = process.env[AuthenticationConstants.ChannelService], ) { super(); @@ -62,7 +62,7 @@ export class ChannelServiceHandler extends ChannelServiceHandlerBase { this.channelService, 'unknown', undefined, - this.authConfig + this.authConfig, ); } } diff --git a/libraries/botbuilder/src/channelServiceHandlerBase.ts b/libraries/botbuilder/src/channelServiceHandlerBase.ts index 02a91a8537..575897edd9 100644 --- a/libraries/botbuilder/src/channelServiceHandlerBase.ts +++ b/libraries/botbuilder/src/channelServiceHandlerBase.ts @@ -34,7 +34,7 @@ export abstract class ChannelServiceHandlerBase { async handleSendToConversation( authHeader: string, conversationId: string, - activity: Activity + activity: Activity, ): Promise { const claimsIdentity = await this.authenticate(authHeader); return this.onSendToConversation(claimsIdentity, conversationId, activity); @@ -53,7 +53,7 @@ export abstract class ChannelServiceHandlerBase { authHeader: string, conversationId: string, activityId: string, - activity: Activity + activity: Activity, ): Promise { const claimsIdentity = await this.authenticate(authHeader); return this.onReplyToActivity(claimsIdentity, conversationId, activityId, activity); @@ -72,7 +72,7 @@ export abstract class ChannelServiceHandlerBase { authHeader: string, conversationId: string, activityId: string, - activity: Activity + activity: Activity, ): Promise { const claimsIdentity = await this.authenticate(authHeader); return this.onUpdateActivity(claimsIdentity, conversationId, activityId, activity); @@ -101,7 +101,7 @@ export abstract class ChannelServiceHandlerBase { async handleGetActivityMembers( authHeader: string, conversationId: string, - activityId: string + activityId: string, ): Promise { const claimsIdentity = await this.authenticate(authHeader); return this.onGetActivityMembers(claimsIdentity, conversationId, activityId); @@ -116,7 +116,7 @@ export abstract class ChannelServiceHandlerBase { */ async handleCreateConversation( authHeader: string, - parameters: ConversationParameters + parameters: ConversationParameters, ): Promise { const claimsIdentity = await this.authenticate(authHeader); return this.onCreateConversation(claimsIdentity, parameters); @@ -133,7 +133,7 @@ export abstract class ChannelServiceHandlerBase { async handleGetConversations( authHeader: string, conversationId: string, - continuationToken?: string /* some default */ + continuationToken?: string /* some default */, ): Promise { const claimsIdentity = await this.authenticate(authHeader); return this.onGetConversations(claimsIdentity, conversationId, continuationToken); @@ -162,7 +162,7 @@ export abstract class ChannelServiceHandlerBase { async handleGetConversationMember( authHeader: string, userId: string, - conversationId: string + conversationId: string, ): Promise { const claimsIdentity = await this.authenticate(authHeader); return this.onGetConversationMember(claimsIdentity, userId, conversationId); @@ -181,7 +181,7 @@ export abstract class ChannelServiceHandlerBase { authHeader: string, conversationId: string, pageSize = -1, - continuationToken?: string + continuationToken?: string, ): Promise { const claimsIdentity = await this.authenticate(authHeader); return this.onGetConversationPagedMembers(claimsIdentity, conversationId, pageSize, continuationToken); @@ -210,7 +210,7 @@ export abstract class ChannelServiceHandlerBase { async handleSendConversationHistory( authHeader: string, conversationId: string, - transcript: Transcript + transcript: Transcript, ): Promise { const claimsIdentity = await this.authenticate(authHeader); return this.onSendConversationHistory(claimsIdentity, conversationId, transcript); @@ -227,7 +227,7 @@ export abstract class ChannelServiceHandlerBase { async handleUploadAttachment( authHeader: string, conversationId: string, - attachmentUpload: AttachmentData + attachmentUpload: AttachmentData, ): Promise { const claimsIdentity = await this.authenticate(authHeader); return this.onUploadAttachment(claimsIdentity, conversationId, attachmentUpload); @@ -239,9 +239,9 @@ export abstract class ChannelServiceHandlerBase { * @remarks * This method allows you to send an activity to the end of a conversation. * This is slightly different from ReplyToActivity(). - * * SendToConversation(conversationId) - will append the activity to the end + * SendToConversation(conversationId) - will append the activity to the end * of the conversation according to the timestamp or semantics of the channel. - * * ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply + * ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply * to another activity, if the channel supports it. If the channel does not * support nested replies, ReplyToActivity falls back to SendToConversation. * @@ -256,13 +256,13 @@ export abstract class ChannelServiceHandlerBase { protected async onSendToConversation( _claimsIdentity: ClaimsIdentity, _conversationId: string, - _activity: Activity + _activity: Activity, ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, `ChannelServiceHandler.onSendToConversation(): ${StatusCodes.NOT_IMPLEMENTED}: ${ STATUS_CODES[StatusCodes.NOT_IMPLEMENTED] - }` + }`, ); } @@ -273,9 +273,9 @@ export abstract class ChannelServiceHandlerBase { * This method allows you to reply to an activity. * * This is slightly different from SendToConversation(). - * * SendToConversation(conversationId) - will append the activity to the end + * SendToConversation(conversationId) - will append the activity to the end * of the conversation according to the timestamp or semantics of the channel. - * * ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply + * ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply * to another activity, if the channel supports it. If the channel does not * support nested replies, ReplyToActivity falls back to SendToConversation. * @@ -292,13 +292,13 @@ export abstract class ChannelServiceHandlerBase { _claimsIdentity: ClaimsIdentity, _conversationId: string, _activityId: string, - _activity: Activity + _activity: Activity, ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, `ChannelServiceHandler.onReplyToActivity(): ${StatusCodes.NOT_IMPLEMENTED}: ${ STATUS_CODES[StatusCodes.NOT_IMPLEMENTED] - }` + }`, ); } @@ -321,13 +321,13 @@ export abstract class ChannelServiceHandlerBase { _claimsIdentity: ClaimsIdentity, _conversationId: string, _activityId: string, - _activity: Activity + _activity: Activity, ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, `ChannelServiceHandler.onUpdateActivity(): ${StatusCodes.NOT_IMPLEMENTED}: ${ STATUS_CODES[StatusCodes.NOT_IMPLEMENTED] - }` + }`, ); } @@ -339,8 +339,6 @@ export abstract class ChannelServiceHandlerBase { * * Some channels allow you to delete an existing activity, and if successful * this method will remove the specified activity. - * - * * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. * @param _conversationId Conversation ID. * @param _activityId activityId to delete. @@ -348,13 +346,13 @@ export abstract class ChannelServiceHandlerBase { protected async onDeleteActivity( _claimsIdentity: ClaimsIdentity, _conversationId: string, - _activityId: string + _activityId: string, ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, `ChannelServiceHandler.onDeleteActivity(): ${StatusCodes.NOT_IMPLEMENTED}: ${ STATUS_CODES[StatusCodes.NOT_IMPLEMENTED] - }` + }`, ); } @@ -374,13 +372,13 @@ export abstract class ChannelServiceHandlerBase { protected async onGetActivityMembers( _claimsIdentity: ClaimsIdentity, _conversationId: string, - _activityId: string + _activityId: string, ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, `ChannelServiceHandler.onGetActivityMembers(): ${StatusCodes.NOT_IMPLEMENTED}: ${ STATUS_CODES[StatusCodes.NOT_IMPLEMENTED] - }` + }`, ); } @@ -391,28 +389,27 @@ export abstract class ChannelServiceHandlerBase { * Create a new Conversation. * * POST to this method with a - * * Bot being the bot creating the conversation - * * IsGroup set to true if this is not a direct message (default is false) - * * Array containing the members to include in the conversation + * Bot being the bot creating the conversation + * IsGroup set to true if this is not a direct message (default is false) + * Array containing the members to include in the conversation * * The return value is a ResourceResponse which contains a conversation id * which is suitable for use in the message payload and REST API uris. * * Most channels only support the semantics of bots initiating a direct * message conversation. - * * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. * @param _parameters Parameters to create the conversation from. */ protected async onCreateConversation( _claimsIdentity: ClaimsIdentity, - _parameters: ConversationParameters + _parameters: ConversationParameters, ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, `ChannelServiceHandler.onCreateConversation(): ${StatusCodes.NOT_IMPLEMENTED}: ${ STATUS_CODES[StatusCodes.NOT_IMPLEMENTED] - }` + }`, ); } @@ -431,7 +428,6 @@ export abstract class ChannelServiceHandlerBase { * * Each ConversationMembers object contains the ID of the conversation and an * array of ChannelAccounts that describe the members of the conversation. - * * @param _claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. * @param _conversationId Conversation ID. * @param _continuationToken Skip or continuation token. @@ -439,13 +435,13 @@ export abstract class ChannelServiceHandlerBase { protected async onGetConversations( _claimsIdentity: ClaimsIdentity, _conversationId: string, - _continuationToken?: string + _continuationToken?: string, ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, `ChannelServiceHandler.onGetConversations(): ${StatusCodes.NOT_IMPLEMENTED}: ${ STATUS_CODES[StatusCodes.NOT_IMPLEMENTED] - }` + }`, ); } @@ -462,13 +458,13 @@ export abstract class ChannelServiceHandlerBase { */ protected async onGetConversationMembers( _claimsIdentity: ClaimsIdentity, - _conversationId: string + _conversationId: string, ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, `ChannelServiceHandler.onGetConversationMembers(): ${StatusCodes.NOT_IMPLEMENTED}: ${ STATUS_CODES[StatusCodes.NOT_IMPLEMENTED] - }` + }`, ); } @@ -487,13 +483,13 @@ export abstract class ChannelServiceHandlerBase { protected async onGetConversationMember( _claimsIdentity: ClaimsIdentity, _userId: string, - _conversationId: string + _conversationId: string, ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, `ChannelServiceHandler.onGetConversationMember(): ${StatusCodes.NOT_IMPLEMENTED}: ${ STATUS_CODES[StatusCodes.NOT_IMPLEMENTED] - }` + }`, ); } @@ -527,13 +523,13 @@ export abstract class ChannelServiceHandlerBase { _claimsIdentity: ClaimsIdentity, _conversationId: string, _pageSize = -1, - _continuationToken?: string + _continuationToken?: string, ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, `ChannelServiceHandler.onGetConversationPagedMembers(): ${StatusCodes.NOT_IMPLEMENTED}: ${ STATUS_CODES[StatusCodes.NOT_IMPLEMENTED] - }` + }`, ); } @@ -553,13 +549,13 @@ export abstract class ChannelServiceHandlerBase { protected async onDeleteConversationMember( _claimsIdentity: ClaimsIdentity, _conversationId: string, - _memberId: string + _memberId: string, ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, `ChannelServiceHandler.onDeleteConversationMember(): ${StatusCodes.NOT_IMPLEMENTED}: ${ STATUS_CODES[StatusCodes.NOT_IMPLEMENTED] - }` + }`, ); } @@ -581,13 +577,13 @@ export abstract class ChannelServiceHandlerBase { protected async onSendConversationHistory( _claimsIdentity: ClaimsIdentity, _conversationId: string, - _transcript: Transcript + _transcript: Transcript, ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, `ChannelServiceHandler.onSendConversationHistory(): ${StatusCodes.NOT_IMPLEMENTED}: ${ STATUS_CODES[StatusCodes.NOT_IMPLEMENTED] - }` + }`, ); } @@ -609,13 +605,13 @@ export abstract class ChannelServiceHandlerBase { protected async onUploadAttachment( _claimsIdentity: ClaimsIdentity, _conversationId: string, - _attachmentUpload: AttachmentData + _attachmentUpload: AttachmentData, ): Promise { throw new StatusCodeError( StatusCodes.NOT_IMPLEMENTED, `ChannelServiceHandler.onUploadAttachment(): ${StatusCodes.NOT_IMPLEMENTED}: ${ STATUS_CODES[StatusCodes.NOT_IMPLEMENTED] - }` + }`, ); } diff --git a/libraries/botbuilder/src/channelServiceRoutes.ts b/libraries/botbuilder/src/channelServiceRoutes.ts index b2c597a543..63793d1f49 100644 --- a/libraries/botbuilder/src/channelServiceRoutes.ts +++ b/libraries/botbuilder/src/channelServiceRoutes.ts @@ -58,7 +58,7 @@ export class ChannelServiceRoutes { server.get(basePath + RouteConstants.ConversationMember, this.processGetConversationMember.bind(this)); server.get( basePath + RouteConstants.ConversationPagedMembers, - this.processGetConversationPagedMembers.bind(this) + this.processGetConversationPagedMembers.bind(this), ); server.post(basePath + RouteConstants.ConversationHistory, this.processSendConversationHistory.bind(this)); server.post(basePath + RouteConstants.Attachments, this.processUploadAttachment.bind(this)); @@ -68,7 +68,7 @@ export class ChannelServiceRoutes { if (typeof server.delete === 'function') { server.delete( basePath + RouteConstants.ConversationMember, - this.processDeleteConversationMember.bind(this) + this.processDeleteConversationMember.bind(this), ); server.delete(basePath + RouteConstants.Activity, this.processDeleteActivity.bind(this)); } else if (typeof server.del === 'function') { @@ -80,7 +80,7 @@ export class ChannelServiceRoutes { /** * @private */ - private processSendToConversation(req: WebRequest, res: WebResponse, next: Function): void { + private processSendToConversation(req: WebRequest, res: WebResponse, next: () => void): void { const authHeader = req.headers.authorization || req.headers.Authorization || ''; ChannelServiceRoutes.readActivity(req) .then((activity) => { @@ -106,7 +106,7 @@ export class ChannelServiceRoutes { /** * @private */ - private processReplyToActivity(req: WebRequest, res: WebResponse, next: Function): void { + private processReplyToActivity(req: WebRequest, res: WebResponse, next: () => void): void { const authHeader = req.headers.authorization || req.headers.Authorization || ''; ChannelServiceRoutes.readActivity(req) .then((activity) => { @@ -132,7 +132,7 @@ export class ChannelServiceRoutes { /** * @private */ - private processUpdateActivity(req: WebRequest, res: WebResponse, next: Function): void { + private processUpdateActivity(req: WebRequest, res: WebResponse, next: () => void): void { const authHeader = req.headers.authorization || req.headers.Authorization || ''; ChannelServiceRoutes.readActivity(req) .then((activity) => { @@ -158,7 +158,7 @@ export class ChannelServiceRoutes { /** * @private */ - private processDeleteActivity(req: WebRequest, res: WebResponse, next: Function): void { + private processDeleteActivity(req: WebRequest, res: WebResponse, next: () => void): void { const authHeader = req.headers.authorization || req.headers.Authorization || ''; this.channelServiceHandler .handleDeleteActivity(authHeader, req.params.conversationId, req.params.activityId) @@ -175,7 +175,7 @@ export class ChannelServiceRoutes { /** * @private */ - private processGetActivityMembers(req: WebRequest, res: WebResponse, next: Function): void { + private processGetActivityMembers(req: WebRequest, res: WebResponse, next: () => void): void { const authHeader = req.headers.authorization || req.headers.Authorization || ''; this.channelServiceHandler .handleGetActivityMembers(authHeader, req.params.conversationId, req.params.activityId) @@ -195,7 +195,7 @@ export class ChannelServiceRoutes { /** * @private */ - private processCreateConversation(req: WebRequest, res: WebResponse, next: Function): void { + private processCreateConversation(req: WebRequest, res: WebResponse, next: () => void): void { const authHeader = req.headers.authorization || req.headers.Authorization || ''; ChannelServiceRoutes.readBody(req).then((conversationParameters) => { this.channelServiceHandler @@ -217,7 +217,7 @@ export class ChannelServiceRoutes { /** * @private */ - private processGetConversations(req: WebRequest, res: WebResponse, next: Function): void { + private processGetConversations(req: WebRequest, res: WebResponse, next: () => void): void { const authHeader = req.headers.authorization || req.headers.Authorization || ''; this.channelServiceHandler .handleGetConversations(authHeader, req.params.conversationId, req.query.continuationToken) @@ -237,7 +237,7 @@ export class ChannelServiceRoutes { /** * @private */ - private processGetConversationMembers(req: WebRequest, res: WebResponse, next: Function): void { + private processGetConversationMembers(req: WebRequest, res: WebResponse, next: () => void): void { const authHeader = req.headers.authorization || req.headers.Authorization || ''; this.channelServiceHandler .handleGetConversationMembers(authHeader, req.params.conversationId) @@ -257,7 +257,7 @@ export class ChannelServiceRoutes { /** * @private */ - private processGetConversationMember(req: WebRequest, res: WebResponse, next: Function): void { + private processGetConversationMember(req: WebRequest, res: WebResponse, next: () => void): void { const authHeader = req.headers.authorization || req.headers.Authorization || ''; this.channelServiceHandler .handleGetConversationMember(authHeader, req.params.memberId, req.params.conversationId) @@ -277,7 +277,7 @@ export class ChannelServiceRoutes { /** * @private */ - private processGetConversationPagedMembers(req: WebRequest, res: WebResponse, next: Function): void { + private processGetConversationPagedMembers(req: WebRequest, res: WebResponse, next: () => void): void { const authHeader = req.headers.authorization || req.headers.Authorization || ''; let pageSize = parseInt(req.query.pageSize); if (isNaN(pageSize)) { @@ -288,7 +288,7 @@ export class ChannelServiceRoutes { authHeader, req.params.conversationId, pageSize, - req.query.continuationToken + req.query.continuationToken, ) .then((pagedMembersResult) => { res.status(200); @@ -306,7 +306,7 @@ export class ChannelServiceRoutes { /** * @private */ - private processDeleteConversationMember(req: WebRequest, res: WebResponse, next: Function): void { + private processDeleteConversationMember(req: WebRequest, res: WebResponse, next: () => void): void { const authHeader = req.headers.authorization || req.headers.Authorization || ''; this.channelServiceHandler .handleDeleteConversationMember(authHeader, req.params.conversationId, req.params.memberId) @@ -323,7 +323,7 @@ export class ChannelServiceRoutes { /** * @private */ - private processSendConversationHistory(req: WebRequest, res: WebResponse, next: Function): void { + private processSendConversationHistory(req: WebRequest, res: WebResponse, next: () => void): void { const authHeader = req.headers.authorization || req.headers.Authorization || ''; ChannelServiceRoutes.readBody(req) .then((transcript) => { @@ -349,7 +349,7 @@ export class ChannelServiceRoutes { /** * @private */ - private processUploadAttachment(req: WebRequest, res: WebResponse, next: Function): void { + private processUploadAttachment(req: WebRequest, res: WebResponse, next: () => void): void { const authHeader = req.headers.authorization || req.headers.Authorization || ''; ChannelServiceRoutes.readBody(req) .then((attachmentData) => { diff --git a/libraries/botbuilder/src/cloudAdapter.ts b/libraries/botbuilder/src/cloudAdapter.ts index c914aa8f93..7cbd4230bb 100644 --- a/libraries/botbuilder/src/cloudAdapter.ts +++ b/libraries/botbuilder/src/cloudAdapter.ts @@ -78,7 +78,7 @@ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAd req: Request, socket: INodeSocket, head: INodeBuffer, - logic: (context: TurnContext) => Promise + logic: (context: TurnContext) => Promise, ): Promise; /** @@ -95,7 +95,7 @@ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAd req: Request, socket: INodeDuplex, head: INodeBuffer, - logic: (context: TurnContext) => Promise + logic: (context: TurnContext) => Promise, ): Promise; /** @@ -105,7 +105,7 @@ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAd req: Request, resOrSocket: Response | INodeSocket | INodeDuplex, logicOrHead: ((context: TurnContext) => Promise) | INodeBuffer, - maybeLogic?: (context: TurnContext) => Promise + maybeLogic?: (context: TurnContext) => Promise, ): Promise { // Early return with web socket handler if function invocation matches that signature if (maybeLogic) { @@ -139,7 +139,7 @@ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAd if (!z.record(z.unknown()).safeParse(req.body).success) { return end( StatusCodes.BAD_REQUEST, - '`req.body` not an object, make sure you are using middleware to parse incoming requests.' + '`req.body` not an object, make sure you are using middleware to parse incoming requests.', ); } @@ -158,7 +158,7 @@ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAd console.error(err); return end( err instanceof AuthenticationError ? StatusCodes.UNAUTHORIZED : StatusCodes.INTERNAL_SERVER_ERROR, - err.message ?? err + err.message ?? err, ); } } @@ -174,12 +174,10 @@ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAd async processActivityDirect( authorization: string | AuthenticateRequestResult, activity: Activity, - logic: (context: TurnContext) => Promise + logic: (context: TurnContext) => Promise, ): Promise { try { - typeof authorization === 'string' - ? await this.processActivity(authorization, activity, logic) - : await this.processActivity(authorization, activity, logic); + await this.processActivity(authorization as any, activity, logic); } catch (err) { throw new Error(`CloudAdapter.processActivityDirect(): ERROR\n ${err.stack}`); } @@ -201,7 +199,7 @@ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAd appId: string, audience: string, callerId?: string, - retryCount = 7 + retryCount = 7, ): Promise { z.object({ pipeName: z.string(), @@ -221,7 +219,7 @@ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAd // Creat request handler const requestHandler = new StreamingRequestHandler( authenticateRequestResult, - (authenticateRequestResult, activity) => this.processActivity(authenticateRequestResult, activity, logic) + (authenticateRequestResult, activity) => this.processActivity(authenticateRequestResult, activity, logic), ); // Create server @@ -238,7 +236,7 @@ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAd req: Request, socket: INodeSocket, head: INodeBuffer, - logic: (context: TurnContext) => Promise + logic: (context: TurnContext) => Promise, ): Promise { // Grab the auth header from the inbound http request const authHeader = z.string().parse(req.headers.Authorization ?? req.headers.authorization ?? ''); @@ -249,19 +247,19 @@ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAd // Authenticate inbound request const authenticateRequestResult = await this.botFrameworkAuthentication.authenticateStreamingRequest( authHeader, - channelIdHeader + channelIdHeader, ); // Creat request handler const requestHandler = new StreamingRequestHandler( authenticateRequestResult, - (authenticateRequestResult, activity) => this.processActivity(authenticateRequestResult, activity, logic) + (authenticateRequestResult, activity) => this.processActivity(authenticateRequestResult, activity, logic), ); // Create server const server = new WebSocketServer( await new NodeWebSocketFactory().createWebSocket(req, socket, head), - requestHandler + requestHandler, ); // Attach server to request handler @@ -284,8 +282,8 @@ class StreamingRequestHandler extends RequestHandler { private readonly authenticateRequestResult: AuthenticateRequestResult, private readonly processActivity: ( authenticateRequestResult: AuthenticateRequestResult, - activity: Activity - ) => Promise + activity: Activity, + ) => Promise, ) { super(); @@ -311,14 +309,14 @@ class StreamingRequestHandler extends RequestHandler { if (!request.verb || !request.path) { return end( StatusCodes.BAD_REQUEST, - `Request missing verb and/or path. Verb: ${request.verb}, Path: ${request.path}` + `Request missing verb and/or path. Verb: ${request.verb}, Path: ${request.path}`, ); } if (request.verb.toUpperCase() !== POST && request.verb.toUpperCase() !== GET) { return end( StatusCodes.METHOD_NOT_ALLOWED, - `Invalid verb received. Only GET and POST are accepted. Verb: ${request.verb}` + `Invalid verb received. Only GET and POST are accepted. Verb: ${request.verb}`, ); } @@ -328,7 +326,7 @@ class StreamingRequestHandler extends RequestHandler { } else { return end( StatusCodes.METHOD_NOT_ALLOWED, - `Invalid verb received for path: ${request.path}. Only GET is accepted. Verb: ${request.verb}` + `Invalid verb received for path: ${request.path}. Only GET is accepted. Verb: ${request.verb}`, ); } } @@ -349,7 +347,7 @@ class StreamingRequestHandler extends RequestHandler { : await attachmentStream.readAsString(); return { contentType, content }; - }) + }), ); } catch (err) { return end(StatusCodes.BAD_REQUEST, `Request body missing or malformed: ${err}`); @@ -377,7 +375,7 @@ class StreamingConnectorFactory implements ConnectorFactory { if (serviceUrl !== this.serviceUrl) { throw new Error( - 'This is a streaming scenario, all connectors from this factory must all be for the same url.' + 'This is a streaming scenario, all connectors from this factory must all be for the same url.', ); } @@ -411,7 +409,7 @@ class StreamingHttpClient implements HttpClient { private async createHttpResponse( receiveResponse: IReceiveResponse, - httpRequest: WebResource + httpRequest: WebResource, ): Promise { const [bodyAsText] = (await Promise.all(receiveResponse.streams?.map((stream) => stream.readAsString()) ?? [])) ?? []; diff --git a/libraries/botbuilder/src/eventFactory.ts b/libraries/botbuilder/src/eventFactory.ts index e73380ea68..9e0ba5a5f7 100644 --- a/libraries/botbuilder/src/eventFactory.ts +++ b/libraries/botbuilder/src/eventFactory.ts @@ -33,7 +33,7 @@ export class EventFactory { static createHandoffInitiation( context: TurnContext, handoffContext: T, - transcript?: Transcript + transcript?: Transcript, ): Activity { if (!context) { throw new TypeError('EventFactory.createHandoffInitiation(): Missing context.'); @@ -42,7 +42,7 @@ export class EventFactory { const handoffEvent = this.createHandoffEvent( HandoffEventNames.InitiateHandoff, handoffContext, - context.activity.conversation + context.activity.conversation, ); handoffEvent.from = context.activity.from; @@ -89,7 +89,7 @@ export class EventFactory { private static createHandoffEvent( name: string, value: T, - conversation: ConversationAccount + conversation: ConversationAccount, ): Activity { const handoffEvent: Partial = { type: ActivityTypes.Event }; diff --git a/libraries/botbuilder/src/fileTranscriptStore.ts b/libraries/botbuilder/src/fileTranscriptStore.ts index f57a8de62f..864a8f977c 100644 --- a/libraries/botbuilder/src/fileTranscriptStore.ts +++ b/libraries/botbuilder/src/fileTranscriptStore.ts @@ -142,7 +142,7 @@ export class FileTranscriptStore implements TranscriptStore { channelId: string, conversationId: string, continuationToken?: string, - startDate?: Date + startDate?: Date, ): Promise> { if (!channelId) { throw new Error('Missing channelId'); @@ -160,10 +160,12 @@ export class FileTranscriptStore implements TranscriptStore { return pagedResult; } + //eslint-disable-next-line security/detect-non-literal-fs-filename const transcriptFolderContents = await readdir(transcriptFolder); const include = includeWhen((fileName) => !continuationToken || parse(fileName).name === continuationToken); const items = transcriptFolderContents.filter( - (transcript) => transcript.endsWith('.json') && withDateFilter(startDate, transcript) && include(transcript) + (transcript) => + transcript.endsWith('.json') && withDateFilter(startDate, transcript) && include(transcript), ); pagedResult.items = await Promise.all( @@ -171,9 +173,10 @@ export class FileTranscriptStore implements TranscriptStore { .slice(0, FileTranscriptStore.PageSize) .sort() .map(async (activityFilename) => { + //eslint-disable-next-line security/detect-non-literal-fs-filename const json = await readFile(join(transcriptFolder, activityFilename), 'utf8'); return parseActivity(json); - }) + }), ); const { length } = pagedResult.items; if (length === FileTranscriptStore.PageSize && items[length]) { @@ -201,6 +204,8 @@ export class FileTranscriptStore implements TranscriptStore { if (!exists) { return pagedResult; } + + //eslint-disable-next-line security/detect-non-literal-fs-filename const channels = await readdir(channelFolder); const items = channels.filter(includeWhen((di) => !continuationToken || di === continuationToken)); pagedResult.items = items @@ -250,6 +255,7 @@ export class FileTranscriptStore implements TranscriptStore { if (!exists) { await mkdirp(transcriptPath); } + //eslint-disable-next-line security/detect-non-literal-fs-filename return writeFile(join(transcriptPath, activityFilename), json, 'utf8'); } diff --git a/libraries/botbuilder/src/inspectionMiddleware.ts b/libraries/botbuilder/src/inspectionMiddleware.ts index 4fed361e04..0cd579f257 100644 --- a/libraries/botbuilder/src/inspectionMiddleware.ts +++ b/libraries/botbuilder/src/inspectionMiddleware.ts @@ -90,7 +90,7 @@ abstract class InterceptionMiddleware implements Middleware { async onTurn(turnContext: TurnContext, next: () => Promise): Promise { const { shouldForwardToApplication, shouldIntercept } = await this.invokeInbound( turnContext, - TraceActivity.fromActivity(turnContext.activity, 'ReceivedActivity', 'Received Activity') + TraceActivity.fromActivity(turnContext.activity, 'ReceivedActivity', 'Received Activity'), ); if (shouldIntercept) { @@ -168,7 +168,6 @@ abstract class InterceptionMiddleware implements Middleware { * * @remarks * InspectionMiddleware for emulator inspection of runtime Activities and BotState. - * * @deprecated This class will be removed in a future version of the framework. */ export class InspectionMiddleware extends InterceptionMiddleware { @@ -192,7 +191,7 @@ export class InspectionMiddleware extends InterceptionMiddleware { inspectionState: InspectionState, userState?: UserState, conversationState?: ConversationState, - credentials?: Partial + credentials?: Partial, ) { super(); @@ -312,7 +311,7 @@ export class InspectionMiddleware extends InterceptionMiddleware { const sessions = await this.inspectionStateAccessor.get(turnContext, InspectionSessionsByStatus.DefaultValue); const sessionId = this.openCommand(sessions, TurnContext.getConversationReference(turnContext.activity)); await turnContext.sendActivity( - TraceActivity.makeCommandActivity(`${InspectionMiddleware.command} attach ${sessionId}`) + TraceActivity.makeCommandActivity(`${InspectionMiddleware.command} attach ${sessionId}`), ); await this.inspectionState.saveChanges(turnContext, false); } @@ -336,7 +335,7 @@ export class InspectionMiddleware extends InterceptionMiddleware { */ private openCommand( sessions: InspectionSessionsByStatus, - conversationReference: Partial + conversationReference: Partial, ): string { const sessionId = uuidv4(); sessions.openedSessions[sessionId] = conversationReference; @@ -376,7 +375,7 @@ export class InspectionMiddleware extends InterceptionMiddleware { private async invokeSend( turnContext: TurnContext, session: InspectionSession, - activity: Partial + activity: Partial, ): Promise { if (await session.send(activity)) { return true; @@ -444,7 +443,6 @@ class InspectionSessionsByStatus { * * @remarks * InspectionState for use by the InspectionMiddleware for emulator inspection of runtime Activities and BotState. - * * @deprecated This class will be removed in a future version of the framework. */ export class InspectionState extends BotState { diff --git a/libraries/botbuilder/src/interfaces/connectorClientBuilder.ts b/libraries/botbuilder/src/interfaces/connectorClientBuilder.ts index 5645674239..f6cb3bfffb 100644 --- a/libraries/botbuilder/src/interfaces/connectorClientBuilder.ts +++ b/libraries/botbuilder/src/interfaces/connectorClientBuilder.ts @@ -22,6 +22,6 @@ export interface ConnectorClientBuilder { createConnectorClientWithIdentity: ( serviceUrl: string, claimsIdentity: ClaimsIdentity, - audience: string + audience: string, ) => Promise; } diff --git a/libraries/botbuilder/src/interfaces/request.ts b/libraries/botbuilder/src/interfaces/request.ts index 741170b574..d344eac0f3 100644 --- a/libraries/botbuilder/src/interfaces/request.ts +++ b/libraries/botbuilder/src/interfaces/request.ts @@ -7,7 +7,7 @@ */ export interface Request< Body extends Record = Record, - Headers extends Record = Record + Headers extends Record = Record, > { body?: Body; headers: Headers; diff --git a/libraries/botbuilder/src/interfaces/response.ts b/libraries/botbuilder/src/interfaces/response.ts index 13936873fd..b9ed0bcb8d 100644 --- a/libraries/botbuilder/src/interfaces/response.ts +++ b/libraries/botbuilder/src/interfaces/response.ts @@ -25,5 +25,5 @@ export const ResponseT = z.custom( typeof val.status === 'function', { message: 'Response', - } + }, ); diff --git a/libraries/botbuilder/src/interfaces/webRequest.ts b/libraries/botbuilder/src/interfaces/webRequest.ts index 448580c9ca..4ebcabb82f 100644 --- a/libraries/botbuilder/src/interfaces/webRequest.ts +++ b/libraries/botbuilder/src/interfaces/webRequest.ts @@ -44,7 +44,6 @@ export interface WebRequest { * * @param event The event name. * @param args Arguments used to handle the event. - * * @returns A reference to the request object. */ on?(event: string, ...args: any[]): any; diff --git a/libraries/botbuilder/src/interfaces/webResponse.ts b/libraries/botbuilder/src/interfaces/webResponse.ts index 9b3a8b4862..35d0c0fe6f 100644 --- a/libraries/botbuilder/src/interfaces/webResponse.ts +++ b/libraries/botbuilder/src/interfaces/webResponse.ts @@ -22,7 +22,6 @@ export interface WebResponse { * When implemented in a derived class, sends a FIN packet. * * @param args The arguments for the end event. - * * @returns A reference to the response object. */ end(...args: any[]): any; @@ -31,7 +30,6 @@ export interface WebResponse { * When implemented in a derived class, sends the response. * * @param body The response payload. - * * @returns A reference to the response object. */ send(body: any): any; @@ -40,7 +38,6 @@ export interface WebResponse { * When implemented in a derived class, sets the HTTP status code for the response. * * @param status The status code to use. - * * @returns The status code. */ status(status: number): any; diff --git a/libraries/botbuilder/src/setSpeakMiddleware.ts b/libraries/botbuilder/src/setSpeakMiddleware.ts index 78480d4c99..89276c7eca 100644 --- a/libraries/botbuilder/src/setSpeakMiddleware.ts +++ b/libraries/botbuilder/src/setSpeakMiddleware.ts @@ -42,7 +42,10 @@ export class SetSpeakMiddleware implements Middleware { * @param voiceName The SSML voice name attribute value. * @param fallbackToTextForSpeak true if an empty Activity.Speak is populated with Activity.Text. */ - constructor(private readonly voiceName: string | null, private readonly fallbackToTextForSpeak: boolean) {} + constructor( + private readonly voiceName: string | null, + private readonly fallbackToTextForSpeak: boolean, + ) {} /** * Processes an incoming activity. @@ -78,7 +81,7 @@ export class SetSpeakMiddleware implements Middleware { }'>${activity.speak}`; } } - }) + }), ); return next(); diff --git a/libraries/botbuilder/src/sharepoint/sharePointActivityHandler.ts b/libraries/botbuilder/src/sharepoint/sharePointActivityHandler.ts index 0a017f68b7..821251e3f8 100644 --- a/libraries/botbuilder/src/sharepoint/sharePointActivityHandler.ts +++ b/libraries/botbuilder/src/sharepoint/sharePointActivityHandler.ts @@ -26,7 +26,7 @@ export class SharePointActivityHandler extends ActivityHandler { /** * Invoked when an invoke activity is received from the connector. * Invoke activities can be used to communicate many different things. - * * Invoke activities communicate programmatic commands from a client or channel to a bot. + * Invoke activities communicate programmatic commands from a client or channel to a bot. * * @param context A strongly-typed context object for this turn * @returns A task that represents the work queued to execute @@ -39,32 +39,32 @@ export class SharePointActivityHandler extends ActivityHandler { switch (context.activity.name) { case 'cardExtension/getCardView': return ActivityHandler.createInvokeResponse( - await this.onSharePointTaskGetCardViewAsync(context, context.activity.value as AceRequest) + await this.onSharePointTaskGetCardViewAsync(context, context.activity.value as AceRequest), ); case 'cardExtension/getQuickView': return ActivityHandler.createInvokeResponse( - await this.onSharePointTaskGetQuickViewAsync(context, context.activity.value as AceRequest) + await this.onSharePointTaskGetQuickViewAsync(context, context.activity.value as AceRequest), ); case 'cardExtension/getPropertyPaneConfiguration': return ActivityHandler.createInvokeResponse( await this.onSharePointTaskGetPropertyPaneConfigurationAsync( context, - context.activity.value as AceRequest - ) + context.activity.value as AceRequest, + ), ); case 'cardExtension/setPropertyPaneConfiguration': return ActivityHandler.createInvokeResponse( await this.onSharePointTaskSetPropertyPaneConfigurationAsync( context, - context.activity.value as AceRequest - ) + context.activity.value as AceRequest, + ), ); case 'cardExtension/handleAction': return ActivityHandler.createInvokeResponse( - await this.onSharePointTaskHandleActionAsync(context, context.activity.value as AceRequest) + await this.onSharePointTaskHandleActionAsync(context, context.activity.value as AceRequest), ); default: return super.onInvokeActivity(context); @@ -89,7 +89,7 @@ export class SharePointActivityHandler extends ActivityHandler { */ protected async onSharePointTaskGetCardViewAsync( _context: TurnContext, - _aceRequest: AceRequest + _aceRequest: AceRequest, ): Promise { throw new Error('NotImplemented'); } @@ -103,7 +103,7 @@ export class SharePointActivityHandler extends ActivityHandler { */ protected async onSharePointTaskGetQuickViewAsync( _context: TurnContext, - _aceRequest: AceRequest + _aceRequest: AceRequest, ): Promise { throw new Error('NotImplemented'); } @@ -117,7 +117,7 @@ export class SharePointActivityHandler extends ActivityHandler { */ protected async onSharePointTaskGetPropertyPaneConfigurationAsync( _context: TurnContext, - _aceRequest: AceRequest + _aceRequest: AceRequest, ): Promise { throw new Error('NotImplemented'); } @@ -131,7 +131,7 @@ export class SharePointActivityHandler extends ActivityHandler { */ protected async onSharePointTaskSetPropertyPaneConfigurationAsync( _context: TurnContext, - _aceRequest: AceRequest + _aceRequest: AceRequest, ): Promise { throw new Error('NotImplemented'); } @@ -145,7 +145,7 @@ export class SharePointActivityHandler extends ActivityHandler { */ protected async onSharePointTaskHandleActionAsync( _context: TurnContext, - _aceRequest: AceRequest + _aceRequest: AceRequest, ): Promise { throw new Error('NotImplemented'); } diff --git a/libraries/botbuilder/src/skills/cloudSkillHandler.ts b/libraries/botbuilder/src/skills/cloudSkillHandler.ts index 027995a96e..5c1d1939fe 100644 --- a/libraries/botbuilder/src/skills/cloudSkillHandler.ts +++ b/libraries/botbuilder/src/skills/cloudSkillHandler.ts @@ -39,7 +39,7 @@ export class CloudSkillHandler extends CloudChannelServiceHandler { adapter: BotAdapter, logic: (context: TurnContext) => Promise, conversationIdFactory: SkillConversationIdFactoryBase, - auth: BotFrameworkAuthentication + auth: BotFrameworkAuthentication, ) { super(auth); @@ -60,7 +60,7 @@ export class CloudSkillHandler extends CloudChannelServiceHandler { adapter, logic, conversationIdFactory, - () => auth.getOriginatingAudience() + () => auth.getOriginatingAudience(), ); } @@ -71,9 +71,9 @@ export class CloudSkillHandler extends CloudChannelServiceHandler { * This method allows you to send an activity to the end of a conversation. * * This is slightly different from replyToActivity(). - * * sendToConversation(conversationId) - will append the activity to the end + * - sendToConversation(conversationId) - will append the activity to the end * of the conversation according to the timestamp or semantics of the channel. - * * replyToActivity(conversationId,ActivityId) - adds the activity as a reply + * - replyToActivity(conversationId,ActivityId) - adds the activity as a reply * to another activity, if the channel supports it. If the channel does not * support nested replies, replyToActivity falls back to sendToConversation. * @@ -88,7 +88,7 @@ export class CloudSkillHandler extends CloudChannelServiceHandler { protected onSendToConversation( claimsIdentity: ClaimsIdentity, conversationId: string, - activity: Activity + activity: Activity, ): Promise { return this.inner.onSendToConversation(claimsIdentity, conversationId, activity); } @@ -100,9 +100,9 @@ export class CloudSkillHandler extends CloudChannelServiceHandler { * This method allows you to reply to an activity. * * This is slightly different from sendToConversation(). - * * sendToConversation(conversationId) - will append the activity to the end + * - sendToConversation(conversationId) - will append the activity to the end * of the conversation according to the timestamp or semantics of the channel. - * * replyToActivity(conversationId,ActivityId) - adds the activity as a reply + * - replyToActivity(conversationId,ActivityId) - adds the activity as a reply * to another activity, if the channel supports it. If the channel does not * support nested replies, replyToActivity falls back to sendToConversation. * @@ -119,7 +119,7 @@ export class CloudSkillHandler extends CloudChannelServiceHandler { claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, - activity: Activity + activity: Activity, ): Promise { return this.inner.onReplyToActivity(claimsIdentity, conversationId, activityId, activity); } @@ -145,7 +145,7 @@ export class CloudSkillHandler extends CloudChannelServiceHandler { claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, - activity: Activity + activity: Activity, ): Promise { return this.inner.onUpdateActivity(claimsIdentity, conversationId, activityId, activity); } @@ -158,8 +158,6 @@ export class CloudSkillHandler extends CloudChannelServiceHandler { * * Some channels allow you to delete an existing activity, and if successful * this method will remove the specified activity. - * - * * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. * @param conversationId Conversation ID. * @param activityId activityId to delete. @@ -168,7 +166,7 @@ export class CloudSkillHandler extends CloudChannelServiceHandler { protected async onDeleteActivity( claimsIdentity: ClaimsIdentity, conversationId: string, - activityId: string + activityId: string, ): Promise { return this.inner.onDeleteActivity(claimsIdentity, conversationId, activityId); } @@ -184,13 +182,12 @@ export class CloudSkillHandler extends CloudChannelServiceHandler { * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. * @param userId User ID. * @param conversationId Conversation ID. - * * @returns The ChannelAccount object representing the member of the conversation. */ protected async onGetConversationMember( claimsIdentity: ClaimsIdentity, userId: string, - conversationId: string + conversationId: string, ): Promise { return this.inner.onGetMember(claimsIdentity, userId, conversationId); } diff --git a/libraries/botbuilder/src/skills/skillHandler.ts b/libraries/botbuilder/src/skills/skillHandler.ts index df81af5eb8..3f956a22ba 100644 --- a/libraries/botbuilder/src/skills/skillHandler.ts +++ b/libraries/botbuilder/src/skills/skillHandler.ts @@ -54,7 +54,7 @@ export class SkillHandler extends ChannelServiceHandler { conversationIdFactory: SkillConversationIdFactoryBase, credentialProvider: ICredentialProvider, authConfig: AuthenticationConfiguration, - channelService?: string + channelService?: string, ) { super(credentialProvider, authConfig, channelService); @@ -78,7 +78,7 @@ export class SkillHandler extends ChannelServiceHandler { () => JwtTokenValidation.isGovernment(channelService) ? GovernmentConstants.ToChannelFromBotOAuthScope - : AuthenticationConstants.ToChannelFromBotOAuthScope + : AuthenticationConstants.ToChannelFromBotOAuthScope, ); } @@ -89,9 +89,9 @@ export class SkillHandler extends ChannelServiceHandler { * This method allows you to send an activity to the end of a conversation. * * This is slightly different from replyToActivity(). - * * sendToConversation(conversationId) - will append the activity to the end + * - sendToConversation(conversationId) - will append the activity to the end * of the conversation according to the timestamp or semantics of the channel. - * * replyToActivity(conversationId,ActivityId) - adds the activity as a reply + * - replyToActivity(conversationId,ActivityId) - adds the activity as a reply * to another activity, if the channel supports it. If the channel does not * support nested replies, replyToActivity falls back to sendToConversation. * @@ -106,7 +106,7 @@ export class SkillHandler extends ChannelServiceHandler { protected onSendToConversation( claimsIdentity: ClaimsIdentity, conversationId: string, - activity: Activity + activity: Activity, ): Promise { return this.inner.onSendToConversation(claimsIdentity, conversationId, activity); } @@ -118,9 +118,9 @@ export class SkillHandler extends ChannelServiceHandler { * This method allows you to reply to an activity. * * This is slightly different from sendToConversation(). - * * sendToConversation(conversationId) - will append the activity to the end + * - sendToConversation(conversationId) - will append the activity to the end * of the conversation according to the timestamp or semantics of the channel. - * * replyToActivity(conversationId,ActivityId) - adds the activity as a reply + * - replyToActivity(conversationId,ActivityId) - adds the activity as a reply * to another activity, if the channel supports it. If the channel does not * support nested replies, replyToActivity falls back to sendToConversation. * @@ -137,7 +137,7 @@ export class SkillHandler extends ChannelServiceHandler { claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, - activity: Activity + activity: Activity, ): Promise { return this.inner.onReplyToActivity(claimsIdentity, conversationId, activityId, activity); } @@ -163,7 +163,7 @@ export class SkillHandler extends ChannelServiceHandler { claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, - activity: Activity + activity: Activity, ): Promise { return this.inner.onUpdateActivity(claimsIdentity, conversationId, activityId, activity); } @@ -176,8 +176,6 @@ export class SkillHandler extends ChannelServiceHandler { * * Some channels allow you to delete an existing activity, and if successful * this method will remove the specified activity. - * - * * @param claimsIdentity ClaimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim. * @param conversationId Conversation ID. * @param activityId activityId to delete. @@ -186,7 +184,7 @@ export class SkillHandler extends ChannelServiceHandler { protected async onDeleteActivity( claimsIdentity: ClaimsIdentity, conversationId: string, - activityId: string + activityId: string, ): Promise { return this.inner.onDeleteActivity(claimsIdentity, conversationId, activityId); } diff --git a/libraries/botbuilder/src/skills/skillHandlerImpl.ts b/libraries/botbuilder/src/skills/skillHandlerImpl.ts index a12b778a77..b44fe0ac52 100644 --- a/libraries/botbuilder/src/skills/skillHandlerImpl.ts +++ b/libraries/botbuilder/src/skills/skillHandlerImpl.ts @@ -28,7 +28,7 @@ export class SkillHandlerImpl { private readonly adapter: BotAdapter, private readonly logic: (context: TurnContext) => Promise, private readonly conversationIdFactory: SkillConversationIdFactoryBase, - private readonly getOauthScope: () => string | undefined = () => undefined + private readonly getOauthScope: () => string | undefined = () => undefined, ) {} /** @@ -37,7 +37,7 @@ export class SkillHandlerImpl { onSendToConversation( claimsIdentity: ClaimsIdentity, conversationId: string, - activity: Activity + activity: Activity, ): Promise { return this.processActivity(claimsIdentity, conversationId, null, activity); } @@ -49,7 +49,7 @@ export class SkillHandlerImpl { claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, - activity: Activity + activity: Activity, ): Promise { return this.processActivity(claimsIdentity, conversationId, activityId, activity); } @@ -61,7 +61,7 @@ export class SkillHandlerImpl { claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, - activity: Activity + activity: Activity, ): Promise { let resourceResponse: ResourceResponse | void; @@ -70,7 +70,7 @@ export class SkillHandlerImpl { context.activity.id = activityId; context.activity.callerId = `${CallerIdConstants.BotToBotPrefix}${JwtTokenValidation.getAppIdFromClaims( - claimsIdentity.claims + claimsIdentity.claims, )}`; resourceResponse = await context.updateActivity(newActivity); @@ -84,7 +84,7 @@ export class SkillHandlerImpl { */ async onDeleteActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string): Promise { return this.continueConversation(claimsIdentity, conversationId, (context) => - context.deleteActivity(activityId) + context.deleteActivity(activityId), ); } @@ -135,7 +135,7 @@ export class SkillHandlerImpl { claimsIdentity: ClaimsIdentity, conversationId: string, replyToActivityId: string, - activity: Activity + activity: Activity, ): Promise { let resourceResponse: ResourceResponse; @@ -151,7 +151,7 @@ export class SkillHandlerImpl { context.activity.id = replyToActivityId; context.activity.callerId = `${CallerIdConstants.BotToBotPrefix}${JwtTokenValidation.getAppIdFromClaims( - claimsIdentity.claims + claimsIdentity.claims, )}`; switch (newActivity.type) { @@ -185,7 +185,7 @@ export class SkillHandlerImpl { private async continueConversation( claimsIdentity: ClaimsIdentity, conversationId: string, - callback: (context: TurnContext, ref: SkillConversationReference) => Promise + callback: (context: TurnContext, ref: SkillConversationReference) => Promise, ): Promise { const ref = await this.getSkillConversationReference(conversationId); @@ -199,7 +199,7 @@ export class SkillHandlerImpl { claimsIdentity, ref.conversationReference, ref.oAuthScope, - continueCallback + continueCallback, ); } catch (err) { if (err.message === 'NotImplemented') { diff --git a/libraries/botbuilder/src/skills/skillHttpClient.ts b/libraries/botbuilder/src/skills/skillHttpClient.ts index 28c74bcb66..fb145bb2de 100644 --- a/libraries/botbuilder/src/skills/skillHttpClient.ts +++ b/libraries/botbuilder/src/skills/skillHttpClient.ts @@ -38,7 +38,7 @@ export class SkillHttpClient extends BotFrameworkHttpClient { constructor( credentialProvider: ICredentialProvider, conversationIdFactory: SkillConversationIdFactoryBase, - channelService?: string + channelService?: string, ) { super(credentialProvider, channelService); if (!conversationIdFactory) { @@ -63,7 +63,7 @@ export class SkillHttpClient extends BotFrameworkHttpClient { fromBotId: string, toSkill: BotFrameworkSkill, callbackUrl: string, - activity: Activity + activity: Activity, ): Promise>; /** * Uses the SkillConversationIdFactory to create or retrieve a Skill Conversation Id, and sends the activity. @@ -78,7 +78,7 @@ export class SkillHttpClient extends BotFrameworkHttpClient { fromBotId: string, toSkill: BotFrameworkSkill, callbackUrl: string, - activity: Activity + activity: Activity, ): Promise; /** * Uses the `SkillConversationIdFactory` to create or retrieve a Skill Conversation Id, and sends the [Activity](xref:botframework-schema.Activity). @@ -95,7 +95,7 @@ export class SkillHttpClient extends BotFrameworkHttpClient { fromBotIdOrSkill: string | BotFrameworkSkill, toSkillOrCallbackUrl: BotFrameworkSkill | string, callbackUrlOrActivity: string | Activity, - activityToForward?: Activity + activityToForward?: Activity, ): Promise> { let originatingAudience: string; let fromBotId: string; @@ -125,13 +125,12 @@ export class SkillHttpClient extends BotFrameworkHttpClient { fromBotOAuthScope: originatingAudience, }; - skillConversationId = await this.conversationIdFactory.createSkillConversationIdWithOptions( - createIdOptions - ); + skillConversationId = + await this.conversationIdFactory.createSkillConversationIdWithOptions(createIdOptions); } catch (err) { if (err.message === 'Not Implemented') { skillConversationId = await this.conversationIdFactory.createSkillConversationId( - TurnContext.getConversationReference(activity) as ConversationReference + TurnContext.getConversationReference(activity) as ConversationReference, ); } else { throw err; @@ -144,7 +143,7 @@ export class SkillHttpClient extends BotFrameworkHttpClient { toSkill.skillEndpoint, callbackUrl, skillConversationId, - activity + activity, ); } } diff --git a/libraries/botbuilder/src/statusCodeError.ts b/libraries/botbuilder/src/statusCodeError.ts index 9c2e59d0d5..18d5bc00eb 100644 --- a/libraries/botbuilder/src/statusCodeError.ts +++ b/libraries/botbuilder/src/statusCodeError.ts @@ -18,7 +18,10 @@ export class StatusCodeError extends Error { * @param statusCode The status code. * @param message Optional. The error message. */ - constructor(public readonly statusCode: StatusCodes, message?: string) { + constructor( + readonly statusCode: StatusCodes, + message?: string, + ) { super(message); this.name = 'StatusCodeError'; diff --git a/libraries/botbuilder/src/streaming/streamingHttpClient.ts b/libraries/botbuilder/src/streaming/streamingHttpClient.ts index 0d631ba2bb..bfe8d35bf7 100644 --- a/libraries/botbuilder/src/streaming/streamingHttpClient.ts +++ b/libraries/botbuilder/src/streaming/streamingHttpClient.ts @@ -41,7 +41,7 @@ export class StreamingHttpClient implements HttpClient { } if (!this.server.isConnected) { throw new Error( - 'StreamingHttpClient.sendRequest(): Streaming connection is disconnected, and the request could not be sent.' + 'StreamingHttpClient.sendRequest(): Streaming connection is disconnected, and the request could not be sent.', ); } diff --git a/libraries/botbuilder/src/streaming/tokenResolver.ts b/libraries/botbuilder/src/streaming/tokenResolver.ts index 1ac144248e..9c0b1089f6 100644 --- a/libraries/botbuilder/src/streaming/tokenResolver.ts +++ b/libraries/botbuilder/src/streaming/tokenResolver.ts @@ -60,7 +60,7 @@ export class TokenResolver { setTimeout( () => this.pollForToken(adapter, context, activity, oauthCard.connectionName, pollingTimeout, log), - TokenResolver.PollingIntervalMs + TokenResolver.PollingIntervalMs, ); } } @@ -75,7 +75,7 @@ export class TokenResolver { activity: Activity, connectionName: string, pollingTimeout: Date, - log?: string[] + log?: string[], ) { if (pollingTimeout > new Date()) { const tokenApiClientCredentials = context.turnState.get(adapter.TokenApiClientCredentialsKey); @@ -90,7 +90,7 @@ export class TokenResolver { TokenResolver.createTokenResponseActivity( TurnContext.getConversationReference(activity), tokenResponse.token, - connectionName + connectionName, ) ); // received a token, send it to the bot and end polling @@ -121,7 +121,7 @@ export class TokenResolver { if (log) log.push('Polling again'); setTimeout( () => this.pollForToken(adapter, context, activity, connectionName, pollingTimeout), - pollingIntervalMs + pollingIntervalMs, ); }); } @@ -130,7 +130,7 @@ export class TokenResolver { private static createTokenResponseActivity( relatesTo: Partial, token: string, - connectionName: string + connectionName: string, ): Partial { const tokenResponse: Partial = { id: uuidv4(), diff --git a/libraries/botbuilder/src/teams/teamsSSOTokenExchangeMiddleware.ts b/libraries/botbuilder/src/teams/teamsSSOTokenExchangeMiddleware.ts index 76a8f8378e..284baf5f06 100644 --- a/libraries/botbuilder/src/teams/teamsSSOTokenExchangeMiddleware.ts +++ b/libraries/botbuilder/src/teams/teamsSSOTokenExchangeMiddleware.ts @@ -50,7 +50,7 @@ async function sendInvokeResponse(context: TurnContext, body: unknown = null, st const ExchangeToken = z.custom>( (val: any) => typeof val.exchangeToken === 'function', - { message: 'ExtendedUserTokenProvider' } + { message: 'ExtendedUserTokenProvider' }, ); /** @@ -75,7 +75,10 @@ export class TeamsSSOTokenExchangeMiddleware implements Middleware { * @param storage The [Storage](xref:botbuilder-core.Storage) to use for deduplication * @param oAuthConnectionName The connection name to use for the single sign on token exchange */ - constructor(private readonly storage: Storage, private readonly oAuthConnectionName: string) { + constructor( + private readonly storage: Storage, + private readonly oAuthConnectionName: string, + ) { if (!storage) { throw new TypeError('`storage` parameter is required'); } @@ -142,7 +145,7 @@ export class TeamsSSOTokenExchangeMiddleware implements Middleware { try { const userTokenClient = context.turnState.get( - (context.adapter as CloudAdapterBase).UserTokenClientKey + (context.adapter as CloudAdapterBase).UserTokenClientKey, ); const exchangeToken = ExchangeToken.safeParse(context.adapter); @@ -151,14 +154,14 @@ export class TeamsSSOTokenExchangeMiddleware implements Middleware { context.activity.from.id, this.oAuthConnectionName, context.activity.channelId, - { token: tokenExchangeRequest.token } + { token: tokenExchangeRequest.token }, ); } else if (exchangeToken.success) { tokenExchangeResponse = await exchangeToken.data.exchangeToken( context, this.oAuthConnectionName, context.activity.from.id, - { token: tokenExchangeRequest.token } + { token: tokenExchangeRequest.token }, ); } else { new Error('Token Exchange is not supported by the current adapter.'); diff --git a/libraries/botbuilder/src/teamsActivityHandler.ts b/libraries/botbuilder/src/teamsActivityHandler.ts index fe95022307..43bd322d33 100644 --- a/libraries/botbuilder/src/teamsActivityHandler.ts +++ b/libraries/botbuilder/src/teamsActivityHandler.ts @@ -90,15 +90,15 @@ export class TeamsActivityHandler extends ActivityHandler { switch (context.activity.name) { case 'config/fetch': return ActivityHandler.createInvokeResponse( - await this.handleTeamsConfigFetch(context, context.activity.value) + await this.handleTeamsConfigFetch(context, context.activity.value), ); case 'config/submit': return ActivityHandler.createInvokeResponse( - await this.handleTeamsConfigSubmit(context, context.activity.value) + await this.handleTeamsConfigSubmit(context, context.activity.value), ); case 'fileConsent/invoke': return ActivityHandler.createInvokeResponse( - await this.handleTeamsFileConsent(context, context.activity.value) + await this.handleTeamsFileConsent(context, context.activity.value), ); case 'actionableMessage/executeAction': @@ -107,43 +107,43 @@ export class TeamsActivityHandler extends ActivityHandler { case 'composeExtension/queryLink': return ActivityHandler.createInvokeResponse( - await this.handleTeamsAppBasedLinkQuery(context, context.activity.value) + await this.handleTeamsAppBasedLinkQuery(context, context.activity.value), ); case 'composeExtension/anonymousQueryLink': return ActivityHandler.createInvokeResponse( - await this.handleTeamsAnonymousAppBasedLinkQuery(context, context.activity.value) + await this.handleTeamsAnonymousAppBasedLinkQuery(context, context.activity.value), ); case 'composeExtension/query': return ActivityHandler.createInvokeResponse( - await this.handleTeamsMessagingExtensionQuery(context, context.activity.value) + await this.handleTeamsMessagingExtensionQuery(context, context.activity.value), ); case 'composeExtension/selectItem': return ActivityHandler.createInvokeResponse( - await this.handleTeamsMessagingExtensionSelectItem(context, context.activity.value) + await this.handleTeamsMessagingExtensionSelectItem(context, context.activity.value), ); case 'composeExtension/submitAction': return ActivityHandler.createInvokeResponse( await this.handleTeamsMessagingExtensionSubmitActionDispatch( context, - context.activity.value - ) + context.activity.value, + ), ); case 'composeExtension/fetchTask': return ActivityHandler.createInvokeResponse( - await this.handleTeamsMessagingExtensionFetchTask(context, context.activity.value) + await this.handleTeamsMessagingExtensionFetchTask(context, context.activity.value), ); case 'composeExtension/querySettingUrl': return ActivityHandler.createInvokeResponse( await this.handleTeamsMessagingExtensionConfigurationQuerySettingUrl( context, - context.activity.value - ) + context.activity.value, + ), ); case 'composeExtension/setting': @@ -156,22 +156,22 @@ export class TeamsActivityHandler extends ActivityHandler { case 'task/fetch': return ActivityHandler.createInvokeResponse( - await this.handleTeamsTaskModuleFetch(context, context.activity.value) + await this.handleTeamsTaskModuleFetch(context, context.activity.value), ); case 'task/submit': return ActivityHandler.createInvokeResponse( - await this.handleTeamsTaskModuleSubmit(context, context.activity.value) + await this.handleTeamsTaskModuleSubmit(context, context.activity.value), ); case 'tab/fetch': return ActivityHandler.createInvokeResponse( - await this.handleTeamsTabFetch(context, context.activity.value) + await this.handleTeamsTabFetch(context, context.activity.value), ); case 'tab/submit': return ActivityHandler.createInvokeResponse( - await this.handleTeamsTabSubmit(context, context.activity.value) + await this.handleTeamsTabSubmit(context, context.activity.value), ); default: @@ -237,7 +237,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsFileConsent( context: TurnContext, - fileConsentCardResponse: FileConsentCardResponse + fileConsentCardResponse: FileConsentCardResponse, ): Promise { switch (fileConsentCardResponse.action) { case 'accept': @@ -260,7 +260,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsFileConsentAccept( _context: TurnContext, - _fileConsentCardResponse: FileConsentCardResponse + _fileConsentCardResponse: FileConsentCardResponse, ): Promise { throw new Error('NotImplemented'); } @@ -276,7 +276,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsFileConsentDecline( _context: TurnContext, - _fileConsentCardResponse: FileConsentCardResponse + _fileConsentCardResponse: FileConsentCardResponse, ): Promise { throw new Error('NotImplemented'); } @@ -290,7 +290,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsO365ConnectorCardAction( _context: TurnContext, - _query: O365ConnectorCardActionQuery + _query: O365ConnectorCardActionQuery, ): Promise { throw new Error('NotImplemented'); } @@ -319,7 +319,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsSigninVerifyState( _context: TurnContext, - _query: SigninStateVerificationQuery + _query: SigninStateVerificationQuery, ): Promise { throw new Error('NotImplemented'); } @@ -333,7 +333,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsSigninTokenExchange( _context: TurnContext, - _query: SigninStateVerificationQuery + _query: SigninStateVerificationQuery, ): Promise { throw new Error('NotImplemented'); } @@ -347,7 +347,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsMessagingExtensionCardButtonClicked( _context: TurnContext, - _cardData: any + _cardData: any, ): Promise { throw new Error('NotImplemented'); } @@ -361,7 +361,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsTaskModuleFetch( _context: TurnContext, - _taskModuleRequest: TaskModuleRequest + _taskModuleRequest: TaskModuleRequest, ): Promise { throw new Error('NotImplemented'); } @@ -375,7 +375,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsTaskModuleSubmit( _context: TurnContext, - _taskModuleRequest: TaskModuleRequest + _taskModuleRequest: TaskModuleRequest, ): Promise { throw new Error('NotImplemented'); } @@ -413,7 +413,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsAppBasedLinkQuery( _context: TurnContext, - _query: AppBasedLinkQuery + _query: AppBasedLinkQuery, ): Promise { throw new Error('NotImplemented'); } @@ -429,7 +429,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsAnonymousAppBasedLinkQuery( _context: TurnContext, - _query: AppBasedLinkQuery + _query: AppBasedLinkQuery, ): Promise { throw new Error('NotImplemented'); } @@ -445,7 +445,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsMessagingExtensionQuery( _context: TurnContext, - _query: MessagingExtensionQuery + _query: MessagingExtensionQuery, ): Promise { throw new Error('NotImplemented'); } @@ -461,7 +461,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsMessagingExtensionSelectItem( _context: TurnContext, - _query: any + _query: any, ): Promise { throw new Error('NotImplemented'); } @@ -479,7 +479,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsMessagingExtensionSubmitActionDispatch( context: TurnContext, - action: MessagingExtensionAction + action: MessagingExtensionAction, ): Promise { if (action.botMessagePreviewAction) { switch (action.botMessagePreviewAction) { @@ -504,7 +504,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsMessagingExtensionSubmitAction( _context: TurnContext, - _action: MessagingExtensionAction + _action: MessagingExtensionAction, ): Promise { throw new Error('NotImplemented'); } @@ -519,7 +519,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsMessagingExtensionBotMessagePreviewEdit( _context: TurnContext, - _action: MessagingExtensionAction + _action: MessagingExtensionAction, ): Promise { throw new Error('NotImplemented'); } @@ -534,7 +534,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsMessagingExtensionBotMessagePreviewSend( _context: TurnContext, - _action: MessagingExtensionAction + _action: MessagingExtensionAction, ): Promise { throw new Error('NotImplemented'); } @@ -548,7 +548,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsMessagingExtensionFetchTask( _context: TurnContext, - _action: MessagingExtensionAction + _action: MessagingExtensionAction, ): Promise { throw new Error('NotImplemented'); } @@ -562,7 +562,7 @@ export class TeamsActivityHandler extends ActivityHandler { */ protected async handleTeamsMessagingExtensionConfigurationQuerySettingUrl( _context: TurnContext, - _query: MessagingExtensionQuery + _query: MessagingExtensionQuery, ): Promise { throw new Error('NotImplemented'); } @@ -967,8 +967,8 @@ export class TeamsActivityHandler extends ActivityHandler { membersAdded: TeamsChannelAccount[], teamInfo: TeamInfo, context: TurnContext, - next: () => Promise - ) => Promise + next: () => Promise, + ) => Promise, ): this { return this.on('TeamsMembersAdded', async (context, next) => { const teamsChannelData = context.activity.channelData as TeamsChannelData; @@ -988,8 +988,8 @@ export class TeamsActivityHandler extends ActivityHandler { membersRemoved: TeamsChannelAccount[], teamInfo: TeamInfo, context: TurnContext, - next: () => Promise - ) => Promise + next: () => Promise, + ) => Promise, ): this { return this.on('TeamsMembersRemoved', async (context, next) => { const teamsChannelData = context.activity.channelData as TeamsChannelData; @@ -1008,8 +1008,8 @@ export class TeamsActivityHandler extends ActivityHandler { channelInfo: ChannelInfo, teamInfo: TeamInfo, context: TurnContext, - next: () => Promise - ) => Promise + next: () => Promise, + ) => Promise, ): this { return this.on('TeamsChannelCreated', async (context, next) => { const teamsChannelData = context.activity.channelData as TeamsChannelData; @@ -1028,8 +1028,8 @@ export class TeamsActivityHandler extends ActivityHandler { channelInfo: ChannelInfo, teamInfo: TeamInfo, context: TurnContext, - next: () => Promise - ) => Promise + next: () => Promise, + ) => Promise, ): this { return this.on('TeamsChannelDeleted', async (context, next) => { const teamsChannelData = context.activity.channelData as TeamsChannelData; @@ -1048,8 +1048,8 @@ export class TeamsActivityHandler extends ActivityHandler { channelInfo: ChannelInfo, teamInfo: TeamInfo, context: TurnContext, - next: () => Promise - ) => Promise + next: () => Promise, + ) => Promise, ): this { return this.on('TeamsChannelRenamed', async (context, next) => { const teamsChannelData = context.activity.channelData as TeamsChannelData; @@ -1064,7 +1064,7 @@ export class TeamsActivityHandler extends ActivityHandler { * @returns A promise that represents the work queued. */ onTeamsTeamArchivedEvent( - handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise + handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise, ): this { return this.on('TeamsTeamArchived', async (context, next) => { const teamsChannelData = context.activity.channelData as TeamsChannelData; @@ -1079,7 +1079,7 @@ export class TeamsActivityHandler extends ActivityHandler { * @returns A promise that represents the work queued. */ onTeamsTeamDeletedEvent( - handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise + handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise, ): this { return this.on('TeamsTeamDeleted', async (context, next) => { const teamsChannelData = context.activity.channelData as TeamsChannelData; @@ -1094,7 +1094,7 @@ export class TeamsActivityHandler extends ActivityHandler { * @returns A promise that represents the work queued. */ onTeamsTeamHardDeletedEvent( - handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise + handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise, ): this { return this.on('TeamsTeamHardDeleted', async (context, next) => { const teamsChannelData = context.activity.channelData as TeamsChannelData; @@ -1113,8 +1113,8 @@ export class TeamsActivityHandler extends ActivityHandler { channelInfo: ChannelInfo, teamInfo: TeamInfo, context: TurnContext, - next: () => Promise - ) => Promise + next: () => Promise, + ) => Promise, ): this { return this.on('TeamsChannelRestored', async (context, next) => { const teamsChannelData = context.activity.channelData as TeamsChannelData; @@ -1129,7 +1129,7 @@ export class TeamsActivityHandler extends ActivityHandler { * @returns A promise that represents the work queued. */ onTeamsTeamRenamedEvent( - handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise + handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise, ): this { return this.on('TeamsTeamRenamed', async (context, next) => { const teamsChannelData = context.activity.channelData as TeamsChannelData; @@ -1144,7 +1144,7 @@ export class TeamsActivityHandler extends ActivityHandler { * @returns A promise that represents the work queued. */ onTeamsTeamRestoredEvent( - handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise + handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise, ): this { return this.on('TeamsTeamRestored', async (context, next) => { const teamsChannelData = context.activity.channelData as TeamsChannelData; @@ -1159,7 +1159,7 @@ export class TeamsActivityHandler extends ActivityHandler { * @returns A promise that represents the work queued. */ onTeamsTeamUnarchivedEvent( - handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise + handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise) => Promise, ): this { return this.on('TeamsTeamUnarchived', async (context, next) => { const teamsChannelData = context.activity.channelData as TeamsChannelData; @@ -1172,7 +1172,6 @@ export class TeamsActivityHandler extends ActivityHandler { * * @param context The context object for the current turn. * @returns A promise that represents the work queued. - * * @remarks * Override this method to support channel-specific behavior across multiple channels or to add * custom event sub-type events. @@ -1258,7 +1257,7 @@ export class TeamsActivityHandler extends ActivityHandler { * @returns A promise that represents the work queued. */ onTeamsMeetingStartEvent( - handler: (meeting: MeetingStartEventDetails, context: TurnContext, next: () => Promise) => Promise + handler: (meeting: MeetingStartEventDetails, context: TurnContext, next: () => Promise) => Promise, ): this { return this.on('TeamsMeetingStart', async (context, next) => { const meeting = TeamsMeetingStartT.parse(context.activity.value); @@ -1271,7 +1270,7 @@ export class TeamsActivityHandler extends ActivityHandler { title: meeting.Title, }, context, - next + next, ); }); } @@ -1283,7 +1282,7 @@ export class TeamsActivityHandler extends ActivityHandler { * @returns A promise that represents the work queued. */ onTeamsMeetingEndEvent( - handler: (meeting: MeetingEndEventDetails, context: TurnContext, next: () => Promise) => Promise + handler: (meeting: MeetingEndEventDetails, context: TurnContext, next: () => Promise) => Promise, ): this { return this.on('TeamsMeetingEnd', async (context, next) => { const meeting = TeamsMeetingEndT.parse(context.activity.value); @@ -1296,7 +1295,7 @@ export class TeamsActivityHandler extends ActivityHandler { title: meeting.Title, }, context, - next + next, ); }); } @@ -1308,7 +1307,7 @@ export class TeamsActivityHandler extends ActivityHandler { * @returns A promise that represents the work queued. */ onTeamsReadReceiptEvent( - handler: (receiptInfo: ReadReceiptInfo, context: TurnContext, next: () => Promise) => Promise + handler: (receiptInfo: ReadReceiptInfo, context: TurnContext, next: () => Promise) => Promise, ): this { return this.on('TeamsReadReceipt', async (context, next) => { const receiptInfo = context.activity.value; @@ -1326,8 +1325,8 @@ export class TeamsActivityHandler extends ActivityHandler { handler: ( meeting: MeetingParticipantsEventDetails, context: TurnContext, - next: () => Promise - ) => Promise + next: () => Promise, + ) => Promise, ): this { return this.on('TeamsMeetingParticipantsJoin', async (context, next) => { const meeting = context.activity.value; @@ -1336,7 +1335,7 @@ export class TeamsActivityHandler extends ActivityHandler { members: meeting?.members, }, context, - next + next, ); }); } @@ -1351,8 +1350,8 @@ export class TeamsActivityHandler extends ActivityHandler { handler: ( meeting: MeetingParticipantsEventDetails, context: TurnContext, - next: () => Promise - ) => Promise + next: () => Promise, + ) => Promise, ): this { return this.on('TeamsMeetingParticipantsLeave', async (context, next) => { const meeting = context.activity.value; @@ -1361,7 +1360,7 @@ export class TeamsActivityHandler extends ActivityHandler { members: meeting?.members, }, context, - next + next, ); }); } diff --git a/libraries/botbuilder/src/teamsActivityHelpers.ts b/libraries/botbuilder/src/teamsActivityHelpers.ts index 85b12f7fa9..9004f6be8b 100644 --- a/libraries/botbuilder/src/teamsActivityHelpers.ts +++ b/libraries/botbuilder/src/teamsActivityHelpers.ts @@ -119,7 +119,7 @@ export function teamsGetChannelId(activity: Activity): string | null { export function teamsNotifyUser( activity: Partial, alertInMeeting = false, - externalResourceUrl?: string + externalResourceUrl?: string, ): void { validateActivity(activity); diff --git a/libraries/botbuilder/src/teamsInfo.ts b/libraries/botbuilder/src/teamsInfo.ts index 736c143086..11a4ebdbd5 100644 --- a/libraries/botbuilder/src/teamsInfo.ts +++ b/libraries/botbuilder/src/teamsInfo.ts @@ -58,7 +58,7 @@ export class TeamsInfo { context: TurnContext, meetingId?: string, participantId?: string, - tenantId?: string + tenantId?: string, ): Promise { if (!context) { throw new Error('context is required.'); @@ -151,7 +151,7 @@ export class TeamsInfo { context: TurnContext, activity: Activity, teamsChannelId: string, - botAppId?: string + botAppId?: string, ): Promise<[ConversationReference, string]> { if (!context) { throw new Error('TurnContext cannot be null'); @@ -188,11 +188,11 @@ export class TeamsInfo { async (turnContext) => { conversationReference = TurnContext.getConversationReference(turnContext.activity); newActivityId = turnContext.activity.id; - } + }, ); } else { const connectorClient = (context.adapter as BotFrameworkAdapter).createConnectorClient( - context.activity.serviceUrl + context.activity.serviceUrl, ); const conversationResourceResponse = await connectorClient.conversations.createConversation(convoParams); conversationReference = TurnContext.getConversationReference(context.activity); @@ -225,7 +225,6 @@ export class TeamsInfo { * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @returns The list of [TeamsChannelAccount](xref:botframework-schema.TeamsChannelAccount). - * * @deprecated Use `getPagedTeamMembers` instead. */ static async getMembers(context: TurnContext): Promise { @@ -250,7 +249,7 @@ export class TeamsInfo { static async getPagedMembers( context: TurnContext, pageSize?: number, - continuationToken?: string + continuationToken?: string, ): Promise { const teamId = this.getTeamId(context); const options: TeamsConnectorModels.ConversationsGetConversationPagedMembersOptionalParams = { @@ -290,7 +289,6 @@ export class TeamsInfo { * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn. * @param teamId ID of the Teams team. * @returns The list of [TeamsChannelAccount](xref:botframework-schema.TeamsChannelAccount) of the members. - * * @deprecated Use `getPagedTeamMembers` instead. */ static async getTeamMembers(context: TurnContext, teamId?: string): Promise { @@ -314,7 +312,7 @@ export class TeamsInfo { context: TurnContext, teamId?: string, pageSize?: number, - continuationToken?: string + continuationToken?: string, ): Promise { const t = teamId || this.getTeamId(context); if (!t) { @@ -357,7 +355,7 @@ export class TeamsInfo { static async sendMeetingNotification( context: TurnContext, notification: MeetingNotification, - meetingId?: string + meetingId?: string, ): Promise { const activity = context.activity; @@ -386,7 +384,7 @@ export class TeamsInfo { context: TurnContext, activity: Activity, tenantId: string, - members: TeamsMember[] + members: TeamsMember[], ): Promise { if (!activity) { throw new Error('activity is required.'); @@ -412,7 +410,7 @@ export class TeamsInfo { static async sendMessageToAllUsersInTenant( context: TurnContext, activity: Activity, - tenantId: string + tenantId: string, ): Promise { if (!activity) { throw new Error('activity is required.'); @@ -437,7 +435,7 @@ export class TeamsInfo { context: TurnContext, activity: Activity, tenantId: string, - teamId: string + teamId: string, ): Promise { if (!activity) { throw new Error('activity is required.'); @@ -452,7 +450,7 @@ export class TeamsInfo { return await this.getTeamsConnectorClient(context).teams.sendMessageToAllUsersInTeam( activity, tenantId, - teamId + teamId, ); } @@ -469,7 +467,7 @@ export class TeamsInfo { context: TurnContext, activity: Activity, tenantId: string, - members: TeamsMember[] + members: TeamsMember[], ): Promise { if (!activity) { throw new Error('activity is required.'); @@ -484,7 +482,7 @@ export class TeamsInfo { return await this.getTeamsConnectorClient(context).teams.sendMessageToListOfChannels( activity, tenantId, - members + members, ); } @@ -538,15 +536,14 @@ export class TeamsInfo { */ private static async getMembersInternal( connectorClient: ConnectorClient, - conversationId: string + conversationId: string, ): Promise { if (!conversationId) { throw new Error('The getMembers operation needs a valid conversationId.'); } - const teamMembers: ChannelAccount[] = await connectorClient.conversations.getConversationMembers( - conversationId - ); + const teamMembers: ChannelAccount[] = + await connectorClient.conversations.getConversationMembers(conversationId); teamMembers.forEach((member): void => { member.aadObjectId = (member as any).objectId; }); @@ -560,7 +557,7 @@ export class TeamsInfo { private static async getPagedMembersInternal( connectorClient: ConnectorClient, conversationId: string, - options: TeamsConnectorModels.ConversationsGetConversationPagedMembersOptionalParams + options: TeamsConnectorModels.ConversationsGetConversationPagedMembersOptionalParams, ): Promise { if (!conversationId) { throw new Error('The getPagedMembers operation needs a valid conversationId.'); @@ -568,7 +565,7 @@ export class TeamsInfo { const pagedMembersResult: PagedMembersResult = await connectorClient.conversations.getConversationPagedMembers( conversationId, - options + options, ); const teamsPagedMembersResult: TeamsPagedMembersResult = { @@ -585,7 +582,7 @@ export class TeamsInfo { private static async getMemberInternal( connectorClient: ConnectorClient, conversationId: string, - userId: string + userId: string, ): Promise { if (!conversationId) { throw new Error('The getMember operation needs a valid conversationId.'); @@ -597,7 +594,7 @@ export class TeamsInfo { const teamMember: ChannelAccount = await connectorClient.conversations.getConversationMember( conversationId, - userId + userId, ); return teamMember as TeamsChannelAccount; diff --git a/libraries/botbuilder/src/zod.ts b/libraries/botbuilder/src/zod.ts index 5a90ebd52a..00f39909bf 100644 --- a/libraries/botbuilder/src/zod.ts +++ b/libraries/botbuilder/src/zod.ts @@ -16,7 +16,7 @@ export const INodeSocketT = z.custom( typeof val.once === 'function' && typeof val.pipe === 'function' && typeof val.write === 'function', - { message: 'INodeSocket' } + { message: 'INodeSocket' }, ); export const LogicT = z.custom<(context: TurnContext) => Promise>((val) => typeof val === 'function'); diff --git a/libraries/botbuilder/tests/botFrameworkAdapter.test.js b/libraries/botbuilder/tests/botFrameworkAdapter.test.js index ca5d995d69..96f5ef0a0d 100644 --- a/libraries/botbuilder/tests/botFrameworkAdapter.test.js +++ b/libraries/botbuilder/tests/botFrameworkAdapter.test.js @@ -89,7 +89,7 @@ class AdapterUnderTest extends BotFrameworkAdapter { assert.strictEqual( authHeader, this.expectAuthHeader, - 'authenticateRequestInternal() not passed expected authHeader.' + 'authenticateRequestInternal() not passed expected authHeader.', ); return this.failAuth ? Promise.reject(new Error('failed auth')) : Promise.resolve({ claims: [] }); } @@ -256,6 +256,7 @@ function createActivity() { describe('BotFrameworkAdapter', function () { let sandbox; + beforeEach(function () { sandbox = sinon.createSandbox(); }); @@ -344,7 +345,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( adapter.webSocketFactory, 'test-web-socket', - 'Adapter should have read settings.webSocketFactory' + 'Adapter should have read settings.webSocketFactory', ); }); }); @@ -368,7 +369,7 @@ describe('BotFrameworkAdapter', function () { const incoming = TurnContext.applyConversationReference( { type: 'message', text: 'foo', callerId: 'foo' }, reference, - true + true, ); incoming.channelId = 'msteams'; @@ -388,7 +389,7 @@ describe('BotFrameworkAdapter', function () { const incoming = TurnContext.applyConversationReference( { type: 'message', text: 'foo', callerId: 'foo' }, reference, - true + true, ); incoming.channelId = 'msteams'; @@ -407,7 +408,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest({ appId: 'bogusApp', appPassword: 'bogusPassword' }); await assert.rejects( adapter.testAuthenticateRequest(req, ''), - new Error('Unauthorized Access. Request is not authorized') + new Error('Unauthorized Access. Request is not authorized'), ); }); }); @@ -483,7 +484,7 @@ describe('BotFrameworkAdapter', function () { headers: new HttpHeaders(), readableStreamBody: undefined, bodyAsText: '', - }) + }), ); const adapter = new BotFrameworkAdapter({ clientOptions: { httpClient: { sendRequest } } }); @@ -497,14 +498,14 @@ describe('BotFrameworkAdapter', function () { assert( sendRequest.called, - 'sendRequest on HttpClient provided to BotFrameworkAdapter.clientOptions was not called when sending an activity' + 'sendRequest on HttpClient provided to BotFrameworkAdapter.clientOptions was not called when sending an activity', ); const [request] = sendRequest.args[0]; assert.deepStrictEqual( JSON.parse(request.body), outgoingMessageLocale, - 'sentActivity should flow through custom httpClient.sendRequest' + 'sentActivity should flow through custom httpClient.sendRequest', ); }); @@ -519,7 +520,7 @@ describe('BotFrameworkAdapter', function () { assert( connectorClient._requestPolicyFactories.find((policy) => policy === setUserAgent), - 'requestPolicyFactories from clientOptions parameter is not used.' + 'requestPolicyFactories from clientOptions parameter is not used.', ); }); }); @@ -555,7 +556,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new BotFrameworkAdapter(); await assert.rejects( adapter.createConnectorClientWithIdentity('https://serviceurl.com'), - new Error('BotFrameworkAdapter.createConnectorClientWithIdentity(): invalid identity parameter.') + new Error('BotFrameworkAdapter.createConnectorClientWithIdentity(): invalid identity parameter.'), ); }); @@ -575,7 +576,7 @@ describe('BotFrameworkAdapter', function () { .mock(adapter) .expects('buildCredentials') .callsFake((appId, oAuthScope) => - Promise.resolve(new MicrosoftAppCredentials(appId, '', undefined, oAuthScope)) + Promise.resolve(new MicrosoftAppCredentials(appId, '', undefined, oAuthScope)), ) .once(); @@ -606,7 +607,7 @@ describe('BotFrameworkAdapter', function () { .mock(adapter) .expects('buildCredentials') .callsFake((appId, oAuthScope) => - Promise.resolve(new MicrosoftAppCredentials(appId, '', undefined, oAuthScope)) + Promise.resolve(new MicrosoftAppCredentials(appId, '', undefined, oAuthScope)), ) .once(); @@ -635,7 +636,7 @@ describe('BotFrameworkAdapter', function () { .mock(adapter) .expects('buildCredentials') .callsFake((appId, oAuthScope) => - Promise.resolve(new MicrosoftAppCredentials(appId, '', undefined, oAuthScope)) + Promise.resolve(new MicrosoftAppCredentials(appId, '', undefined, oAuthScope)), ) .once(); @@ -655,7 +656,7 @@ describe('BotFrameworkAdapter', function () { const connector = await adapter.createConnectorClientWithIdentity( 'https://serviceurl.com', - new ClaimsIdentity([{ type: AuthenticationConstants.AppIdClaim, value: appId }]) + new ClaimsIdentity([{ type: AuthenticationConstants.AppIdClaim, value: appId }]), ); const credentials = connector.credentials; @@ -673,7 +674,7 @@ describe('BotFrameworkAdapter', function () { const connector = await adapter.createConnectorClientWithIdentity( 'https://serviceurl.com', - new ClaimsIdentity([{ type: AuthenticationConstants.AppIdClaim, value: appId }]) + new ClaimsIdentity([{ type: AuthenticationConstants.AppIdClaim, value: appId }]), ); const credentials = connector.credentials; @@ -692,7 +693,7 @@ describe('BotFrameworkAdapter', function () { const connector = await adapter.createConnectorClientWithIdentity( 'https://serviceurl.com', - new ClaimsIdentity([{ type: AuthenticationConstants.AudienceClaim, value: appId }]) + new ClaimsIdentity([{ type: AuthenticationConstants.AudienceClaim, value: appId }]), ); const credentials = connector.credentials; @@ -726,7 +727,7 @@ describe('BotFrameworkAdapter', function () { await context.sendActivity({ type: 'invokeResponse', text: '1st message' }); await context.sendActivity({ type: 'invokeResponse', text: '2nd message' }); }, - { activity } + { activity }, ); assertResponse(response, StatusCodes.OK, true); @@ -743,7 +744,7 @@ describe('BotFrameworkAdapter', function () { text: '2nd message', type: 'invokeResponse', }, - ] + ], ); }); @@ -760,7 +761,7 @@ describe('BotFrameworkAdapter', function () { await context.sendActivity({ type: 'invokeResponse', text: 'message' }); await context.sendActivity(testTraceMessage); }, - { activity } + { activity }, ); assertResponse(response, StatusCodes.OK, true); @@ -773,7 +774,7 @@ describe('BotFrameworkAdapter', function () { text: 'message', type: 'invokeResponse', }, - ] + ], ); }); @@ -790,7 +791,7 @@ describe('BotFrameworkAdapter', function () { await context.sendActivity({ type: 'invokeResponse', text: 'message' }); await context.sendActivity(testTraceMessage); }, - { activity } + { activity }, ); assertResponse(response, StatusCodes.OK, true); @@ -798,7 +799,7 @@ describe('BotFrameworkAdapter', function () { assert.deepStrictEqual( response.body.activities.map(({ type }) => type), - ['invokeResponse', 'trace'] + ['invokeResponse', 'trace'], ); }); @@ -843,7 +844,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( typeof context.activity.timestamp, 'object', - "'context.activity.timestamp' is not a date" + "'context.activity.timestamp' is not a date", ); assert(context.activity.timestamp instanceof Date, "'context.activity.timestamp' is not a date"); @@ -851,15 +852,15 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( typeof context.activity.localTimestamp, 'object', - "'context.activity.localTimestamp' is not a date" + "'context.activity.localTimestamp' is not a date", ); assert( context.activity.localTimestamp instanceof Date, - "'context.activity.localTimestamp' is not a date" + "'context.activity.localTimestamp' is not a date", ); }, - { activity } + { activity }, ); assertResponse(response, StatusCodes.OK); @@ -874,7 +875,7 @@ describe('BotFrameworkAdapter', function () { assert(!fake.called); assertResponse(response, 400, true); return true; - } + }, ); }); @@ -886,7 +887,7 @@ describe('BotFrameworkAdapter', function () { assert(!fake.called); assertResponse(response, 400, true); return true; - } + }, ); }); @@ -894,7 +895,7 @@ describe('BotFrameworkAdapter', function () { const activity = TurnContext.applyConversationReference( { type: 'message', text: 'foo', channelData: { tenant: { id: '1234' } } }, reference, - true + true, ); activity.channelId = 'msteams'; @@ -903,10 +904,10 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( context.activity.conversation.tenantId, '1234', - 'should have copied tenant id from channelData to conversation address' + 'should have copied tenant id from channelData to conversation address', ); }, - { activity } + { activity }, ); assertResponse(response, StatusCodes.OK); @@ -917,7 +918,7 @@ describe('BotFrameworkAdapter', function () { const activity = TurnContext.applyConversationReference( { type: 'message', text: 'foo', semanticAction: { state: 'start' } }, reference, - true + true, ); activity.channelId = 'msteams'; @@ -925,7 +926,7 @@ describe('BotFrameworkAdapter', function () { (context) => { assert(context.activity.semanticAction.state === 'start'); }, - { activity } + { activity }, ); assertResponse(response, StatusCodes.OK); @@ -936,7 +937,7 @@ describe('BotFrameworkAdapter', function () { const processIncoming = async ( incoming, handler, - { adapterArgs = {}, authDisabled = false, claims = [] } = {} + { adapterArgs = {}, authDisabled = false, claims = [] } = {}, ) => { // Sets up expectation for JWT validation to pass back claims mockReturns(JwtTokenValidation, 'authenticateRequest', new ClaimsIdentity(claims, true)); @@ -965,7 +966,7 @@ describe('BotFrameworkAdapter', function () { const incoming = TurnContext.applyConversationReference( { type: 'message', text: 'foo', callerId: 'foo' }, reference, - true + true, ); incoming.channelId = 'msteams'; @@ -986,7 +987,7 @@ describe('BotFrameworkAdapter', function () { (context) => { assert.strictEqual( context.activity.callerId, - `${CallerIdConstants.BotToBotPrefix}${skillConsumerAppId}` + `${CallerIdConstants.BotToBotPrefix}${skillConsumerAppId}`, ); }, { @@ -995,7 +996,7 @@ describe('BotFrameworkAdapter', function () { { type: AuthenticationConstants.AppIdClaim, value: skillConsumerAppId }, { type: AuthenticationConstants.VersionClaim, value: '1.0' }, ], - } + }, ); }); @@ -1003,7 +1004,7 @@ describe('BotFrameworkAdapter', function () { const incoming = TurnContext.applyConversationReference( { type: 'message', text: 'foo', callerId: 'foo' }, reference, - true + true, ); incoming.channelId = 'msteams'; @@ -1012,7 +1013,7 @@ describe('BotFrameworkAdapter', function () { (context) => { assert.strictEqual(context.activity.callerId, undefined); }, - { authDisabled: true } + { authDisabled: true }, ); }); @@ -1033,7 +1034,7 @@ describe('BotFrameworkAdapter', function () { { type: AuthenticationConstants.AudienceClaim, value: skillAppId }, { type: AuthenticationConstants.VersionClaim, value: '1.0' }, ], - } + }, ); }); }); @@ -1042,7 +1043,7 @@ describe('BotFrameworkAdapter', function () { const incoming = TurnContext.applyConversationReference( { type: 'message', text: 'foo', callerId: 'foo' }, reference, - true + true, ); incoming.channelId = 'msteams'; @@ -1063,7 +1064,7 @@ describe('BotFrameworkAdapter', function () { assert(!fake.called); return true; - } + }, ); }); @@ -1078,7 +1079,7 @@ describe('BotFrameworkAdapter', function () { assert(fake.called); return true; - } + }, ); }); @@ -1086,7 +1087,7 @@ describe('BotFrameworkAdapter', function () { const createConversation = async ( reference, handler, - { adapterArgs, createConversationParams, testAdapterArgs } = {} + { adapterArgs, createConversationParams, testAdapterArgs } = {}, ) => { const adapter = new AdapterUnderTest(adapterArgs, testAdapterArgs); @@ -1120,7 +1121,7 @@ describe('BotFrameworkAdapter', function () { assert(context.activity.conversation, 'activity has no conversation'); assert(context.activity.conversation.isGroup, 'activity isGroup is not true'); }, - { createConversationParams: { isGroup: true } } + { createConversationParams: { isGroup: true } }, ); }); @@ -1133,17 +1134,17 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( context.activity.conversation.id, 'convo2', - 'request has invalid conversation.id.' + 'request has invalid conversation.id.', ); assert.strictEqual( context.activity.serviceUrl, 'https://example.org/channel2', - 'request has invalid conversation.id.' + 'request has invalid conversation.id.', ); }, { testAdapterArgs: { newServiceUrl: 'https://example.org/channel2' }, - } + }, ); }); @@ -1158,7 +1159,7 @@ describe('BotFrameworkAdapter', function () { assert(!fake.called); return true; - } + }, ); }); @@ -1179,13 +1180,13 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( context.activity.conversation.tenantId, tenantReference.conversation.tenantId, - 'request has invalid tenantId on conversation.' + 'request has invalid tenantId on conversation.', ); assert.strictEqual( context.activity.channelData.tenant.id, tenantReference.conversation.tenantId, - 'request has invalid tenantId in channelData.' + 'request has invalid tenantId in channelData.', ); }); }); @@ -1198,7 +1199,7 @@ describe('BotFrameworkAdapter', function () { const responses = await adapter.sendActivities(context, [outgoingMessage]); assert.deepStrictEqual( responses.map(({ id }) => id), - ['5678'] + ['5678'], ); }); @@ -1251,7 +1252,7 @@ describe('BotFrameworkAdapter', function () { it('should return bots invokeResponse', async function () { const { response, verify } = await processActivity( (context) => context.sendActivity({ type: 'invokeResponse', value: { status: 200, body: 'body' } }), - { activity: incomingInvoke } + { activity: incomingInvoke }, ); assertResponse(response, StatusCodes.OK, true); verify(); @@ -1266,7 +1267,7 @@ describe('BotFrameworkAdapter', function () { assert(fake.called); return true; - } + }, ); }); @@ -1298,7 +1299,7 @@ describe('BotFrameworkAdapter', function () { const responses = await adapter.sendActivities(context, [copy]); assert.deepStrictEqual( responses.map(({ id }) => id), - ['5678'] + ['5678'], ); }); @@ -1404,7 +1405,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( testEndpoint, connector.ChannelValidation.OpenIdMetadataEndpoint, - 'ChannelValidation.OpenIdMetadataEndpoint was not set.' + 'ChannelValidation.OpenIdMetadataEndpoint was not set.', ); }); @@ -1415,7 +1416,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( testEndpoint, connector.GovernmentChannelValidation.OpenIdMetadataEndpoint, - 'GovernmentChannelValidation.OpenIdMetadataEndpoint was not set.' + 'GovernmentChannelValidation.OpenIdMetadataEndpoint was not set.', ); }); }); @@ -1431,7 +1432,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.deleteConversationMember({ activity: {} }), - new Error('BotFrameworkAdapter.deleteConversationMember(): missing serviceUrl') + new Error('BotFrameworkAdapter.deleteConversationMember(): missing serviceUrl'), ); }); @@ -1439,7 +1440,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.deleteConversationMember({ activity: { serviceUrl: 'https://test.com' } }), - new Error('BotFrameworkAdapter.deleteConversationMember(): missing conversation or conversation.id') + new Error('BotFrameworkAdapter.deleteConversationMember(): missing conversation or conversation.id'), ); }); @@ -1447,7 +1448,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.deleteConversationMember({ activity: { serviceUrl: 'https://test.com', conversation: {} } }), - new Error('BotFrameworkAdapter.deleteConversationMember(): missing conversation or conversation.id') + new Error('BotFrameworkAdapter.deleteConversationMember(): missing conversation or conversation.id'), ); }); @@ -1461,7 +1462,7 @@ describe('BotFrameworkAdapter', function () { await adapter.deleteConversationMember( { activity: { serviceUrl: 'https://test.com', conversation: { id: 'convo1' } } }, - 'test-member' + 'test-member', ); sandbox.verify(); @@ -1471,7 +1472,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getActivityMembers({ activity: {} }), - new Error('BotFrameworkAdapter.getActivityMembers(): missing serviceUrl') + new Error('BotFrameworkAdapter.getActivityMembers(): missing serviceUrl'), ); }); @@ -1479,7 +1480,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getActivityMembers({ activity: { serviceUrl: 'https://test.com' } }), - new Error('BotFrameworkAdapter.getActivityMembers(): missing conversation or conversation.id') + new Error('BotFrameworkAdapter.getActivityMembers(): missing conversation or conversation.id'), ); }); @@ -1487,7 +1488,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getActivityMembers({ activity: { serviceUrl: 'https://test.com', conversation: {} } }), - new Error('BotFrameworkAdapter.getActivityMembers(): missing conversation or conversation.id') + new Error('BotFrameworkAdapter.getActivityMembers(): missing conversation or conversation.id'), ); }); @@ -1497,7 +1498,7 @@ describe('BotFrameworkAdapter', function () { adapter.getActivityMembers({ activity: { serviceUrl: 'https://test.com', conversation: { id: '1' } }, }), - new Error('BotFrameworkAdapter.getActivityMembers(): missing both activityId and context.activity.id') + new Error('BotFrameworkAdapter.getActivityMembers(): missing both activityId and context.activity.id'), ); }); @@ -1512,7 +1513,7 @@ describe('BotFrameworkAdapter', function () { await adapter.getActivityMembers( { activity: { serviceUrl: 'https://test.com', conversation: { id: 'convo1' } } }, - 'activityId' + 'activityId', ); sandbox.verify(); @@ -1522,7 +1523,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getConversationMembers({ activity: {} }), - new Error('BotFrameworkAdapter.getConversationMembers(): missing serviceUrl') + new Error('BotFrameworkAdapter.getConversationMembers(): missing serviceUrl'), ); }); @@ -1530,7 +1531,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getConversationMembers({ activity: { serviceUrl: 'https://test.com' } }), - new Error('BotFrameworkAdapter.getConversationMembers(): missing conversation or conversation.id') + new Error('BotFrameworkAdapter.getConversationMembers(): missing conversation or conversation.id'), ); }); @@ -1538,7 +1539,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getConversationMembers({ activity: { serviceUrl: 'https://test.com', conversation: {} } }), - new Error('BotFrameworkAdapter.getConversationMembers(): missing conversation or conversation.id') + new Error('BotFrameworkAdapter.getConversationMembers(): missing conversation or conversation.id'), ); }); @@ -1561,7 +1562,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getUserToken({ activity: {}, turnState: new Map() }), - new Error('BotFrameworkAdapter.getUserToken(): missing from or from.id') + new Error('BotFrameworkAdapter.getUserToken(): missing from or from.id'), ); }); @@ -1569,7 +1570,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getUserToken({ activity: { from: {} }, turnState: new Map() }), - new Error('BotFrameworkAdapter.getUserToken(): missing from or from.id') + new Error('BotFrameworkAdapter.getUserToken(): missing from or from.id'), ); }); @@ -1577,7 +1578,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getUserToken({ activity: { from: { id: 'some id' } }, turnState: new Map() }), - new Error('getUserToken() requires a connectionName but none was provided.') + new Error('getUserToken() requires a connectionName but none was provided.'), ); }); @@ -1590,7 +1591,7 @@ describe('BotFrameworkAdapter', function () { const token = await adapter.getUserToken( { activity: { channelId: 'The Facebook', from: { id: 'some id' } }, turnState: new Map() }, - 'aConnectionName' + 'aConnectionName', ); sandbox.verify(); @@ -1608,7 +1609,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.signOutUser({ activity: {}, turnState: new Map() }), - new Error('BotFrameworkAdapter.signOutUser(): missing from or from.id') + new Error('BotFrameworkAdapter.signOutUser(): missing from or from.id'), ); }); @@ -1616,7 +1617,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.signOutUser({ activity: { from: {} }, turnState: new Map() }), - new Error('BotFrameworkAdapter.signOutUser(): missing from or from.id') + new Error('BotFrameworkAdapter.signOutUser(): missing from or from.id'), ); }); @@ -1637,7 +1638,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getAadTokens({ activity: {}, turnState: new Map() }), - new Error('BotFrameworkAdapter.getAadTokens(): missing from or from.id') + new Error('BotFrameworkAdapter.getAadTokens(): missing from or from.id'), ); }); @@ -1645,7 +1646,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getAadTokens({ activity: { from: {} }, turnState: new Map() }), - new Error('BotFrameworkAdapter.getAadTokens(): missing from or from.id') + new Error('BotFrameworkAdapter.getAadTokens(): missing from or from.id'), ); }); @@ -1693,9 +1694,9 @@ describe('BotFrameworkAdapter', function () { context, 'aConnectionName', new MicrosoftAppCredentials('abc', 'abc'), - 'invalidId' + 'invalidId', ), - ReferenceError("cannot retrieve OAuth signin link for a user that's different from the conversation") + ReferenceError("cannot retrieve OAuth signin link for a user that's different from the conversation"), ); }); @@ -1711,7 +1712,7 @@ describe('BotFrameworkAdapter', function () { const response = await adapter.getSignInLink( context, 'aConnectionName', - new MicrosoftAppCredentials('abc', 'abc') + new MicrosoftAppCredentials('abc', 'abc'), ); assert(response, mockedUrl); verify(); @@ -1724,7 +1725,7 @@ describe('BotFrameworkAdapter', function () { 'aConnectionName', new MicrosoftAppCredentials('abc', 'abc'), incomingMessage.from.id, - 'http://finalredirect.com' + 'http://finalredirect.com', ); assert(response, mockedUrl); verify(); @@ -1755,7 +1756,7 @@ describe('BotFrameworkAdapter', function () { const { adapter, context } = getMockedAdapter(); await assert.rejects( adapter.getSignInResource(context), - new Error('getUserToken() requires a connectionName but none was provided.') + new Error('getUserToken() requires a connectionName but none was provided.'), ); }); @@ -1766,7 +1767,7 @@ describe('BotFrameworkAdapter', function () { const { adapter, context } = getMockedAdapter(activity); await assert.rejects( adapter.getSignInResource(context, 'TestConnectionName'), - new Error('BotFrameworkAdapter.getSignInResource(): missing from or from.id') + new Error('BotFrameworkAdapter.getSignInResource(): missing from or from.id'), ); }); @@ -1777,7 +1778,7 @@ describe('BotFrameworkAdapter', function () { const { adapter, context } = getMockedAdapter(activity); await assert.rejects( adapter.getSignInResource(context, 'TestConnectionName'), - new Error('BotFrameworkAdapter.getSignInResource(): missing from or from.id') + new Error('BotFrameworkAdapter.getSignInResource(): missing from or from.id'), ); }); @@ -1786,8 +1787,8 @@ describe('BotFrameworkAdapter', function () { await assert.rejects( adapter.getSignInResource(context, 'TestConnectionName', 'OtherUserId'), new Error( - 'BotFrameworkAdapter.getSiginInResource(): cannot get signin resource for a user that is different from the conversation' - ) + 'BotFrameworkAdapter.getSiginInResource(): cannot get signin resource for a user that is different from the conversation', + ), ); }); @@ -1815,7 +1816,7 @@ describe('BotFrameworkAdapter', function () { const { adapter, context } = getMockedAdapter(); await assert.rejects( adapter.exchangeToken(context), - new Error('exchangeToken() requires a connectionName but none was provided.') + new Error('exchangeToken() requires a connectionName but none was provided.'), ); }); @@ -1823,7 +1824,7 @@ describe('BotFrameworkAdapter', function () { const { adapter, context } = getMockedAdapter(); await assert.rejects( adapter.exchangeToken(context, 'TestConnectionName'), - new Error('exchangeToken() requires an userId but none was provided.') + new Error('exchangeToken() requires an userId but none was provided.'), ); }); @@ -1832,8 +1833,8 @@ describe('BotFrameworkAdapter', function () { await assert.rejects( adapter.exchangeToken(context, 'TestConnectionName', 'TestUser', {}), new Error( - 'BotFrameworkAdapter.exchangeToken(): Either a Token or Uri property is required on the TokenExchangeRequest' - ) + 'BotFrameworkAdapter.exchangeToken(): Either a Token or Uri property is required on the TokenExchangeRequest', + ), ); }); @@ -1881,7 +1882,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getTokenStatus({ activity: {}, turnState: new Map() }), - new Error('BotFrameworkAdapter.getTokenStatus(): missing from or from.id') + new Error('BotFrameworkAdapter.getTokenStatus(): missing from or from.id'), ); }); @@ -1889,7 +1890,7 @@ describe('BotFrameworkAdapter', function () { const adapter = new AdapterUnderTest(); await assert.rejects( adapter.getTokenStatus({ activity: { from: {} }, turnState: new Map() }), - new Error('BotFrameworkAdapter.getTokenStatus(): missing from or from.id') + new Error('BotFrameworkAdapter.getTokenStatus(): missing from or from.id'), ); }); }); @@ -1902,7 +1903,7 @@ describe('BotFrameworkAdapter', function () { // Empty Claims assert.strictEqual( AuthenticationConstants.ToChannelFromBotOAuthScope, - await adapter.getOAuthScope('botAppId', []) + await adapter.getOAuthScope('botAppId', []), ); // Non-skill Claims @@ -1911,7 +1912,7 @@ describe('BotFrameworkAdapter', function () { await adapter.getOAuthScope('botAppId', [ { type: 'aud', value: 'botAppId' }, { type: 'azp', value: 'botAppId' }, - ]) + ]), ); const govAdapter = new BotFrameworkAdapter({ channelService: GovernmentConstants.ChannelService }); @@ -1921,7 +1922,7 @@ describe('BotFrameworkAdapter', function () { // Empty Claims assert.strictEqual( GovernmentConstants.ToChannelFromBotOAuthScope, - await govAdapter.getOAuthScope('botAppId', []) + await govAdapter.getOAuthScope('botAppId', []), ); // Non-skill Claims @@ -1930,7 +1931,7 @@ describe('BotFrameworkAdapter', function () { await govAdapter.getOAuthScope('botAppId', [ { type: 'aud', value: 'botAppId' }, { type: 'azp', value: 'botAppId' }, - ]) + ]), ); }); @@ -1960,7 +1961,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( context.activity.recipient.id, reference.bot.id, - 'request has invalid recipient.id.' + 'request has invalid recipient.id.', ); }); }); @@ -1974,7 +1975,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( context.activity.recipient.id, reference.bot.id, - 'request has invalid recipient.id.' + 'request has invalid recipient.id.', ); }); }); @@ -1988,7 +1989,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( context.activity.recipient.id, reference.bot.id, - 'request has invalid recipient.id.' + 'request has invalid recipient.id.', ); }); }); @@ -2006,7 +2007,7 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual(context.activity.recipient.id, reference.bot.id); assert.strictEqual(context.turnState.get(context.adapter.OAuthScopeKey), oauthScope); }, - { oauthScope } + { oauthScope }, ); }); @@ -2023,12 +2024,12 @@ describe('BotFrameworkAdapter', function () { assert.strictEqual( context.turnState.get(context.adapter.OAuthScopeKey), - GovernmentConstants.ToChannelFromBotOAuthScope + GovernmentConstants.ToChannelFromBotOAuthScope, ); }, { adapterArgs: { channelService: GovernmentConstants.ChannelService }, - } + }, ); }); }); @@ -2086,7 +2087,7 @@ describe('BotFrameworkAdapter', function () { await assert.rejects( adapter.processActivityDirect(createActivity(), () => null), - new Error('BotFrameworkAdapter.processActivityDirect(): ERROR\n test-error') + new Error('BotFrameworkAdapter.processActivityDirect(): ERROR\n test-error'), ); sandbox.verify(); @@ -2098,7 +2099,7 @@ describe('BotFrameworkAdapter', function () { await assert.rejects( adapter.processActivityDirect(createActivity(), 'callbackLogic'), - new Error('BotFrameworkAdapter.processActivityDirect(): ERROR') + new Error('BotFrameworkAdapter.processActivityDirect(): ERROR'), ); sandbox.verify(); diff --git a/libraries/botbuilder/tests/botFrameworkHttpClient.test.js b/libraries/botbuilder/tests/botFrameworkHttpClient.test.js index e7068ff9ff..f8d54e0257 100644 --- a/libraries/botbuilder/tests/botFrameworkHttpClient.test.js +++ b/libraries/botbuilder/tests/botFrameworkHttpClient.test.js @@ -55,7 +55,7 @@ describe('BotFrameworkHttpClient', function () { it('should fail to construct without required parameters', function () { assert.throws( () => new BotFrameworkHttpClient(), - new Error('BotFrameworkHttpClient(): missing credentialProvider') + new Error('BotFrameworkHttpClient(): missing credentialProvider'), ); }); @@ -74,7 +74,7 @@ describe('BotFrameworkHttpClient', function () { 'http://skillUrl/api/good', 'serviceUrl', 'conversationId', - { type: 'message', conversation: {} } + { type: 'message', conversation: {} }, ); assert.strictEqual(response.status, 200); }); @@ -94,7 +94,7 @@ describe('BotFrameworkHttpClient', function () { 'http://skillUrl/api/bad', 'serviceUrl', 'conversationId', - { type: 'message', conversation: {} } + { type: 'message', conversation: {} }, ); assert.strictEqual(response.status, 404); }); @@ -114,7 +114,7 @@ describe('BotFrameworkHttpClient', function () { 'http://skillUrl/api/good', 'serviceUrl', 'conversationId', - { type: 'message', conversation: {} } + { type: 'message', conversation: {} }, ); assert.strictEqual(response.status, 200); }); @@ -135,9 +135,11 @@ describe('BotFrameworkHttpClient', function () { 'http://skillUrl/api/good', 'serviceUrl', 'conversationId', - { type: 'message', conversation: {} } + { type: 'message', conversation: {} }, + ), + new Error( + 'BotFrameworkHttpClient.postActivity(): Unable to get appCredentials to connect to the skill', ), - new Error('BotFrameworkHttpClient.postActivity(): Unable to get appCredentials to connect to the skill') ); }); @@ -153,7 +155,7 @@ describe('BotFrameworkHttpClient', function () { await assert.rejects( client.postActivity(fromBotId, 'toBotId', 'http://skillUrl/api/good', 'serviceUrl', 'conversationId'), - new Error('BotFrameworkHttpClient.postActivity(): missing activity') + new Error('BotFrameworkHttpClient.postActivity(): missing activity'), ); }); @@ -175,9 +177,9 @@ describe('BotFrameworkHttpClient', function () { 'http://skillUrl/api/good', 'serviceUrl', 'conversationId', - activity + activity, ), - new Error('BotFrameworkHttpClient.postActivity(): Activity must have a ConversationReference') + new Error('BotFrameworkHttpClient.postActivity(): Activity must have a ConversationReference'), ); }); @@ -197,7 +199,7 @@ describe('BotFrameworkHttpClient', function () { 'http://skillUrl/api/good', 'serviceUrl', 'conversationId', - activity + activity, ); assert.strictEqual(response.status, 200); assert.strictEqual(activity.recipient, undefined); @@ -220,7 +222,7 @@ describe('BotFrameworkHttpClient', function () { 'http://skillUrl/api/good', 'serviceUrl', 'conversationId', - forwardedActivity + forwardedActivity, ); assert.strictEqual(forwardedActivity.relatesTo, originalRelatesTo); }); diff --git a/libraries/botbuilder/tests/channelServiceHandler.test.js b/libraries/botbuilder/tests/channelServiceHandler.test.js index 97de7039b9..a6ae97d439 100644 --- a/libraries/botbuilder/tests/channelServiceHandler.test.js +++ b/libraries/botbuilder/tests/channelServiceHandler.test.js @@ -41,6 +41,7 @@ describe('ChannelServiceHandler', function () { const handler = new ChannelServiceHandler(CREDENTIALS, AUTH_CONFIG, 'channels'); let sandbox; + beforeEach(function () { sandbox = sinon.createSandbox(); }); @@ -86,7 +87,7 @@ describe('ChannelServiceHandler', function () { await assert.rejects( handler.handleSendToConversation(AUTH_HEADER, 'convId', { type: ActivityTypes.Message }), - matchStatusCodeError('onSendToConversation') + matchStatusCodeError('onSendToConversation'), ); }); }); @@ -97,7 +98,7 @@ describe('ChannelServiceHandler', function () { await assert.rejects( handler.handleReplyToActivity(AUTH_HEADER, 'convId', ACTIVITY.id, ACTIVITY), - matchStatusCodeError('onReplyToActivity') + matchStatusCodeError('onReplyToActivity'), ); }); }); @@ -108,7 +109,7 @@ describe('ChannelServiceHandler', function () { await assert.rejects( handler.handleUpdateActivity(AUTH_HEADER, 'convId', ACTIVITY.id, ACTIVITY), - matchStatusCodeError('onUpdateActivity') + matchStatusCodeError('onUpdateActivity'), ); }); }); @@ -119,7 +120,7 @@ describe('ChannelServiceHandler', function () { await assert.rejects( handler.handleDeleteActivity(AUTH_HEADER, 'convId', ACTIVITY.id, ACTIVITY), - matchStatusCodeError('onDeleteActivity') + matchStatusCodeError('onDeleteActivity'), ); }); }); @@ -130,7 +131,7 @@ describe('ChannelServiceHandler', function () { await assert.rejects( handler.handleGetActivityMembers(AUTH_HEADER, 'convId', ACTIVITY.id), - matchStatusCodeError('onGetActivityMembers') + matchStatusCodeError('onGetActivityMembers'), ); }); }); @@ -141,7 +142,7 @@ describe('ChannelServiceHandler', function () { await assert.rejects( handler.handleCreateConversation(AUTH_HEADER, { isGroup: false }), - matchStatusCodeError('onCreateConversation') + matchStatusCodeError('onCreateConversation'), ); }); }); @@ -152,7 +153,7 @@ describe('ChannelServiceHandler', function () { await assert.rejects( handler.handleGetConversations(AUTH_HEADER, 'convId'), - matchStatusCodeError('onGetConversations') + matchStatusCodeError('onGetConversations'), ); }); }); @@ -163,7 +164,7 @@ describe('ChannelServiceHandler', function () { await assert.rejects( handler.handleGetConversationMembers(AUTH_HEADER, 'convId'), - matchStatusCodeError('onGetConversationMembers') + matchStatusCodeError('onGetConversationMembers'), ); }); @@ -172,7 +173,7 @@ describe('ChannelServiceHandler', function () { await assert.rejects( handler.handleGetConversationPagedMembers(AUTH_HEADER, 'convId'), - matchStatusCodeError('onGetConversationPagedMembers') + matchStatusCodeError('onGetConversationPagedMembers'), ); }); @@ -181,7 +182,7 @@ describe('ChannelServiceHandler', function () { await assert.rejects( handler.handleDeleteConversationMember(AUTH_HEADER, 'convId', 'memberId'), - matchStatusCodeError('onDeleteConversationMember') + matchStatusCodeError('onDeleteConversationMember'), ); }); }); @@ -192,7 +193,7 @@ describe('ChannelServiceHandler', function () { await assert.rejects( handler.handleSendConversationHistory(AUTH_HEADER, 'convId', { ACTIVITY }), - matchStatusCodeError('onSendConversationHistory') + matchStatusCodeError('onSendConversationHistory'), ); }); }); @@ -203,7 +204,7 @@ describe('ChannelServiceHandler', function () { await assert.rejects( handler.handleUploadAttachment(AUTH_HEADER, 'convId', { type: 'string', name: 'attachment' }), - matchStatusCodeError('onUploadAttachment') + matchStatusCodeError('onUploadAttachment'), ); }); }); diff --git a/libraries/botbuilder/tests/channelServiceRoutes.test.js b/libraries/botbuilder/tests/channelServiceRoutes.test.js index 6f3467be71..8d830a4ff4 100644 --- a/libraries/botbuilder/tests/channelServiceRoutes.test.js +++ b/libraries/botbuilder/tests/channelServiceRoutes.test.js @@ -31,6 +31,7 @@ class MockResponse { describe('channelServiceRoutes', function () { let sandbox; + beforeEach(function () { sandbox = sinon.createSandbox(); }); @@ -50,6 +51,7 @@ describe('channelServiceRoutes', function () { describe('register()', function () { let channel, server; + beforeEach(function () { const testHandler = sandbox.mock(ChannelServiceHandler); channel = new ChannelServiceRoutes(testHandler); @@ -120,7 +122,7 @@ describe('channelServiceRoutes', function () { statusCode: 200, body: testResource, }, - done + done, ); const service = sandbox.createStubInstance(ChannelServiceHandler); @@ -145,7 +147,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -171,7 +173,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -197,7 +199,7 @@ describe('channelServiceRoutes', function () { statusCode: 200, body: testResource, }, - done + done, ); const service = sandbox.createStubInstance(ChannelServiceHandler); @@ -222,7 +224,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -249,7 +251,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -275,7 +277,7 @@ describe('channelServiceRoutes', function () { statusCode: 200, body: testResource, }, - done + done, ); const service = sandbox.createStubInstance(ChannelServiceHandler); @@ -300,7 +302,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -327,7 +329,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -353,7 +355,7 @@ describe('channelServiceRoutes', function () { statusCode: 200, body: {}, }, - done + done, ); const service = sandbox.createStubInstance(ChannelServiceHandler); @@ -378,7 +380,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -402,7 +404,7 @@ describe('channelServiceRoutes', function () { statusCode: 200, body: testResource, }, - done + done, ); const service = sandbox.createStubInstance(ChannelServiceHandler); @@ -427,7 +429,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -451,7 +453,7 @@ describe('channelServiceRoutes', function () { statusCode: 201, body: testResource, }, - done + done, ); const service = sandbox.createStubInstance(ChannelServiceHandler); @@ -476,7 +478,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -500,7 +502,7 @@ describe('channelServiceRoutes', function () { statusCode: 200, body: testResource, }, - done + done, ); const service = sandbox.createStubInstance(ChannelServiceHandler); @@ -525,7 +527,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -549,7 +551,7 @@ describe('channelServiceRoutes', function () { statusCode: 200, body: testResource, }, - done + done, ); const service = sandbox.createStubInstance(ChannelServiceHandler); @@ -574,7 +576,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -598,7 +600,7 @@ describe('channelServiceRoutes', function () { statusCode: 200, body: testResource, }, - done + done, ); const service = sandbox.createStubInstance(ChannelServiceHandler); @@ -623,7 +625,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -647,7 +649,7 @@ describe('channelServiceRoutes', function () { statusCode: 200, body: {}, }, - done + done, ); const service = sandbox.createStubInstance(ChannelServiceHandler); @@ -672,7 +674,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -696,7 +698,7 @@ describe('channelServiceRoutes', function () { statusCode: 200, body: testResource, }, - done + done, ); const service = sandbox.createStubInstance(ChannelServiceHandler); @@ -721,7 +723,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -748,7 +750,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -774,7 +776,7 @@ describe('channelServiceRoutes', function () { statusCode: 200, body: testResource, }, - done + done, ); const service = sandbox.createStubInstance(ChannelServiceHandler); @@ -799,7 +801,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -826,7 +828,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( err, resourceResponse, - `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}` + `expected: ${JSON.stringify(resourceResponse)}. received: ${JSON.stringify(err)}`, ); done(); }; @@ -885,7 +887,7 @@ describe('channelServiceRoutes', function () { assert.deepStrictEqual( body, source, - `expected: ${JSON.stringify(source)}. received: ${JSON.stringify(body)}` + `expected: ${JSON.stringify(source)}. received: ${JSON.stringify(body)}`, ); done(); }) diff --git a/libraries/botbuilder/tests/cloudAdapter.test.js b/libraries/botbuilder/tests/cloudAdapter.test.js index 013aa0fac4..2af3657225 100644 --- a/libraries/botbuilder/tests/cloudAdapter.test.js +++ b/libraries/botbuilder/tests/cloudAdapter.test.js @@ -30,6 +30,7 @@ const noop = () => null; describe('CloudAdapter', function () { let sandbox; + beforeEach(function () { sandbox = sinon.createSandbox({ useFakeTimers: false }); }); @@ -85,6 +86,7 @@ describe('CloudAdapter', function () { const activity = { type: ActivityTypes.Invoke, value: 'invoke' }; const authorization = 'Bearer Authorization'; + it('delegates to connect', async function () { const req = {}; const socket = FakeNodeSocket(); @@ -128,6 +130,7 @@ describe('CloudAdapter', function () { mock.verify(); }); + //eslint-disable-next-line mocha/no-skipped-tests it.skip('throws exception on expired token', async function () { const consoleStub = sandbox.stub(console, 'error'); @@ -170,7 +173,7 @@ describe('CloudAdapter', function () { credentialsFactory, authConfig, undefined, - undefined + undefined, ); const adapter = new CloudAdapter(botFrameworkAuthentication); @@ -178,7 +181,7 @@ describe('CloudAdapter', function () { await adapter.process(req, res, logic); assert.equal(StatusCodes.UNAUTHORIZED, res.statusCode); - expect(consoleStub.calledWithMatch({ message: 'The token has expired' })).to.be.true; + expect(consoleStub.calledWithMatch({ message: 'The token has expired' })).to.equal(true); }); it('calls processActivityDirect with string authorization', async function () { @@ -205,7 +208,7 @@ describe('CloudAdapter', function () { const claimsIdentity = adapter.createClaimsIdentity('appId'); const audience = AuthenticationConstants.ToChannelFromBotOAuthScope; const botFrameworkAuthentication = new ConfigurationBotFrameworkAuthentication( - TestConfiguration.DefaultConfig + TestConfiguration.DefaultConfig, ); const connectorFactory = botFrameworkAuthentication.createConnectorFactory(claimsIdentity); //AuthenticateRequestResult @@ -249,7 +252,7 @@ describe('CloudAdapter', function () { await assert.rejects( adapter.processActivityDirect(authorization, activity, logic), - new Error('CloudAdapter.processActivityDirect(): ERROR\n error stack') + new Error('CloudAdapter.processActivityDirect(): ERROR\n error stack'), ); }); }); @@ -263,27 +266,27 @@ describe('CloudAdapter', function () { await assert.rejects( adapter.connectNamedPipe(undefined, noop, 'appId', 'audience', 'callerId'), - includesParam('pipeName') + includesParam('pipeName'), ); await assert.rejects( adapter.connectNamedPipe('pipeName', undefined, 'appId', 'audience', 'callerId'), - includesParam('logic') + includesParam('logic'), ); await assert.rejects( adapter.connectNamedPipe('pipeName', noop, undefined, 'audience', 'callerId'), - includesParam('appId') + includesParam('appId'), ); await assert.rejects( adapter.connectNamedPipe('pipeName', noop, 'appId', undefined, 'callerId'), - includesParam('audience') + includesParam('audience'), ); await assert.rejects( adapter.connectNamedPipe('pipeName', noop, 'appId', 'audience', 10), - includesParam('callerId') + includesParam('callerId'), ); }); diff --git a/libraries/botbuilder/tests/eventFactoryTests.test.js b/libraries/botbuilder/tests/eventFactoryTests.test.js index eab0c29322..9cb56595e5 100644 --- a/libraries/botbuilder/tests/eventFactoryTests.test.js +++ b/libraries/botbuilder/tests/eventFactoryTests.test.js @@ -42,7 +42,7 @@ describe('EventFactory', function () { it('should throw if turnContext is falsy', function () { assert.throws( () => EventFactory.createHandoffInitiation(null, 'some text'), - TypeError('EventFactory.createHandoffInitiation(): Missing context.') + TypeError('EventFactory.createHandoffInitiation(): Missing context.'), ); }); }); @@ -82,14 +82,14 @@ describe('EventFactory', function () { it('should throw if conversation is falsy', function () { assert.throws( () => EventFactory.createHandoffStatus(null, 'some text'), - TypeError('EventFactory.createHandoffStatus(): missing conversation.') + TypeError('EventFactory.createHandoffStatus(): missing conversation.'), ); }); it('should throw if state is falsy', function () { assert.throws( () => EventFactory.createHandoffStatus({}, null), - TypeError('EventFactory.createHandoffStatus(): missing state.') + TypeError('EventFactory.createHandoffStatus(): missing state.'), ); }); }); diff --git a/libraries/botbuilder/tests/fileTranscriptStore.test.js b/libraries/botbuilder/tests/fileTranscriptStore.test.js index 79979e1089..4e02d3ca0a 100644 --- a/libraries/botbuilder/tests/fileTranscriptStore.test.js +++ b/libraries/botbuilder/tests/fileTranscriptStore.test.js @@ -12,10 +12,12 @@ const workingFolder = path.join(os.tmpdir(), 'botbuilder-transcript-tests'); describe('The FileTranscriptStore', function () { let storage; const startDate = new Date(); + before(async function () { await fs.remove(workingFolder); storage = new FileTranscriptStore(workingFolder); }); + after(function () { return fs.remove(workingFolder); }); @@ -27,14 +29,14 @@ describe('The FileTranscriptStore', function () { let pagedResult = await storage.getTranscriptActivities('test', 'deleteActivitySpec'); assert.ok( pagedResult.items.length === 1, - `Expected pagedResult.items.length to be 1 but it was ${pagedResult.items.length}` + `Expected pagedResult.items.length to be 1 but it was ${pagedResult.items.length}`, ); await storage.deleteTranscript('test', 'deleteActivitySpec'); pagedResult = await storage.getTranscriptActivities('test', 'deleteActivitySpec'); assert.ok( pagedResult.items.length === 0, - `Expected pagedResult.items.length to be 0 but it was ${pagedResult.items.length}` + `Expected pagedResult.items.length to be 0 but it was ${pagedResult.items.length}`, ); }); @@ -46,13 +48,14 @@ describe('The FileTranscriptStore', function () { const pagedResult = await storage.getTranscriptActivities('test', 'deleteActivitySpec'); assert.ok( pagedResult.items.length === 1, - `Expected pagedResult.items.length to be 1 but it was ${pagedResult.items.length}` + `Expected pagedResult.items.length to be 1 but it was ${pagedResult.items.length}`, ); }); describe('should log activities', function () { const conversationId = 'logActivitySpec'; let activities; + before(function () { activities = createActivities(conversationId, startDate); return Promise.all(activities.map((activity) => storage.logActivity(activity))); @@ -72,7 +75,7 @@ describe('The FileTranscriptStore', function () { const pagedResult = await storage.getTranscriptActivities('otherChannelId', conversationId); assert.ok( !pagedResult.continuationToken, - 'expected pagedResult.continuationToken to be false but it was not' + 'expected pagedResult.continuationToken to be false but it was not', ); assert.ok(pagedResult.items.length === 0, 'Expected pagedResult.items.length to be 0 but it was not'); }); @@ -81,7 +84,7 @@ describe('The FileTranscriptStore', function () { const pagedResult = await storage.getTranscriptActivities('test', 'someOtherConversation'); assert.ok( !pagedResult.continuationToken, - 'expected pagedResult.continuationToken to be false but it was not' + 'expected pagedResult.continuationToken to be false but it was not', ); assert.ok(pagedResult.items.length === 0, 'Expected pagedResult.items.length to be 0 but it was not'); }); @@ -92,8 +95,8 @@ describe('The FileTranscriptStore', function () { pagedResult.items.forEach((item, index) => assert.ok( JSON.stringify(item) === JSON.stringify(activities[index]), - `item #${index} does not match what was persisted to disk` - ) + `item #${index} does not match what was persisted to disk`, + ), ); }); @@ -102,11 +105,11 @@ describe('The FileTranscriptStore', function () { 'test', conversationId, null, - new Date(startDate.getTime() + 60000 * 5) + new Date(startDate.getTime() + 60000 * 5), ); assert.ok( pagedResult.items.length === 5, - `Expected the pagedResult.items.length to be 5 but it was ${pagedResult.items.length}` + `Expected the pagedResult.items.length to be 5 but it was ${pagedResult.items.length}`, ); }); }); @@ -119,21 +122,21 @@ describe('The FileTranscriptStore', function () { it('no activity is passed to the "logActivity" function', async function () { await assert.rejects( storage.logActivity(null), - new Error('activity cannot be null for logActivity()', 'An error should exist') + new Error('activity cannot be null for logActivity()', 'An error should exist'), ); }); it('no channelId is passed to the "getTranscriptActivities" function', async function () { await assert.rejects( storage.getTranscriptActivities(null, '123456'), - new Error('Missing channelId', 'An error should exist') + new Error('Missing channelId', 'An error should exist'), ); }); it('no conversationId is passed to the "getTranscriptActivities" function', async function () { await assert.rejects( storage.getTranscriptActivities({}), - new Error('Missing conversationId', 'An error should exist') + new Error('Missing conversationId', 'An error should exist'), ); }); @@ -148,7 +151,7 @@ describe('The FileTranscriptStore', function () { it('no conversationId is passed to the "deleteTranscript" function', async function () { await assert.rejects( storage.deleteTranscript({}), - new Error('Missing conversationId', 'An error should exist') + new Error('Missing conversationId', 'An error should exist'), ); }); }); @@ -156,11 +159,13 @@ describe('The FileTranscriptStore', function () { describe('should retrieve activities', function () { const conversationId = 'retrieveActivitiesSpec'; let activities; + before(function () { activities = createActivities(conversationId, startDate, 60); storage = new FileTranscriptStore(workingFolder); return Promise.all(activities.map((activity) => storage.logActivity(activity))); }); + after(function () { return fs.remove(workingFolder); }); @@ -169,12 +174,12 @@ describe('The FileTranscriptStore', function () { const pagedResult = await storage.getTranscriptActivities('test', conversationId); assert.ok( typeof pagedResult.continuationToken === 'string', - `Expected a continuationToken but got ${pagedResult.continuationToken}` + `Expected a continuationToken but got ${pagedResult.continuationToken}`, ); const pagedResult1 = await storage.getTranscriptActivities( 'test', conversationId, - pagedResult.continuationToken + pagedResult.continuationToken, ); assert.ok(!!pagedResult1.items.length, 'Expected the pagedResult to contain items but it did not'); assert.ok(JSON.stringify(pagedResult) !== JSON.stringify(pagedResult1)); @@ -189,12 +194,12 @@ describe('The FileTranscriptStore', function () { set(target, p, value) { if (target[p]) { assert.fail( - 'This ID already returned by getTranscriptActivities and it should not have been' + 'This ID already returned by getTranscriptActivities and it should not have been', ); } return (target[p] = value); }, - } + }, ); let increments = ~~(activities.length / 20); while (increments--) { @@ -219,23 +224,23 @@ describe('The FileTranscriptStore', function () { set(target, p, value) { if (target[p]) { assert.fail( - 'This ID already returned by getTranscriptActivities and it should not have been' + 'This ID already returned by getTranscriptActivities and it should not have been', ); } return (target[p] = value); }, - } + }, ); while (i--) { continuationToken = pagedResult.continuationToken; pagedResult = await storage.getTranscriptActivities('test', conversationId, continuationToken); assert.ok( i === 0 || !!pagedResult.continuationToken, - 'Expected a continuationToken but did not receive one' + 'Expected a continuationToken but did not receive one', ); assert.ok( continuationToken !== pagedResult.continuationToken, - 'The newly returned continuationToken should not match the last one received' + 'The newly returned continuationToken should not match the last one received', ); pagedResult.items.forEach((item) => (seen[item.id] = true)); } @@ -245,6 +250,7 @@ describe('The FileTranscriptStore', function () { describe('should list transcripts', function () { let activities; + before(function () { activities = []; let ct = 100; @@ -254,6 +260,7 @@ describe('The FileTranscriptStore', function () { storage = new FileTranscriptStore(workingFolder); return Promise.all(activities.map((activity) => storage.logActivity(activity))); }); + after(function () { return fs.remove(workingFolder); }); @@ -271,18 +278,18 @@ describe('The FileTranscriptStore', function () { } return (target[p] = value); }, - } + }, ); while (i--) { continuationToken = pagedResult.continuationToken; pagedResult = await storage.listTranscripts('test', continuationToken); assert.ok( i === 0 || !!pagedResult.continuationToken, - 'Expected a continuationToken but did not receive one' + 'Expected a continuationToken but did not receive one', ); assert.ok( continuationToken !== pagedResult.continuationToken, - 'The newly returned continuationToken should not match the last one received' + 'The newly returned continuationToken should not match the last one received', ); pagedResult.items.forEach((item) => (seen[item.id] = true)); } diff --git a/libraries/botbuilder/tests/inspectionMiddleware.test.js b/libraries/botbuilder/tests/inspectionMiddleware.test.js index fcd1b00dff..1cb858261a 100644 --- a/libraries/botbuilder/tests/inspectionMiddleware.test.js +++ b/libraries/botbuilder/tests/inspectionMiddleware.test.js @@ -39,20 +39,21 @@ describe('InspectionMiddleware', function () { assert(adapter.activityBuffer[0].type === 'message', 'expected a message activity'); assert(adapter.activityBuffer[0].text === 'hi', "expected text saying 'hi'"); }); + it('should replicate activity data to listening emulator following open and attach', async function () { // set up our expectations in nock - each corresponds to a trace message we expect to receive in the emulator const inboundExpectation = nock('https://test.com') .post( '/v3/conversations/Convo1/activities', - (activity) => activity.type === 'trace' && activity.value.text == 'hi' + (activity) => activity.type === 'trace' && activity.value.text == 'hi', ) .reply(200, { id: 'test' }); const outboundExpectation = nock('https://test.com') .post( '/v3/conversations/Convo1/activities', - (activity) => activity.type === 'trace' && activity.value.text == 'echo: hi' + (activity) => activity.type === 'trace' && activity.value.text == 'echo: hi', ) .reply(200, { id: 'test' }); @@ -64,7 +65,7 @@ describe('InspectionMiddleware', function () { activity.value.userState && activity.value.userState.x.property == 'hello' && activity.value.conversationState && - activity.value.conversationState.y.property == 'world' + activity.value.conversationState.y.property == 'world', ) .reply(200, { id: 'test' }); @@ -85,7 +86,7 @@ describe('InspectionMiddleware', function () { await inspectionMiddleware.processCommand(turnContext); }, null, - true + true, ); await inspectionAdapter.receiveActivity(openActivity); @@ -109,7 +110,7 @@ describe('InspectionMiddleware', function () { await conversationState.saveChanges(turnContext); }, null, - true + true, ); // IMPORTANT add the InspectionMiddleware to the adapter that is running our bot @@ -129,24 +130,25 @@ describe('InspectionMiddleware', function () { assert(inboundExpectation.isDone(), 'The expectation of a trace message for the inbound activity was not met'); assert( outboundExpectation.isDone(), - 'The expectation of a trace message for the outbound activity was not met' + 'The expectation of a trace message for the outbound activity was not met', ); assert(stateExpectation.isDone(), 'The expectation of a trace message for the bot state was not met'); }); + it('should replicate activity data to listening emulator following open and attach with at mention', async function () { // set up our expectations in nock - each corresponds to a trace message we expect to receive in the emulator const inboundExpectation = nock('https://test.com') .post( '/v3/conversations/Convo1/activities', - (activity) => activity.type === 'trace' && activity.value.text == 'hi' + (activity) => activity.type === 'trace' && activity.value.text == 'hi', ) .reply(200, { id: 'test' }); const outboundExpectation = nock('https://test.com') .post( '/v3/conversations/Convo1/activities', - (activity) => activity.type === 'trace' && activity.value.text == 'echo: hi' + (activity) => activity.type === 'trace' && activity.value.text == 'echo: hi', ) .reply(200, { id: 'test' }); @@ -158,7 +160,7 @@ describe('InspectionMiddleware', function () { activity.value.userState && activity.value.userState.x.property == 'hello' && activity.value.conversationState && - activity.value.conversationState.y.property == 'world' + activity.value.conversationState.y.property == 'world', ) .reply(200, { id: 'test' }); @@ -179,7 +181,7 @@ describe('InspectionMiddleware', function () { await inspectionMiddleware.processCommand(turnContext); }, null, - true + true, ); await inspectionAdapter.receiveActivity(openActivity); @@ -205,7 +207,7 @@ describe('InspectionMiddleware', function () { await conversationState.saveChanges(turnContext); }, null, - true + true, ); // IMPORTANT add the InspectionMiddleware to the adapter that is running our bot @@ -241,24 +243,25 @@ describe('InspectionMiddleware', function () { assert(inboundExpectation.isDone(), 'The expectation of a trace message for the inbound activity was not met'); assert( outboundExpectation.isDone(), - 'The expectation of a trace message for the outbound activity was not met' + 'The expectation of a trace message for the outbound activity was not met', ); assert(stateExpectation.isDone(), 'The expectation of a trace message for the bot state was not met'); }); + it('should replicate activity data to listening emulator following open and attach within Teams Team', async function () { // set up our expectations in nock - each corresponds to a trace message we expect to receive in the emulator const inboundExpectation = nock('https://test.com') .post( '/v3/conversations/Convo1/activities', - (activity) => activity.type === 'trace' && activity.value.text == 'hi' + (activity) => activity.type === 'trace' && activity.value.text == 'hi', ) .reply(200, { id: 'test' }); const outboundExpectation = nock('https://test.com') .post( '/v3/conversations/Convo1/activities', - (activity) => activity.type === 'trace' && activity.value.text == 'echo: hi' + (activity) => activity.type === 'trace' && activity.value.text == 'echo: hi', ) .reply(200, { id: 'test' }); @@ -270,7 +273,7 @@ describe('InspectionMiddleware', function () { activity.value.userState && activity.value.userState.x.property == 'hello' && activity.value.conversationState && - activity.value.conversationState.y.property == 'world' + activity.value.conversationState.y.property == 'world', ) .reply(200, { id: 'test' }); @@ -291,7 +294,7 @@ describe('InspectionMiddleware', function () { await inspectionMiddleware.processCommand(turnContext); }, null, - true + true, ); await inspectionAdapter.receiveActivity(openActivity); @@ -315,7 +318,7 @@ describe('InspectionMiddleware', function () { await conversationState.saveChanges(turnContext); }, null, - true + true, ); // IMPORTANT add the InspectionMiddleware to the adapter that is running our bot @@ -341,7 +344,7 @@ describe('InspectionMiddleware', function () { assert(inboundExpectation.isDone(), 'The expectation of a trace message for the inbound activity was not met'); assert( outboundExpectation.isDone(), - 'The expectation of a trace message for the outbound activity was not met' + 'The expectation of a trace message for the outbound activity was not met', ); assert(stateExpectation.isDone(), 'The expectation of a trace message for the bot state was not met'); }); @@ -352,14 +355,14 @@ describe('InspectionMiddleware', function () { nock('https://test.com') .post( '/v3/conversations/Convo1/activities', - (activity) => activity.type === 'trace' && activity.value.text == 'hi' + (activity) => activity.type === 'trace' && activity.value.text == 'hi', ) .reply(200, { id: 'test' }); nock('https://test.com') .post( '/v3/conversations/Convo1/activities', - (activity) => activity.type === 'trace' && activity.value.text == 'echo: hi' + (activity) => activity.type === 'trace' && activity.value.text == 'echo: hi', ) .reply(200, { id: 'test' }); @@ -371,7 +374,7 @@ describe('InspectionMiddleware', function () { activity.value.userState && activity.value.userState.x.property == 'hello' && activity.value.conversationState && - activity.value.conversationState.y.property == 'world' + activity.value.conversationState.y.property == 'world', ) .reply(200, { id: 'test' }); @@ -390,7 +393,7 @@ describe('InspectionMiddleware', function () { await inspectionMiddleware.processCommand(turnContext); }, null, - true + true, ); await inspectionAdapter.receiveActivity(openActivity); @@ -412,7 +415,7 @@ describe('InspectionMiddleware', function () { await conversationState.saveChanges(turnContext); }, null, - true + true, ); adapter.use(inspectionMiddleware); @@ -433,14 +436,14 @@ describe('InspectionMiddleware', function () { nock('https://test.com') .post( '/v3/conversations/Convo1/activities', - (activity) => activity.type === 'trace' && activity.value.text == 'hi' + (activity) => activity.type === 'trace' && activity.value.text == 'hi', ) .reply(200, { id: 'test' }); nock('https://test.com') .post( '/v3/conversations/Convo1/activities', - (activity) => activity.type === 'trace' && activity.value.text == 'echo: hi' + (activity) => activity.type === 'trace' && activity.value.text == 'echo: hi', ) .reply(200, { id: 'test' }); @@ -452,7 +455,7 @@ describe('InspectionMiddleware', function () { activity.value.userState && activity.value.userState.x.property == 'hello' && activity.value.conversationState && - activity.value.conversationState.y.property == 'world' + activity.value.conversationState.y.property == 'world', ) .reply(200, { id: 'test' }); @@ -472,7 +475,7 @@ describe('InspectionMiddleware', function () { await inspectionMiddleware.processCommand(turnContext); }, null, - true + true, ); await inspectionAdapter.receiveActivity(openActivity); @@ -493,7 +496,7 @@ describe('InspectionMiddleware', function () { await conversationState.saveChanges(turnContext); }, null, - true + true, ); adapter.use(inspectionMiddleware); @@ -513,14 +516,14 @@ describe('InspectionMiddleware', function () { nock('https://test.com') .post( '/v3/conversations/Convo1/activities', - (activity) => activity.type === 'trace' && activity.value.text == 'hi' + (activity) => activity.type === 'trace' && activity.value.text == 'hi', ) .reply(200, { id: 'test' }); nock('https://test.com') .post( '/v3/conversations/Convo1/activities', - (activity) => activity.type === 'trace' && activity.value.text == 'echo: hi' + (activity) => activity.type === 'trace' && activity.value.text == 'echo: hi', ) .reply(200, { id: 'test' }); @@ -532,7 +535,7 @@ describe('InspectionMiddleware', function () { activity.value.userState && activity.value.userState.x.property == 'hello' && activity.value.conversationState && - activity.value.conversationState.y.property == 'world' + activity.value.conversationState.y.property == 'world', ) .reply(200, { id: 'test' }); @@ -551,7 +554,7 @@ describe('InspectionMiddleware', function () { await inspectionMiddleware.processCommand(turnContext); }, null, - true + true, ); await inspectionAdapter.receiveActivity(openActivity); @@ -563,11 +566,11 @@ describe('InspectionMiddleware', function () { async (turnContext) => { await assert.rejects( inspectionMiddleware.onTurn(turnContext, null), - TypeError('next is not a function', 'next function should be null') + TypeError('next is not a function', 'next function should be null'), ); }, null, - true + true, ); adapter.use(inspectionMiddleware); @@ -641,7 +644,7 @@ describe('InspectionMiddleware', function () { const result = await inspectionMiddleware.attachCommand( '', { openedSessions: { 'session-1': undefined } }, - 'session-1' + 'session-1', ); assert.strictEqual(result, false, 'should be returning false'); }); diff --git a/libraries/botbuilder/tests/skills/cloudSkillHandler.test.js b/libraries/botbuilder/tests/skills/cloudSkillHandler.test.js index a46b02b1af..04b4951066 100644 --- a/libraries/botbuilder/tests/skills/cloudSkillHandler.test.js +++ b/libraries/botbuilder/tests/skills/cloudSkillHandler.test.js @@ -13,9 +13,11 @@ describe('CloudSkillHandler', function () { const handler = new CloudSkillHandler(adapter, bot, factory, authConfig); let sandbox; + beforeEach(function () { sandbox = sinon.createSandbox(); }); + afterEach(function () { sandbox.restore(); }); diff --git a/libraries/botbuilder/tests/skills/skillHandler.test.js b/libraries/botbuilder/tests/skills/skillHandler.test.js index 1a50be399f..b19700e4e5 100644 --- a/libraries/botbuilder/tests/skills/skillHandler.test.js +++ b/libraries/botbuilder/tests/skills/skillHandler.test.js @@ -27,9 +27,11 @@ describe('SkillHandler', function () { const handler = new SkillHandler(adapter, bot, factory, creds, authConfig); let sandbox; + beforeEach(function () { sandbox = sinon.createSandbox(); }); + afterEach(function () { sandbox.restore(); }); @@ -73,7 +75,7 @@ describe('SkillHandler', function () { assert.deepStrictEqual(context.turnState.get(adapter.BotIdentityKey), identity); return true; }) - .and(sinon.match({ activity })) + .and(sinon.match({ activity })), ) .once(); @@ -133,7 +135,7 @@ describe('SkillHandler', function () { expectsGetSkillConversationReference(convId, updatedActivity.serviceUrl); expectsContext((context) => - context.expects('updateActivity').withArgs(sinon.match(updatedActivity)).once().resolves() + context.expects('updateActivity').withArgs(sinon.match(updatedActivity)).once().resolves(), ); await handler.onUpdateActivity(new ClaimsIdentity([]), convId, activityId, updatedActivity); @@ -166,13 +168,13 @@ describe('SkillHandler', function () { assert.deepStrictEqual( context.turnState.get(adapter.BotIdentityKey), identity, - 'cached identity exists' + 'cached identity exists', ); assert.deepStrictEqual( context.turnState.get(handler.SkillConversationReferenceKey), ref, - 'cached conversation ref exists' + 'cached conversation ref exists', ); sandbox.verify(); @@ -186,7 +188,7 @@ describe('SkillHandler', function () { await assert.rejects( handler.inner.processActivity({}, 'convId', 'replyId', {}), - new Error('skillConversationReference not found') + new Error('skillConversationReference not found'), ); sandbox.verify(); @@ -197,7 +199,7 @@ describe('SkillHandler', function () { await assert.rejects( handler.inner.processActivity({}, 'convId', 'replyId', {}), - new Error('conversationReference not found.') + new Error('conversationReference not found.'), ); sandbox.verify(); @@ -233,7 +235,7 @@ describe('SkillHandler', function () { { type: AuthenticationConstants.AppIdClaim, value: '00000000-0000-0000-0000-000000000000' }, { type: AuthenticationConstants.VersionClaim, value: '1.0' }, ], - true + true, ); const skillActivity = { @@ -289,7 +291,7 @@ describe('SkillHandler', function () { { type: AuthenticationConstants.AppIdClaim, value: skillAppId }, { type: AuthenticationConstants.VersionClaim, value: '1.0' }, ], - true + true, ); const skillActivity = { @@ -313,16 +315,16 @@ describe('SkillHandler', function () { assert.strictEqual( fromKey, fromHandlerKey, - 'the keys should return the same cached values' + 'the keys should return the same cached values', ); assert.strictEqual( context.activity.callerId, - `${CallerIdConstants.BotToBotPrefix}${skillAppId}` + `${CallerIdConstants.BotToBotPrefix}${skillAppId}`, ); return true; - }) + }), ) .once(); diff --git a/libraries/botbuilder/tests/skills/skillHttpClient.test.js b/libraries/botbuilder/tests/skills/skillHttpClient.test.js index 3bfd849c82..04008dbc8b 100644 --- a/libraries/botbuilder/tests/skills/skillHttpClient.test.js +++ b/libraries/botbuilder/tests/skills/skillHttpClient.test.js @@ -10,7 +10,7 @@ describe('SkillHttpClient', function () { it('should fail to construct without required parameters', function () { assert.throws( () => new SkillHttpClient(new SimpleCredentialProvider('', '')), - new Error('conversationIdFactory missing') + new Error('conversationIdFactory missing'), ); }); }); diff --git a/libraries/botbuilder/tests/statusCodeError.test.js b/libraries/botbuilder/tests/statusCodeError.test.js index e0e132ec96..5e1c05efbe 100644 --- a/libraries/botbuilder/tests/statusCodeError.test.js +++ b/libraries/botbuilder/tests/statusCodeError.test.js @@ -17,7 +17,7 @@ describe('StatusCodeError', function () { assert.strictEqual( error.statusCode, StatusCodes.NOT_FOUND, - `statusCode should be the code ${StatusCodes.NOT_FOUND}` + `statusCode should be the code ${StatusCodes.NOT_FOUND}`, ); }); @@ -28,7 +28,7 @@ describe('StatusCodeError', function () { assert.strictEqual( error.statusCode, StatusCodes.NOT_FOUND, - `statusCode should be the code ${StatusCodes.NOT_FOUND}` + `statusCode should be the code ${StatusCodes.NOT_FOUND}`, ); }); diff --git a/libraries/botbuilder/tests/streaming/botFrameworkAdapterStreaming.test.js b/libraries/botbuilder/tests/streaming/botFrameworkAdapterStreaming.test.js index e0a7961231..e28ed4d472 100644 --- a/libraries/botbuilder/tests/streaming/botFrameworkAdapterStreaming.test.js +++ b/libraries/botbuilder/tests/streaming/botFrameworkAdapterStreaming.test.js @@ -52,7 +52,7 @@ describe('BotFrameworkAdapter Streaming tests', function () { const adapter = new BotFrameworkAdapter(); adapter.useNamedPipe(async (_) => {}, 'PipeyMcPipeface'); - expect(adapter.streamingServer.disconnect()).to.not.throw; + expect(() => adapter.streamingServer.disconnect()).to.not.throw(); }); it("throws exception when trying to connect to a different named pipe than it's connected to", async function () { @@ -66,7 +66,7 @@ describe('BotFrameworkAdapter Streaming tests', function () { { message: 'This BotFrameworkAdapter instance is already connected to a different stream. Use a new instance to connect to the provided pipeName.', - } + }, ); }); @@ -83,7 +83,7 @@ describe('BotFrameworkAdapter Streaming tests', function () { it('isStreamingConnectionOpen returns false without a streamingServer', function () { const adapter = new BotFrameworkAdapter(); - expect(adapter.isStreamingConnectionOpen).to.be.false; + expect(adapter.isStreamingConnectionOpen).to.equal(false); }); it('sendActivities should throw an error if streaming connection is closed.', async function () { @@ -102,8 +102,8 @@ describe('BotFrameworkAdapter Streaming tests', function () { await assert.rejects( adapter.sendActivities(new TurnContext(adapter, activity), [reply]), new Error( - 'BotFrameworkAdapter.sendActivities(): Unable to send activity as Streaming connection is closed.' - ) + 'BotFrameworkAdapter.sendActivities(): Unable to send activity as Streaming connection is closed.', + ), ); }); @@ -142,7 +142,7 @@ describe('BotFrameworkAdapter Streaming tests', function () { await adapter.useWebSocket(request, realSocket, Buffer.from([]), async (context) => { await bot.run(context); }); - expect(writeSpy.called).to.be.true; + expect(writeSpy.called).to.equal(true); }); it('returns status code 401 when request is not authorized', async function () { @@ -165,13 +165,13 @@ describe('BotFrameworkAdapter Streaming tests', function () { expect(err.message).to.equal('Unauthorized. Is not authenticated'); const socketResponse = MockNetSocket.createNonSuccessResponse( StatusCodes.UNAUTHORIZED, - err.message + err.message, ); - expect(writeSpy.called).to.be.true; - expect(writeSpy.calledWithExactly(socketResponse)).to.be.true; - expect(destroySpy.calledOnceWithExactly()).to.be.true; + expect(writeSpy.called).to.equal(true); + expect(writeSpy.calledWithExactly(socketResponse)).to.equal(true); + expect(destroySpy.calledOnceWithExactly()).to.equal(true); return true; - } + }, ); }); @@ -193,11 +193,11 @@ describe('BotFrameworkAdapter Streaming tests', function () { expect(err.message).to.equal("'authHeader' required."); expect(err.statusCode).to.equal(StatusCodes.BAD_REQUEST); const socketResponse = MockNetSocket.createNonSuccessResponse(StatusCodes.BAD_REQUEST, err.message); - expect(writeSpy.called).to.be.true; - expect(writeSpy.calledWithExactly(socketResponse)).to.be.true; - expect(destroySpy.calledOnceWithExactly()).to.be.true; + expect(writeSpy.called).to.equal(true); + expect(writeSpy.calledWithExactly(socketResponse)).to.equal(true); + expect(destroySpy.calledOnceWithExactly()).to.equal(true); return true; - } + }, ); }); @@ -211,7 +211,7 @@ describe('BotFrameworkAdapter Streaming tests', function () { await assert.rejects(adapter.useWebSocket(request, socket, Buffer.from([]), uncallableLogic), (err) => { expect(err.message).to.equal('Streaming logic needs to be provided to `useWebSocket`'); - expect(useWebSocketSpy.called).to.be.true; + expect(useWebSocketSpy.called).to.equal(true); return true; }); }); @@ -257,7 +257,7 @@ describe('BotFrameworkAdapter Streaming tests', function () { const response = await adapter.processRequest(request); expect(response.statusCode).to.equal(StatusCodes.OK); - expect(response.streams[0].content).to.not.be.undefined; + expect(response.streams[0].content).to.not.equal(undefined); }); it('returns user agent information from cache when a GET hits the version endpoint more than once', async function () { @@ -269,11 +269,11 @@ describe('BotFrameworkAdapter Streaming tests', function () { const response = await adapter.processRequest(request); expect(response.statusCode).to.equal(StatusCodes.OK); - expect(response.streams[0].content).to.not.be.undefined; + expect(response.streams[0].content).to.not.equal(undefined); const response2 = await adapter.processRequest(request); expect(response2.statusCode).to.equal(StatusCodes.OK); - expect(response2.streams[0].content).to.not.be.undefined; + expect(response2.streams[0].content).to.not.equal(undefined); }); it('should return 405 for unsupported methods to valid paths', async function () { @@ -353,7 +353,7 @@ describe('BotFrameworkAdapter Streaming tests', function () { const response = await adapter.processRequest(request); expect(response.statusCode).to.equal(StatusCodes.INTERNAL_SERVER_ERROR); - expect(middlewareCalled).to.be.true; + expect(middlewareCalled).to.equal(true); }); it('executes middleware', async function () { @@ -379,8 +379,8 @@ describe('BotFrameworkAdapter Streaming tests', function () { const response = await adapter.processRequest(request); expect(response.statusCode).to.equal(StatusCodes.NOT_IMPLEMENTED); - expect(runSpy.called).to.be.true; - expect(middlewareCalled).to.be.true; + expect(runSpy.called).to.equal(true); + expect(middlewareCalled).to.equal(true); }); }); @@ -398,7 +398,7 @@ describe('BotFrameworkAdapter Streaming tests', function () { const connection = adapter.createConnectorClient('fakeUrl'); connection.sendRequest({ method: 'POST', url: 'testResultDotCom', body: 'Test body!' }); - expect(writeSpy.called).to.be.true; + expect(writeSpy.called).to.equal(true); }).timeout(2000); describe('private methods', function () { @@ -409,7 +409,7 @@ describe('BotFrameworkAdapter Streaming tests', function () { ]; serviceUrls.forEach((serviceUrl) => { - expect(BotFrameworkAdapter.isStreamingServiceUrl(serviceUrl)).to.be.true; + expect(BotFrameworkAdapter.isStreamingServiceUrl(serviceUrl)).to.equal(true); }); }); @@ -417,7 +417,7 @@ describe('BotFrameworkAdapter Streaming tests', function () { const serviceUrls = ['http://yayay.com', 'HTTPS://yayay.com']; serviceUrls.forEach((serviceUrl) => { - expect(BotFrameworkAdapter.isStreamingServiceUrl(serviceUrl)).to.be.false; + expect(BotFrameworkAdapter.isStreamingServiceUrl(serviceUrl)).to.equal(false); }); }); }); diff --git a/libraries/botbuilder/tests/streaming/mockHttpRequest.js b/libraries/botbuilder/tests/streaming/mockHttpRequest.js index b97aad8300..c9e64f861c 100644 --- a/libraries/botbuilder/tests/streaming/mockHttpRequest.js +++ b/libraries/botbuilder/tests/streaming/mockHttpRequest.js @@ -12,7 +12,7 @@ class MockHttpRequest { 'sec-websocket-protocol': '', }, }, - options + options, ); this.method = config.method; diff --git a/libraries/botbuilder/tests/streaming/mockStreamingRequest.js b/libraries/botbuilder/tests/streaming/mockStreamingRequest.js index ac65f92c07..771532c286 100644 --- a/libraries/botbuilder/tests/streaming/mockStreamingRequest.js +++ b/libraries/botbuilder/tests/streaming/mockStreamingRequest.js @@ -7,7 +7,7 @@ class MockContentStream { { readAsJson: async () => ({ type: ActivityTypes.Invoke, serviceUrl: 'somewhere/', channelId: 'test' }), }, - options + options, ); this.readAsJson = config.readAsJson; @@ -23,7 +23,7 @@ class MockStreamingRequest { path: '/api/messages', streams: [new MockContentStream()], }, - options + options, ); this.verb = config.verb; diff --git a/libraries/botbuilder/tests/streaming/streamingHttpClient.test.js b/libraries/botbuilder/tests/streaming/streamingHttpClient.test.js index 348cacad71..e353583d1d 100644 --- a/libraries/botbuilder/tests/streaming/streamingHttpClient.test.js +++ b/libraries/botbuilder/tests/streaming/streamingHttpClient.test.js @@ -19,7 +19,7 @@ describe('StreamingHttpClient', function () { await assert.rejects( client.sendRequest(), - new Error('StreamingHttpClient.sendRequest(): missing "httpRequest" parameter') + new Error('StreamingHttpClient.sendRequest(): missing "httpRequest" parameter'), ); }); @@ -29,8 +29,8 @@ describe('StreamingHttpClient', function () { await assert.rejects( client.sendRequest({}), new Error( - 'StreamingHttpClient.sendRequest(): Streaming connection is disconnected, and the request could not be sent.' - ) + 'StreamingHttpClient.sendRequest(): Streaming connection is disconnected, and the request could not be sent.', + ), ); }); }); diff --git a/libraries/botbuilder/tests/streaming/tokenResolver.test.js b/libraries/botbuilder/tests/streaming/tokenResolver.test.js index 489cbf5b7d..6dbc32e703 100644 --- a/libraries/botbuilder/tests/streaming/tokenResolver.test.js +++ b/libraries/botbuilder/tests/streaming/tokenResolver.test.js @@ -61,7 +61,7 @@ describe('TokenResolver', function () { assert(!gotToken, 'did not receive token'); await assert.throws( () => TokenResolver.checkForOAuthCards(adapter, context, activity), - new Error("The OAuthPrompt's ConnectionName property is missing a value.", 'did not receive token') + new Error("The OAuthPrompt's ConnectionName property is missing a value.", 'did not receive token'), ); }); diff --git a/libraries/botbuilder/tests/teams/teamsSSOTokenExchangeMiddleware.test.js b/libraries/botbuilder/tests/teams/teamsSSOTokenExchangeMiddleware.test.js index 5f63d31985..bde0085cd3 100644 --- a/libraries/botbuilder/tests/teams/teamsSSOTokenExchangeMiddleware.test.js +++ b/libraries/botbuilder/tests/teams/teamsSSOTokenExchangeMiddleware.test.js @@ -102,7 +102,7 @@ describe('TeamsSSOTokenExchangeMiddleware', function () { }); const adapter = new TeamsSSOAdapter(createConversationReference(), logic).use( - new TeamsSSOTokenExchangeMiddleware(new MemoryStorage(), connectionName) + new TeamsSSOTokenExchangeMiddleware(new MemoryStorage(), connectionName), ); adapter.addExchangeableToken(connectionName, Channels.Msteams, teamsUserId, fakeExchangeableItem, token); @@ -120,7 +120,7 @@ describe('TeamsSSOTokenExchangeMiddleware', function () { }); const adapter = new TeamsSSOAdapter(createConversationReference(), logic).use( - new TeamsSSOTokenExchangeMiddleware(new MemoryStorage(), connectionName) + new TeamsSSOTokenExchangeMiddleware(new MemoryStorage(), connectionName), ); adapter.addExchangeableToken(connectionName, Channels.Msteams, teamsUserId, fakeExchangeableItem, token); @@ -148,7 +148,7 @@ describe('TeamsSSOTokenExchangeMiddleware', function () { // Note: addExchangeableToken omitted so exchange does not take place const adapter = new TeamsSSOAdapter(createConversationReference(), logic).use( - new TeamsSSOTokenExchangeMiddleware(new MemoryStorage(), connectionName) + new TeamsSSOTokenExchangeMiddleware(new MemoryStorage(), connectionName), ); await adapter @@ -177,7 +177,7 @@ describe('TeamsSSOTokenExchangeMiddleware', function () { }); const adapter = new TeamsSSOAdapter(createConversationReference(Channels.Directline), logic).use( - new TeamsSSOTokenExchangeMiddleware(new MemoryStorage(), connectionName) + new TeamsSSOTokenExchangeMiddleware(new MemoryStorage(), connectionName), ); await adapter.send('test').assertReply('processed').startTest(); @@ -194,6 +194,7 @@ describe('TeamsSSOTokenExchangeMiddleware', function () { afterEach(function () { this.sandbox.restore(); }); + it('exchange token with CloudAdapter', async function () { class TestCloudAdapter extends CloudAdapterBase {} const conversation = TestAdapter.createConversation('Convo1'); diff --git a/libraries/botbuilder/tests/teamsActivityHandler.test.js b/libraries/botbuilder/tests/teamsActivityHandler.test.js index 234a2e580e..3f1aa42aca 100644 --- a/libraries/botbuilder/tests/teamsActivityHandler.test.js +++ b/libraries/botbuilder/tests/teamsActivityHandler.test.js @@ -676,17 +676,17 @@ describe('TeamsActivityHandler', function () { .assertReply((activity) => { assert( activity.type === 'invokeResponse', - `incorrect activity type "${activity.type}", expected "invokeResponse"` + `incorrect activity type "${activity.type}", expected "invokeResponse"`, ); assert( activity.value.status === 400, - `incorrect status code "${activity.value.status}", expected "400"` + `incorrect status code "${activity.value.status}", expected "400"`, ); assert( !activity.value.body, `expected empty body for invokeResponse from fileConsent flow.\nReceived: ${JSON.stringify( - activity.value.body - )}` + activity.value.body, + )}`, ); }) .startTest(); @@ -706,17 +706,17 @@ describe('TeamsActivityHandler', function () { .assertReply((activity) => { assert( activity.type === 'invokeResponse', - `incorrect activity type "${activity.type}", expected "invokeResponse"` + `incorrect activity type "${activity.type}", expected "invokeResponse"`, ); assert( activity.value.status === 400, - `incorrect status code "${activity.value.status}", expected "400"` + `incorrect status code "${activity.value.status}", expected "400"`, ); assert( !activity.value.body, `expected empty body for invokeResponse from fileConsent flow.\nReceived: ${JSON.stringify( - activity.value.body - )}` + activity.value.body, + )}`, ); }) .startTest(); @@ -774,17 +774,17 @@ describe('TeamsActivityHandler', function () { .assertReply((activity) => { assert( activity.type === 'invokeResponse', - `incorrect activity type "${activity.type}", expected "invokeResponse"` + `incorrect activity type "${activity.type}", expected "invokeResponse"`, ); assert( activity.value.status === 501, - `incorrect status code "${activity.value.status}", expected "501"` + `incorrect status code "${activity.value.status}", expected "501"`, ); assert( !activity.value.body, `expected empty body for invokeResponse from fileConsent flow.\nReceived: ${JSON.stringify( - activity.value.body - )}` + activity.value.body, + )}`, ); }) .startTest(); @@ -806,17 +806,17 @@ describe('TeamsActivityHandler', function () { .assertReply((activity) => { assert( activity.type === 'invokeResponse', - `incorrect activity type "${activity.type}", expected "invokeResponse"` + `incorrect activity type "${activity.type}", expected "invokeResponse"`, ); assert( activity.value.status === 501, - `incorrect status code "${activity.value.status}", expected "501"` + `incorrect status code "${activity.value.status}", expected "501"`, ); assert( !activity.value.body, `expected empty body for invokeResponse from fileConsent flow.\nReceived: ${JSON.stringify( - activity.value.body - )}` + activity.value.body, + )}`, ); }) .startTest(); @@ -838,17 +838,17 @@ describe('TeamsActivityHandler', function () { .assertReply((activity) => { assert( activity.type === 'invokeResponse', - `incorrect activity type "${activity.type}", expected "invokeResponse"` + `incorrect activity type "${activity.type}", expected "invokeResponse"`, ); assert( activity.value.status === 501, - `incorrect status code "${activity.value.status}", expected "501"` + `incorrect status code "${activity.value.status}", expected "501"`, ); assert( !activity.value.body, `expected empty body for invokeResponse from fileConsent flow.\nReceived: ${JSON.stringify( - activity.value.body - )}` + activity.value.body, + )}`, ); }) .startTest(); @@ -868,17 +868,17 @@ describe('TeamsActivityHandler', function () { .assertReply((activity) => { assert( activity.type === 'invokeResponse', - `incorrect activity type "${activity.type}", expected "invokeResponse"` + `incorrect activity type "${activity.type}", expected "invokeResponse"`, ); assert( activity.value.status === 501, - `incorrect status code "${activity.value.status}", expected "501"` + `incorrect status code "${activity.value.status}", expected "501"`, ); assert( !activity.value.body, `expected empty body for invokeResponse from fileConsent flow.\nReceived: ${JSON.stringify( - activity.value.body - )}` + activity.value.body, + )}`, ); }) .startTest(); @@ -1148,24 +1148,6 @@ describe('TeamsActivityHandler', function () { .startTest(); }); - it('handleTeamsMessagingExtensionConfigurationQuerySettingUrl is not overridden', async function () { - const bot = new TeamsActivityHandler(); - - const adapter = new TestAdapter(async (context) => { - await bot.run(context); - }); - - const taskSubmitActivity = createInvokeActivity('composeExtension/querySettingUrl'); - await adapter - .send(taskSubmitActivity) - .assertReply((activity) => { - assert.strictEqual(activity.type, 'invokeResponse'); - assert.strictEqual(activity.value.status, 501); - assert.strictEqual(activity.value.body, undefined); - }) - .startTest(); - }); - it('handleTeamsMessagingExtensionConfigurationSetting is not overridden', async function () { const bot = new TeamsActivityHandler(); @@ -1211,17 +1193,17 @@ describe('TeamsActivityHandler', function () { .assertReply((activity) => { assert( activity.type === 'invokeResponse', - `incorrect activity type "${activity.type}", expected "invokeResponse"` + `incorrect activity type "${activity.type}", expected "invokeResponse"`, ); assert( activity.value.status === 200, - `incorrect status code "${activity.value.status}", expected "200"` + `incorrect status code "${activity.value.status}", expected "200"`, ); assert( !activity.value.body, `expected empty body for invokeResponse from fileConsent flow.\nReceived: ${JSON.stringify( - activity.value.body - )}` + activity.value.body, + )}`, ); }) .startTest(); @@ -1240,17 +1222,17 @@ describe('TeamsActivityHandler', function () { .assertReply((activity) => { assert( activity.type === 'invokeResponse', - `incorrect activity type "${activity.type}", expected "invokeResponse"` + `incorrect activity type "${activity.type}", expected "invokeResponse"`, ); assert( activity.value.status === 200, - `incorrect status code "${activity.value.status}", expected "200"` + `incorrect status code "${activity.value.status}", expected "200"`, ); assert( !activity.value.body, `expected empty body for invokeResponse from fileConsent flow.\nReceived: ${JSON.stringify( - activity.value.body - )}` + activity.value.body, + )}`, ); }) .startTest(); @@ -1275,17 +1257,17 @@ describe('TeamsActivityHandler', function () { .assertReply((activity) => { assert( activity.type === 'invokeResponse', - `incorrect activity type "${activity.type}", expected "invokeResponse"` + `incorrect activity type "${activity.type}", expected "invokeResponse"`, ); assert( activity.value.status === 200, - `incorrect status code "${activity.value.status}", expected "200"` + `incorrect status code "${activity.value.status}", expected "200"`, ); assert( !activity.value.body, `expected empty body for invokeResponse from fileConsent flow.\nReceived: ${JSON.stringify( - activity.value.body - )}` + activity.value.body, + )}`, ); }) .startTest(); @@ -1481,7 +1463,7 @@ describe('TeamsActivityHandler', function () { assert(fileConsentCardResponse, 'fileConsentCardResponse not found'); assert( fileConsentCalled, - 'handleTeamsFileConsent handler was not called before handleTeamsFileConsentAccept handler' + 'handleTeamsFileConsent handler was not called before handleTeamsFileConsentAccept handler', ); fileConsentAcceptCalled = true; } @@ -1491,7 +1473,7 @@ describe('TeamsActivityHandler', function () { assert(fileConsentCardResponse, 'fileConsentCardResponse not found'); assert( fileConsentCalled, - 'handleTeamsFileConsent handler was not called before handleTeamsFileConsentDecline handler' + 'handleTeamsFileConsent handler was not called before handleTeamsFileConsentDecline handler', ); fileConsentDeclineCalled = true; } @@ -1521,17 +1503,17 @@ describe('TeamsActivityHandler', function () { .assertReply((activity) => { assert( activity.type === 'invokeResponse', - `incorrect activity type "${activity.type}", expected "invokeResponse"` + `incorrect activity type "${activity.type}", expected "invokeResponse"`, ); assert( activity.value.status === 200, - `incorrect status code "${activity.value.status}", expected "200"` + `incorrect status code "${activity.value.status}", expected "200"`, ); assert( !activity.value.body, `expected empty body for invokeResponse from fileConsent flow.\nReceived: ${JSON.stringify( - activity.value.body - )}` + activity.value.body, + )}`, ); }) .then(() => { @@ -1553,17 +1535,17 @@ describe('TeamsActivityHandler', function () { .assertReply((activity) => { assert( activity.type === 'invokeResponse', - `incorrect activity type "${activity.type}", expected "invokeResponse"` + `incorrect activity type "${activity.type}", expected "invokeResponse"`, ); assert( activity.value.status === 200, - `incorrect status code "${activity.value.status}", expected "200"` + `incorrect status code "${activity.value.status}", expected "200"`, ); assert( !activity.value.body, `expected empty body for invokeResponse from fileConsent flow.\nReceived: ${JSON.stringify( - activity.value.body - )}` + activity.value.body, + )}`, ); }) .then(() => { @@ -2574,7 +2556,7 @@ describe('TeamsActivityHandler', function () { .then(() => { assert( ncalls === 1, - 'On ConversationUpdate handler should only be called once, times called: ' + ncalls.toString() + 'On ConversationUpdate handler should only be called once, times called: ' + ncalls.toString(), ); }) .startTest(); diff --git a/libraries/botbuilder/tests/teamsInfo.test.js b/libraries/botbuilder/tests/teamsInfo.test.js index 718d85a8a2..9cee971de0 100644 --- a/libraries/botbuilder/tests/teamsInfo.test.js +++ b/libraries/botbuilder/tests/teamsInfo.test.js @@ -279,7 +279,7 @@ describe('TeamsInfo', function () { it('should error if context is null', async function () { await assert.rejects( TeamsInfo.sendMessageToTeamsChannel(null, teamActivity, 'teamID'), - new Error('TurnContext cannot be null') + new Error('TurnContext cannot be null'), ); }); @@ -288,7 +288,7 @@ describe('TeamsInfo', function () { await assert.rejects( TeamsInfo.sendMessageToTeamsChannel(context, null, 'teamID'), - new Error('Activity cannot be null') + new Error('Activity cannot be null'), ); }); @@ -297,7 +297,7 @@ describe('TeamsInfo', function () { await assert.rejects( TeamsInfo.sendMessageToTeamsChannel(context, teamActivity, ''), - new Error('The teamsChannelId cannot be null or empty') + new Error('The teamsChannelId cannot be null or empty'), ); }); @@ -306,7 +306,7 @@ describe('TeamsInfo', function () { await assert.rejects( TeamsInfo.sendMessageToTeamsChannel(context, teamActivity, null), - new Error('The teamsChannelId cannot be null or empty') + new Error('The teamsChannelId cannot be null or empty'), ); }); }); @@ -317,7 +317,7 @@ describe('TeamsInfo', function () { await assert.rejects( TeamsInfo.getTeamChannels(context), - new Error('This method is only valid within the scope of a MS Teams Team.') + new Error('This method is only valid within the scope of a MS Teams Team.'), ); }); @@ -326,7 +326,7 @@ describe('TeamsInfo', function () { await assert.rejects( TeamsInfo.getTeamChannels(context), - new Error('This method is only valid within the scope of a MS Teams Team.') + new Error('This method is only valid within the scope of a MS Teams Team.'), ); }); @@ -365,7 +365,7 @@ describe('TeamsInfo', function () { // There should be a channel in the conversations returned from the conversations assert( channels.find((channel) => channel.id === '19:generalChannelIdgeneralChannelId@thread.skype'), - 'did not find general channel/team id in response' + 'did not find general channel/team id in response', ); }); @@ -404,7 +404,7 @@ describe('TeamsInfo', function () { // There should be a channel in the conversations returned from the conversations assert( channels.find((channel) => channel.id === '19:ChannelIdgeneralChannelId@thread.skype'), - 'did not find general channel/team id in response' + 'did not find general channel/team id in response', ); }); }); @@ -415,7 +415,7 @@ describe('TeamsInfo', function () { await assert.rejects( TeamsInfo.getTeamDetails(context), - new Error('This method is only valid within the scope of a MS Teams Team.') + new Error('This method is only valid within the scope of a MS Teams Team.'), ); }); @@ -424,7 +424,7 @@ describe('TeamsInfo', function () { await assert.rejects( TeamsInfo.getTeamDetails(context), - new Error('This method is only valid within the scope of a MS Teams Team.') + new Error('This method is only valid within the scope of a MS Teams Team.'), ); }); @@ -474,7 +474,7 @@ describe('TeamsInfo', function () { context.turnState.set(context.adapter.ConnectorClientKey, connectorClient); const fetchedTeamDetails = await TeamsInfo.getTeamDetails( context, - '19:ChannelIdgeneralChannelId@thread.skype' + '19:ChannelIdgeneralChannelId@thread.skype', ); assert(fetchTeamDetailsExpectation.isDone()); @@ -516,7 +516,7 @@ describe('TeamsInfo', function () { assert.deepStrictEqual( fetchedMembers, - members.map((member) => ({ ...member, aadObjectId: member.objectId })) + members.map((member) => ({ ...member, aadObjectId: member.objectId })), ); }); @@ -569,7 +569,7 @@ describe('TeamsInfo', function () { assert.deepStrictEqual( fetchedMembers, - members.map((member) => ({ ...member, aadObjectId: member.objectId })) + members.map((member) => ({ ...member, aadObjectId: member.objectId })), ); }); @@ -612,7 +612,7 @@ describe('TeamsInfo', function () { assert.deepStrictEqual( fetchedMembers, - members.map((member) => ({ ...member, aadObjectId: member.objectId })) + members.map((member) => ({ ...member, aadObjectId: member.objectId })), ); }); @@ -693,7 +693,7 @@ describe('TeamsInfo', function () { await assert.rejects( TeamsInfo.getTeamMember(context), - new Error('This method is only valid within the scope of a MS Teams Team.') + new Error('This method is only valid within the scope of a MS Teams Team.'), ); }); }); @@ -836,7 +836,7 @@ describe('TeamsInfo', function () { it('should throw error for missing meetingId', async function () { await assert.rejects( TeamsInfo.getMeetingInfo({ activity: {} }), - Error('meetingId or TurnContext containing meetingId is required.') + Error('meetingId or TurnContext containing meetingId is required.'), ); }); }); @@ -847,7 +847,7 @@ describe('TeamsInfo', function () { await assert.rejects( TeamsInfo.getTeamMembers(context), - new Error('This method is only valid within the scope of a MS Teams Team.') + new Error('This method is only valid within the scope of a MS Teams Team.'), ); }); @@ -856,7 +856,7 @@ describe('TeamsInfo', function () { await assert.rejects( TeamsInfo.getTeamMembers(context), - new Error('This method is only valid within the scope of a MS Teams Team.') + new Error('This method is only valid within the scope of a MS Teams Team.'), ); }); @@ -899,7 +899,7 @@ describe('TeamsInfo', function () { assert.deepStrictEqual( fetchedMembers, - members.map((member) => ({ ...member, aadObjectId: member.objectId })) + members.map((member) => ({ ...member, aadObjectId: member.objectId })), ); }); @@ -942,7 +942,7 @@ describe('TeamsInfo', function () { assert.deepStrictEqual( fetchedMembers, - members.map((member) => ({ ...member, aadObjectId: member.objectId })) + members.map((member) => ({ ...member, aadObjectId: member.objectId })), ); }); }); @@ -1015,7 +1015,7 @@ describe('TeamsInfo', function () { const sendTeamsMeetingNotification = await TeamsInfo.sendMeetingNotification( context, notification, - meetingId + meetingId, ); assert(sendTeamsMeetingNotificationExpectation.isDone()); @@ -1054,7 +1054,7 @@ describe('TeamsInfo', function () { const sendTeamsMeetingNotification = await TeamsInfo.sendMeetingNotification( context, notification, - meetingId + meetingId, ); assert(sendTeamsMeetingNotificationExpectation.isDone()); @@ -1125,7 +1125,7 @@ describe('TeamsInfo', function () { const sendTeamsMeetingNotificationExpectation = nock('https://smba.trafficmanager.net/amer') .post( `/v1/meetings/${encodeURIComponent(teamActivity.channelData.meeting.id)}/notification`, - notification + notification, ) .matchHeader('Authorization', expectedAuthHeader) .reply(202, {}); @@ -1226,21 +1226,21 @@ describe('TeamsInfo', function () { it('should throw an error if an empty activity is provided', async function () { await assert.rejects( TeamsInfo.sendMessageToListOfUsers(context, null, tenantId, members), - Error('activity is required.') + Error('activity is required.'), ); }); it('should throw an error if an empty member list is provided', async function () { await assert.rejects( TeamsInfo.sendMessageToListOfUsers(context, activity, tenantId, null), - Error('members list is required.') + Error('members list is required.'), ); }); it('should throw an error if an empty tenant id is provided', async function () { await assert.rejects( TeamsInfo.sendMessageToListOfUsers(context, activity, null, members), - Error('tenantId is required.') + Error('tenantId is required.'), ); }); }); @@ -1319,14 +1319,14 @@ describe('TeamsInfo', function () { it('should throw an error if an empty activity is provided', async function () { await assert.rejects( TeamsInfo.sendMessageToAllUsersInTenant(context, null, tenantId), - Error('activity is required.') + Error('activity is required.'), ); }); it('should throw an error if an empty tenant id is provided', async function () { await assert.rejects( TeamsInfo.sendMessageToAllUsersInTenant(context, activity, null), - Error('tenantId is required.') + Error('tenantId is required.'), ); }); }); @@ -1407,21 +1407,21 @@ describe('TeamsInfo', function () { it('should throw an error if an empty activity is provided', async function () { await assert.rejects( TeamsInfo.sendMessageToAllUsersInTeam(context, null, tenantId, teamId), - Error('activity is required.') + Error('activity is required.'), ); }); it('should throw an error if an empty tenant id is provided', async function () { await assert.rejects( TeamsInfo.sendMessageToAllUsersInTeam(context, activity, null, teamId), - Error('tenantId is required.') + Error('tenantId is required.'), ); }); it('should throw an error if an empty team id is provided', async function () { await assert.rejects( TeamsInfo.sendMessageToAllUsersInTeam(context, activity, teamId, null), - Error('teamId is required.') + Error('teamId is required.'), ); }); }); @@ -1514,21 +1514,21 @@ describe('TeamsInfo', function () { it('should throw an error if an empty activity is provided', async function () { await assert.rejects( TeamsInfo.sendMessageToListOfChannels(context, null, tenantId, members), - Error('activity is required.') + Error('activity is required.'), ); }); it('should throw an error if an empty member list is provided', async function () { await assert.rejects( TeamsInfo.sendMessageToListOfChannels(context, activity, tenantId, null), - Error('members list is required.') + Error('members list is required.'), ); }); it('should throw an error if an empty tenant id is provided', async function () { await assert.rejects( TeamsInfo.sendMessageToListOfChannels(context, activity, null, members), - Error('tenantId is required.') + Error('tenantId is required.'), ); }); }); @@ -1716,7 +1716,7 @@ describe('TeamsInfo', function () { it("should error if the context doesn't have an adapter", function () { assert.throws( () => TeamsInfo.getConnectorClient({}), - new Error('This method requires a connector client.') + new Error('This method requires a connector client.'), ); }); @@ -1729,30 +1729,31 @@ describe('TeamsInfo', function () { }); describe('getMembersInternal()', function () { - it('should error if an invalid conversationId is passed in.', async function () { + it('getMembers should throw error if an invalid conversationId is passed in.', async function () { await assert.rejects( TeamsInfo.getMembersInternal({}, undefined), - new Error('The getMembers operation needs a valid conversationId.') + new Error('The getMembers operation needs a valid conversationId.'), ); }); - it('should error if an invalid conversationId is passed in.', async function () { + it('getMember should throw error if an invalid conversationId is passed in.', async function () { await assert.rejects( TeamsInfo.getMemberInternal({}, undefined), - new Error('The getMember operation needs a valid conversationId.') + new Error('The getMember operation needs a valid conversationId.'), ); }); it('should error if an invalid userId is passed in.', async function () { await assert.rejects( TeamsInfo.getMemberInternal({}, 'conversationId', undefined), - new Error('The getMember operation needs a valid userId.') + new Error('The getMember operation needs a valid userId.'), ); }); }); describe('getPagedMembersInternal()', function () { let sandbox; + beforeEach(function () { sandbox = sinon.createSandbox(); }); @@ -1764,7 +1765,7 @@ describe('TeamsInfo', function () { it('should error if an invalid conversationId is passed in.', async function () { await assert.rejects( TeamsInfo.getPagedMembersInternal({}, undefined, 'options'), - new Error('The getPagedMembers operation needs a valid conversationId.') + new Error('The getPagedMembers operation needs a valid conversationId.'), ); }); @@ -1802,7 +1803,7 @@ describe('TeamsInfo', function () { assert.strictEqual( getPagedMembers.calledOnce, true, - 'should have called conversations.getConversationPagedMembers' + 'should have called conversations.getConversationPagedMembers', ); }); });