From 455fa404bd7c5c9ee93c9701ed3b18baa6e55374 Mon Sep 17 00:00:00 2001 From: Joel Mut Date: Fri, 20 Oct 2023 21:07:23 +0200 Subject: [PATCH] Fix lint and depcheck issues --- libraries/botbuilder/package.json | 1 + .../src/auth/authenticatorResult.ts | 2 +- .../src/auth/certificateAppCredentials.ts | 15 ++++++++++----- .../src/auth/microsoftAppCredentials.ts | 6 +++--- .../tests/appCredentials.test.js | 5 +---- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libraries/botbuilder/package.json b/libraries/botbuilder/package.json index 50cd274dff..257891e736 100644 --- a/libraries/botbuilder/package.json +++ b/libraries/botbuilder/package.json @@ -28,6 +28,7 @@ }, "dependencies": { "@azure/ms-rest-js": "^2.7.0", + "@azure/msal-node": "^1.2.0", "axios": "^0.25.0", "botbuilder-core": "4.1.6", "botbuilder-stdlib": "4.1.6", diff --git a/libraries/botframework-connector/src/auth/authenticatorResult.ts b/libraries/botframework-connector/src/auth/authenticatorResult.ts index bba86c8673..12e087efe5 100644 --- a/libraries/botframework-connector/src/auth/authenticatorResult.ts +++ b/libraries/botframework-connector/src/auth/authenticatorResult.ts @@ -15,4 +15,4 @@ export interface AuthenticatorResult { * The date and time of expiration relative to Coordinated Universal Time (UTC). */ expiresOn: Date; -}; +} diff --git a/libraries/botframework-connector/src/auth/certificateAppCredentials.ts b/libraries/botframework-connector/src/auth/certificateAppCredentials.ts index 3907d87d09..ec9737ef41 100644 --- a/libraries/botframework-connector/src/auth/certificateAppCredentials.ts +++ b/libraries/botframework-connector/src/auth/certificateAppCredentials.ts @@ -38,19 +38,24 @@ export class CertificateAppCredentials extends AppCredentials { certificatePrivateKey: string, channelAuthTenant?: string, oAuthScope?: string, - x5c?: string, + x5c?: string ) { super(appId, channelAuthTenant, oAuthScope); this.certificateThumbprint = certificateThumbprint; this.certificatePrivateKey = certificatePrivateKey; this.x5c = x5c; } - + /** * @inheritdoc - */ - async getToken(forceRefresh = false): Promise { - this.credentials ??= new MsalAppCredentials(this.createClientApplication(), this.appId, this.oAuthEndpoint, this.oAuthScope); + */ + async getToken(forceRefresh = false): Promise { + this.credentials ??= new MsalAppCredentials( + this.createClientApplication(), + this.appId, + this.oAuthEndpoint, + this.oAuthScope + ); return this.credentials.getToken(forceRefresh); } diff --git a/libraries/botframework-connector/src/auth/microsoftAppCredentials.ts b/libraries/botframework-connector/src/auth/microsoftAppCredentials.ts index d8b756b062..b98e57355a 100644 --- a/libraries/botframework-connector/src/auth/microsoftAppCredentials.ts +++ b/libraries/botframework-connector/src/auth/microsoftAppCredentials.ts @@ -32,11 +32,11 @@ export class MicrosoftAppCredentials extends AppCredentials { constructor(appId: string, public appPassword: string, channelAuthTenant?: string, oAuthScope?: string) { super(appId, channelAuthTenant, oAuthScope); } - + /** * @inheritdoc - */ - async getToken(forceRefresh = false): Promise { + */ + async getToken(forceRefresh = false): Promise { this.credentials ??= new MsalAppCredentials(this.appId, this.appPassword, this.oAuthEndpoint, this.oAuthScope); return this.credentials.getToken(forceRefresh); } diff --git a/libraries/botframework-connector/tests/appCredentials.test.js b/libraries/botframework-connector/tests/appCredentials.test.js index c8b5be7ba4..77f75dd5e9 100644 --- a/libraries/botframework-connector/tests/appCredentials.test.js +++ b/libraries/botframework-connector/tests/appCredentials.test.js @@ -84,10 +84,7 @@ describe('AppCredentials', function () { it('should fail to get a token with an appId and no appPassword', async function () { const tokenGenerator = new MicrosoftAppCredentials(APP_ID); - await assert.rejects( - tokenGenerator.getToken(true), - { errorCode: "invalid_client_credential" } - ); + await assert.rejects(tokenGenerator.getToken(true), { errorCode: 'invalid_client_credential' }); }); }); });