@microsoft/agents-hosting 1.6.0-beta.4.g8ab0e486bc → 1.6.0-beta.41.g36be9b7b46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/package.json +5 -9
  2. package/dist/src/agent-client/agentClient.js +2 -2
  3. package/dist/src/agent-client/agentClient.js.map +1 -1
  4. package/dist/src/agent-client/agentResponseHandler.js +2 -2
  5. package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
  6. package/dist/src/app/agentApplication.js +27 -2
  7. package/dist/src/app/agentApplication.js.map +1 -1
  8. package/dist/src/app/auth/authorizationManager.d.ts +4 -0
  9. package/dist/src/app/auth/authorizationManager.js +94 -67
  10. package/dist/src/app/auth/authorizationManager.js.map +1 -1
  11. package/dist/src/app/auth/handlers/azureBotAuthorization.js +2 -2
  12. package/dist/src/app/auth/handlers/azureBotAuthorization.js.map +1 -1
  13. package/dist/src/app/proactive/createConversationOptionsBuilder.js +10 -6
  14. package/dist/src/app/proactive/createConversationOptionsBuilder.js.map +1 -1
  15. package/dist/src/app/teamsAttachmentDownloader.js +7 -1
  16. package/dist/src/app/teamsAttachmentDownloader.js.map +1 -1
  17. package/dist/src/auth/authConfiguration.d.ts +2 -143
  18. package/dist/src/auth/authConfiguration.js +301 -257
  19. package/dist/src/auth/authConfiguration.js.map +1 -1
  20. package/dist/src/auth/jwt-middleware.js +2 -1
  21. package/dist/src/auth/jwt-middleware.js.map +1 -1
  22. package/dist/src/auth/msalConnectionManager.js +27 -14
  23. package/dist/src/auth/msalConnectionManager.js.map +1 -1
  24. package/dist/src/auth/msalTokenProvider.d.ts +7 -0
  25. package/dist/src/auth/msalTokenProvider.js +156 -38
  26. package/dist/src/auth/msalTokenProvider.js.map +1 -1
  27. package/dist/src/auth/settings.d.ts +327 -0
  28. package/dist/src/auth/settings.js +158 -0
  29. package/dist/src/auth/settings.js.map +1 -0
  30. package/dist/src/cloudAdapter.d.ts +51 -1
  31. package/dist/src/cloudAdapter.js +219 -50
  32. package/dist/src/cloudAdapter.js.map +1 -1
  33. package/dist/src/connector-client/connectorClient.d.ts +2 -2
  34. package/dist/src/connector-client/connectorClient.js +7 -8
  35. package/dist/src/connector-client/connectorClient.js.map +1 -1
  36. package/dist/src/errorHelper.js +50 -0
  37. package/dist/src/errorHelper.js.map +1 -1
  38. package/dist/src/index.d.ts +1 -1
  39. package/dist/src/index.js +6 -2
  40. package/dist/src/index.js.map +1 -1
  41. package/dist/src/oauth/userTokenClient.js +1 -1
  42. package/dist/src/oauth/userTokenClient.js.map +1 -1
  43. package/dist/src/observability/traces.d.ts +1 -1
  44. package/dist/src/observability/traces.js +2 -2
  45. package/dist/src/observability/traces.js.map +1 -1
  46. package/dist/src/utils/env.d.ts +50 -0
  47. package/dist/src/utils/env.js +113 -0
  48. package/dist/src/utils/env.js.map +1 -0
  49. package/dist/src/utils.d.ts +10 -0
  50. package/dist/src/utils.js +18 -0
  51. package/dist/src/utils.js.map +1 -0
  52. package/package.json +5 -9
  53. package/src/agent-client/agentClient.ts +2 -2
  54. package/src/agent-client/agentResponseHandler.ts +2 -2
  55. package/src/app/agentApplication.ts +28 -3
  56. package/src/app/auth/authorizationManager.ts +84 -41
  57. package/src/app/auth/handlers/azureBotAuthorization.ts +2 -2
  58. package/src/app/proactive/createConversationOptionsBuilder.ts +8 -4
  59. package/src/app/teamsAttachmentDownloader.ts +6 -1
  60. package/src/auth/authConfiguration.ts +317 -356
  61. package/src/auth/jwt-middleware.ts +1 -1
  62. package/src/auth/msalConnectionManager.ts +27 -10
  63. package/src/auth/msalTokenProvider.ts +143 -33
  64. package/src/auth/settings.ts +323 -0
  65. package/src/cloudAdapter.ts +272 -10
  66. package/src/connector-client/connectorClient.ts +8 -8
  67. package/src/errorHelper.ts +57 -0
  68. package/src/index.ts +4 -1
  69. package/src/oauth/userTokenClient.ts +1 -1
  70. package/src/observability/traces.ts +2 -2
  71. package/src/utils/env.ts +105 -0
  72. package/src/utils.ts +14 -0
@@ -21,7 +21,7 @@ const logger = debug('agents:jwt-middleware')
21
21
  export function buildJwksUri (iss: string, authConfig: AuthConfiguration): string {
22
22
  return iss === 'https://api.botframework.com'
23
23
  ? 'https://login.botframework.com/v1/.well-known/keys'
24
- : `${resolveAuthority(authConfig.authority, authConfig.tenantId)}/discovery/v2.0/keys`
24
+ : `${resolveAuthority(authConfig.authorityEndpoint ?? authConfig.authority, authConfig.tenantId)}/discovery/v2.0/keys`
25
25
  }
26
26
 
27
27
  /**
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { Activity, RoleTypes } from '@microsoft/agents-activity'
7
7
  import { debug } from '@microsoft/agents-telemetry'
8
- import { AuthConfiguration, resolveAuthority } from './authConfiguration'
8
+ import { AuthConfiguration, AuthType, resolveAuthority } from './authConfiguration'
9
9
  import { Connections } from './connections'
10
10
  import { MsalTokenProvider } from './msalTokenProvider'
11
11
  import { JwtPayload } from 'jsonwebtoken'
@@ -44,13 +44,16 @@ export class MsalConnectionManager implements Connections {
44
44
 
45
45
  for (const [name, provider] of this._connections.entries()) {
46
46
  const cfg = provider.connectionSettings
47
- const authType = cfg?.certPemFile
48
- ? 'certificate'
49
- : cfg?.clientSecret
50
- ? 'clientSecret'
51
- : cfg?.WIDAssertionFile || cfg?.FICClientId
52
- ? 'workloadIdentity'
53
- : 'none'
47
+ const authType = cfg?.authType ??
48
+ (cfg?.certPemFile
49
+ ? AuthType.Certificate
50
+ : cfg?.clientSecret
51
+ ? AuthType.ClientSecret
52
+ : cfg?.WIDAssertionFile
53
+ ? AuthType.WorkloadIdentity
54
+ : cfg?.federatedClientId || cfg?.FICClientId
55
+ ? AuthType.FederatedCredentials
56
+ : 'none')
54
57
  logger.debug('connection "%s" clientId=%s tenantId=%s authType=%s', name, cfg?.clientId ?? '<none>', cfg?.tenantId ?? '<none>', authType)
55
58
  }
56
59
 
@@ -185,13 +188,27 @@ export class MsalConnectionManager implements Connections {
185
188
 
186
189
  private applyConnectionDefaults (conn: MsalTokenProvider): MsalTokenProvider {
187
190
  if (conn.connectionSettings) {
188
- conn.connectionSettings.authority ??= 'https://login.microsoftonline.com'
191
+ conn.connectionSettings.authorityEndpoint ??= conn.connectionSettings.authority || 'https://login.microsoftonline.com'
192
+ conn.connectionSettings.authority ??= conn.connectionSettings.authorityEndpoint
189
193
  conn.connectionSettings.issuers ??= [
190
194
  'https://api.botframework.com',
191
195
  `${resolveAuthority('https://sts.windows.net', conn.connectionSettings.tenantId)}/`,
192
- `${resolveAuthority(conn.connectionSettings.authority, conn.connectionSettings.tenantId)}/v2.0`
196
+ `${resolveAuthority(conn.connectionSettings.authorityEndpoint, conn.connectionSettings.tenantId)}/v2.0`
193
197
  ]
198
+ // For backward compatibility
199
+ if (conn.connectionSettings.federatedClientId) {
200
+ conn.connectionSettings.FICClientId = conn.connectionSettings.federatedClientId
201
+ }
202
+
203
+ if (conn.connectionSettings.scopes?.length) {
204
+ conn.connectionSettings.scope = conn.connectionSettings.scopes?.[0]
205
+ }
206
+
207
+ if (conn.connectionSettings.authorityEndpoint) {
208
+ conn.connectionSettings.authority = conn.connectionSettings.authorityEndpoint
209
+ }
194
210
  }
211
+
195
212
  return conn
196
213
  }
197
214
  }
@@ -5,16 +5,18 @@
5
5
 
6
6
  import { ConfidentialClientApplication, LogLevel, ManagedIdentityApplication, NodeSystemOptions } from '@azure/msal-node'
7
7
  import axios from 'axios'
8
- import { AuthConfiguration, resolveAuthority as resolveAuthorityUtil } from './authConfiguration'
8
+ import { AuthConfiguration, AuthType, resolveAuthority as resolveAuthorityUtil } from './authConfiguration'
9
9
  import { AuthProvider } from './authProvider'
10
10
  import { debug, trace } from '@microsoft/agents-telemetry'
11
- import { v4 } from 'uuid'
11
+ import { randomUUID } from 'crypto'
12
12
  import { MemoryCache } from './MemoryCache'
13
13
  import jwt from 'jsonwebtoken'
14
14
 
15
15
  import fs from 'fs'
16
16
  import crypto from 'crypto'
17
17
  import { AuthenticationTraceDefinitions } from '../observability'
18
+ import { ExceptionHelper } from '@microsoft/agents-activity'
19
+ import { Errors } from '../errorHelper'
18
20
 
19
21
  const audience = 'api://AzureADTokenExchange'
20
22
  const logger = debug('agents:msal')
@@ -70,34 +72,77 @@ export class MsalTokenProvider implements AuthProvider {
70
72
  }
71
73
 
72
74
  let token
73
- if (authConfig.WIDAssertionFile !== undefined) {
74
- record({ method: 'wid' })
75
- logger.debug('getAccessToken via WID clientId=%s scope=%s', authConfig.clientId, actualScope)
75
+ if (authConfig.authType) {
76
+ record({ method: authConfig.authType })
77
+ logger.debug(`getAccessToken via ${authConfig.authType} clientId=${authConfig.clientId} scope=${actualScope}`)
78
+ switch (authConfig.authType) {
79
+ case AuthType.WorkloadIdentity: {
80
+ const tokenFilePath = authConfig.federatedTokenFile ?? authConfig.WIDAssertionFile
81
+ if (!tokenFilePath) {
82
+ throw ExceptionHelper.generateException(Error, Errors.WorkloadIdentityTokenFileRequired)
83
+ }
84
+ token = await this.acquireAccessTokenViaWID(authConfig, actualScope)
85
+ break
86
+ }
87
+ case AuthType.FederatedCredentials:
88
+ if (!authConfig.federatedClientId && !authConfig.FICClientId) {
89
+ throw ExceptionHelper.generateException(Error, Errors.FICClientIdRequired)
90
+ }
91
+ token = await this.acquireAccessTokenViaFIC(authConfig, actualScope)
92
+ break
93
+ case AuthType.ClientSecret:
94
+ if (!authConfig.clientSecret) {
95
+ throw ExceptionHelper.generateException(Error, Errors.ClientSecretRequired)
96
+ }
97
+ token = await this.acquireAccessTokenViaSecret(authConfig, actualScope)
98
+ break
99
+ case AuthType.Certificate:
100
+ case AuthType.CertificateSubjectName:
101
+ if (!authConfig.certPemFile || !authConfig.certKeyFile) {
102
+ throw ExceptionHelper.generateException(Error, Errors.CertificateFilesRequired)
103
+ }
104
+ token = await this.acquireTokenWithCertificate(authConfig, actualScope)
105
+ break
106
+ case AuthType.UserManagedIdentity:
107
+ if (!authConfig.clientId) {
108
+ throw ExceptionHelper.generateException(Error, Errors.ClientIdRequiredForUserManagedIdentity)
109
+ }
110
+ token = await this.acquireTokenWithUserAssignedIdentity(authConfig, actualScope)
111
+ break
112
+ case AuthType.SystemManagedIdentity:
113
+ token = await this.acquireTokenWithSystemAssignedIdentity(authConfig, actualScope)
114
+ break
115
+ default:
116
+ throw ExceptionHelper.generateException(Error, Errors.UnsupportedAuthType, undefined, { authType: authConfig.authType })
117
+ }
118
+ } else if (authConfig.WIDAssertionFile !== undefined) {
119
+ record({ method: AuthType.WorkloadIdentity })
120
+ logger.debug('getAccessToken via method=%s clientId=%s scope=%s', AuthType.WorkloadIdentity, authConfig.clientId, actualScope)
76
121
  token = await this.acquireAccessTokenViaWID(authConfig, actualScope)
77
- } else if (authConfig.FICClientId !== undefined) {
78
- record({ method: 'fic' })
79
- logger.debug('getAccessToken via FIC clientId=%s scope=%s', authConfig.clientId, actualScope)
122
+ } else if (authConfig.federatedClientId !== undefined || authConfig.FICClientId !== undefined) {
123
+ record({ method: AuthType.FederatedCredentials })
124
+ logger.debug('getAccessToken via method=%s clientId=%s scope=%s', AuthType.FederatedCredentials, authConfig.clientId, actualScope)
80
125
  token = await this.acquireAccessTokenViaFIC(authConfig, actualScope)
81
126
  } else if (authConfig.clientSecret !== undefined) {
82
- record({ method: 'secret' })
83
- logger.debug('getAccessToken via secret clientId=%s scope=%s', authConfig.clientId, actualScope)
127
+ record({ method: AuthType.ClientSecret })
128
+ logger.debug('getAccessToken via method=%s clientId=%s scope=%s', AuthType.ClientSecret, authConfig.clientId, actualScope)
84
129
  token = await this.acquireAccessTokenViaSecret(authConfig, actualScope)
85
130
  } else if (authConfig.certPemFile !== undefined &&
86
131
  authConfig.certKeyFile !== undefined) {
87
- record({ method: 'certificate' })
88
- logger.debug('getAccessToken via certificate clientId=%s scope=%s', authConfig.clientId, actualScope)
132
+ record({ method: AuthType.Certificate })
133
+ logger.debug('getAccessToken via method=%s clientId=%s scope=%s', AuthType.Certificate, authConfig.clientId, actualScope)
89
134
  token = await this.acquireTokenWithCertificate(authConfig, actualScope)
90
135
  } else if (authConfig.clientSecret === undefined &&
91
136
  authConfig.certPemFile === undefined &&
92
137
  authConfig.certKeyFile === undefined) {
93
- record({ method: 'managed_identity' })
94
- logger.debug('getAccessToken via managed identity clientId=%s scope=%s', authConfig.clientId, actualScope)
138
+ record({ method: AuthType.UserManagedIdentity })
139
+ logger.debug('getAccessToken via method=%s clientId=%s scope=%s', AuthType.UserManagedIdentity, authConfig.clientId, actualScope)
95
140
  token = await this.acquireTokenWithUserAssignedIdentity(authConfig, actualScope)
96
141
  } else {
97
- throw new Error('Invalid authConfig. ')
142
+ throw ExceptionHelper.generateException(Error, Errors.InvalidAuthConfig)
98
143
  }
99
144
  if (token === undefined) {
100
- throw new Error('Failed to acquire token')
145
+ throw ExceptionHelper.generateException(Error, Errors.FailedToAcquireToken)
101
146
  }
102
147
 
103
148
  return token
@@ -137,7 +182,7 @@ export class MsalTokenProvider implements AuthProvider {
137
182
  const cca = new ConfidentialClientApplication({
138
183
  auth: {
139
184
  clientId: authConfig.clientId as string,
140
- authority: `${authConfig.authority}/${authConfig.tenantId || 'botframework.com'}`,
185
+ authority: `${authConfig.authorityEndpoint ?? authConfig.authority}/${authConfig.tenantId || 'botframework.com'}`,
141
186
  clientSecret: authConfig.clientSecret
142
187
  },
143
188
  system: this.sysOptions
@@ -174,7 +219,7 @@ export class MsalTokenProvider implements AuthProvider {
174
219
 
175
220
  const token = await cca.acquireTokenByClientCredential({
176
221
  scopes: ['api://AzureAdTokenExchange/.default'],
177
- correlationId: v4(),
222
+ correlationId: randomUUID(),
178
223
  azureRegion: this.connectionSettings?.azureRegion
179
224
  })
180
225
 
@@ -193,16 +238,16 @@ export class MsalTokenProvider implements AuthProvider {
193
238
  * @returns
194
239
  */
195
240
  private resolveAuthority (tenantId?: string) : string {
196
- const { authority: configuredAuth, tenantId: configuredTenantId } = this.connectionSettings ?? {}
241
+ const { authorityEndpoint: configuredAuth, authority, tenantId: configuredTenantId } = this.connectionSettings ?? {}
197
242
 
198
243
  if (!tenantId) {
199
244
  // No agentic tenant override — delegate to shared utility
200
- return resolveAuthorityUtil(configuredAuth, configuredTenantId)
245
+ return resolveAuthorityUtil(configuredAuth ?? authority, configuredTenantId)
201
246
  }
202
247
 
203
248
  // Agentic override: build a clean base using the override tenant, then replace any
204
249
  // /common or GUID placeholder left in the authority (e.g. from a multi-tenant config)
205
- const base = resolveAuthorityUtil(configuredAuth, tenantId)
250
+ const base = resolveAuthorityUtil(configuredAuth ?? authority, tenantId)
206
251
  const guidPattern = /\/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/
207
252
 
208
253
  if (base.endsWith('/common') || guidPattern.test(base)) {
@@ -303,12 +348,60 @@ export class MsalTokenProvider implements AuthProvider {
303
348
  }
304
349
  logger.debug('getAgenticApplicationToken clientId=%s tenantId=%s agentAppInstanceId=%s', this.connectionSettings.clientId, tenantId, agentAppInstanceId)
305
350
 
351
+ if (this.connectionSettings.authType === AuthType.IdentityProxyManager) {
352
+ let resource: string
353
+ if (!this.connectionSettings.idpmResource) {
354
+ resource = 'api://AzureAdTokenExchange/.default'
355
+ } else if (!URL.canParse(this.connectionSettings.idpmResource)) {
356
+ throw new Error('idpmResource must be a valid absolute URI')
357
+ } else {
358
+ resource = this.connectionSettings.idpmResource
359
+ }
360
+ const msiApp = new ManagedIdentityApplication({
361
+ managedIdentityIdParams: {
362
+ userAssignedClientId: this.connectionSettings.clientId
363
+ },
364
+ system: this.sysOptions
365
+ })
366
+ const tokenResult = await msiApp.acquireToken({ resource })
367
+ if (!tokenResult?.accessToken) {
368
+ throw new Error(`Failed to acquire token via IdentityProxyManager for agent instance: ${agentAppInstanceId}`)
369
+ }
370
+ logger.debug('getAgenticApplicationToken via IdentityProxyManager clientId=%s resource=%s', this.connectionSettings.clientId, resource)
371
+ return tokenResult.accessToken
372
+ }
373
+
306
374
  let clientAssertion
307
375
 
308
- if (this.connectionSettings.WIDAssertionFile !== undefined) {
309
- clientAssertion = fs.readFileSync(this.connectionSettings.WIDAssertionFile as string, 'utf8')
310
- } else if (this.connectionSettings.FICClientId !== undefined) {
311
- clientAssertion = await this.fetchExternalToken(this.connectionSettings.FICClientId as string)
376
+ if (this.connectionSettings.authType) {
377
+ switch (this.connectionSettings.authType) {
378
+ case AuthType.WorkloadIdentity: {
379
+ const tokenFilePath = this.connectionSettings.federatedTokenFile ?? this.connectionSettings.WIDAssertionFile
380
+ if (tokenFilePath === undefined) {
381
+ throw ExceptionHelper.generateException(Error, Errors.WorkloadIdentityTokenFileRequired)
382
+ }
383
+ clientAssertion = fs.readFileSync(tokenFilePath as string, 'utf8')
384
+ break
385
+ }
386
+ case AuthType.FederatedCredentials:
387
+ if (!this.connectionSettings.federatedClientId && !this.connectionSettings.FICClientId) {
388
+ throw ExceptionHelper.generateException(Error, Errors.FICClientIdRequired)
389
+ }
390
+ clientAssertion = await this.fetchExternalToken(this.connectionSettings.federatedClientId as string || this.connectionSettings.FICClientId as string)
391
+ break
392
+ case AuthType.Certificate:
393
+ case AuthType.CertificateSubjectName:
394
+ if (!this.connectionSettings.certPemFile || !this.connectionSettings.certKeyFile) {
395
+ throw ExceptionHelper.generateException(Error, Errors.CertificateFilesRequired)
396
+ }
397
+ clientAssertion = this.getAssertionFromCert(this.connectionSettings)
398
+ break
399
+ }
400
+ } else if (this.connectionSettings.WIDAssertionFile !== undefined) {
401
+ const tokenFilePath = this.connectionSettings.federatedTokenFile ?? this.connectionSettings.WIDAssertionFile
402
+ clientAssertion = fs.readFileSync(tokenFilePath as string, 'utf8')
403
+ } else if (this.connectionSettings.federatedClientId !== undefined || this.connectionSettings.FICClientId !== undefined) {
404
+ clientAssertion = await this.fetchExternalToken(this.connectionSettings.federatedClientId as string || this.connectionSettings.FICClientId as string)
312
405
  } else if (this.connectionSettings.certPemFile !== undefined &&
313
406
  this.connectionSettings.certKeyFile !== undefined) {
314
407
  clientAssertion = this.getAssertionFromCert(this.connectionSettings)
@@ -380,7 +473,7 @@ export class MsalTokenProvider implements AuthProvider {
380
473
  aud: `${this.resolveAuthority(authConfig.tenantId)}/oauth2/v2.0/token`,
381
474
  iss: authConfig.clientId,
382
475
  sub: authConfig.clientId,
383
- jti: v4(),
476
+ jti: randomUUID(),
384
477
  nbf: now,
385
478
  iat: now,
386
479
  exp: now + 600, // 10 minutes
@@ -415,6 +508,22 @@ export class MsalTokenProvider implements AuthProvider {
415
508
  return token?.accessToken
416
509
  }
417
510
 
511
+ /**
512
+ * Acquires a token using a system-assigned identity.
513
+ * @param authConfig The authentication configuration.
514
+ * @param scope The scope for the token.
515
+ * @returns A promise that resolves to the access token.
516
+ */
517
+ private async acquireTokenWithSystemAssignedIdentity (authConfig: AuthConfiguration, scope: string) {
518
+ const mia = new ManagedIdentityApplication({
519
+ system: this.sysOptions
520
+ })
521
+ const token = await mia.acquireToken({
522
+ resource: scope
523
+ })
524
+ return token?.accessToken
525
+ }
526
+
418
527
  /**
419
528
  * Acquires a token using a certificate.
420
529
  * @param authConfig The authentication configuration.
@@ -440,7 +549,7 @@ export class MsalTokenProvider implements AuthProvider {
440
549
  const cca = new ConfidentialClientApplication({
441
550
  auth: {
442
551
  clientId: authConfig.clientId || '',
443
- authority: `${authConfig.authority}/${authConfig.tenantId || 'botframework.com'}`,
552
+ authority: `${authConfig.authorityEndpoint ?? authConfig.authority}/${authConfig.tenantId || 'botframework.com'}`,
444
553
  clientCertificate: {
445
554
  privateKey: privateKey as string,
446
555
  thumbprint: pubKeyObject.fingerprint.replaceAll(':', ''),
@@ -451,7 +560,7 @@ export class MsalTokenProvider implements AuthProvider {
451
560
  })
452
561
  const token = await cca.acquireTokenByClientCredential({
453
562
  scopes: [`${scope}/.default`],
454
- correlationId: v4(),
563
+ correlationId: randomUUID(),
455
564
  azureRegion: authConfig.azureRegion
456
565
  })
457
566
  if (!token?.accessToken) {
@@ -470,14 +579,14 @@ export class MsalTokenProvider implements AuthProvider {
470
579
  const cca = new ConfidentialClientApplication({
471
580
  auth: {
472
581
  clientId: authConfig.clientId as string,
473
- authority: `${authConfig.authority}/${authConfig.tenantId || 'botframework.com'}`,
582
+ authority: `${authConfig.authorityEndpoint ?? authConfig.authority}/${authConfig.tenantId || 'botframework.com'}`,
474
583
  clientSecret: authConfig.clientSecret
475
584
  },
476
585
  system: this.sysOptions
477
586
  })
478
587
  const token = await cca.acquireTokenByClientCredential({
479
588
  scopes: [`${scope}/.default`],
480
- correlationId: v4(),
589
+ correlationId: randomUUID(),
481
590
  azureRegion: authConfig.azureRegion
482
591
  })
483
592
  if (!token?.accessToken) {
@@ -494,11 +603,11 @@ export class MsalTokenProvider implements AuthProvider {
494
603
  */
495
604
  private async acquireAccessTokenViaFIC (authConfig: AuthConfiguration, scope: string) : Promise<string> {
496
605
  const scopes = [`${scope}/.default`]
497
- const clientAssertion = await this.fetchExternalToken(authConfig.FICClientId as string)
606
+ const clientAssertion = await this.fetchExternalToken(authConfig.federatedClientId as string || authConfig.FICClientId as string)
498
607
  const cca = new ConfidentialClientApplication({
499
608
  auth: {
500
609
  clientId: authConfig.clientId as string,
501
- authority: `${authConfig.authority}/${authConfig.tenantId}`,
610
+ authority: `${authConfig.authorityEndpoint ?? authConfig.authority}/${authConfig.tenantId}`,
502
611
  clientAssertion
503
612
  },
504
613
  system: this.sysOptions
@@ -519,7 +628,8 @@ export class MsalTokenProvider implements AuthProvider {
519
628
  */
520
629
  private async acquireAccessTokenViaWID (authConfig: AuthConfiguration, scope: string) : Promise<string> {
521
630
  const scopes = [`${scope}/.default`]
522
- const clientAssertion = fs.readFileSync(authConfig.WIDAssertionFile as string, 'utf8')
631
+ const tokenFilePath = authConfig.federatedTokenFile ?? authConfig.WIDAssertionFile
632
+ const clientAssertion = fs.readFileSync(tokenFilePath as string, 'utf8')
523
633
  const cca = new ConfidentialClientApplication({
524
634
  auth: {
525
635
  clientId: authConfig.clientId as string,