@microsoft/agents-hosting 0.6.21-g3c2261b2fc → 1.0.0-ge4831811bf

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 (67) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/app/adaptiveCards/adaptiveCardsActions.d.ts +9 -6
  3. package/dist/src/app/adaptiveCards/adaptiveCardsActions.js +3 -3
  4. package/dist/src/app/adaptiveCards/adaptiveCardsActions.js.map +1 -1
  5. package/dist/src/app/adaptiveCards/query.d.ts +1 -1
  6. package/dist/src/app/agentApplication.d.ts +10 -10
  7. package/dist/src/app/agentApplication.js +9 -9
  8. package/dist/src/app/agentApplicationBuilder.d.ts +1 -1
  9. package/dist/src/app/agentApplicationBuilder.js +1 -1
  10. package/dist/src/app/agentApplicationOptions.d.ts +10 -1
  11. package/dist/src/app/appMemory.d.ts +1 -1
  12. package/dist/src/app/appRoute.d.ts +1 -1
  13. package/dist/src/app/extensions.d.ts +1 -1
  14. package/dist/src/app/extensions.js +1 -1
  15. package/dist/src/app/turnState.d.ts +6 -6
  16. package/dist/src/app/turnState.js +6 -6
  17. package/dist/src/app/turnStateProperty.d.ts +2 -2
  18. package/dist/src/app/turnStateProperty.js +2 -2
  19. package/dist/src/auth/authConfiguration.d.ts +8 -0
  20. package/dist/src/auth/authConfiguration.js +14 -6
  21. package/dist/src/auth/authConfiguration.js.map +1 -1
  22. package/dist/src/auth/jwt-middleware.js +1 -1
  23. package/dist/src/auth/jwt-middleware.js.map +1 -1
  24. package/dist/src/auth/msalTokenProvider.js +4 -4
  25. package/dist/src/auth/msalTokenProvider.js.map +1 -1
  26. package/dist/src/cloudAdapter.d.ts +5 -2
  27. package/dist/src/cloudAdapter.js +19 -11
  28. package/dist/src/cloudAdapter.js.map +1 -1
  29. package/dist/src/connector-client/connectorClient.d.ts +9 -7
  30. package/dist/src/connector-client/connectorClient.js +27 -11
  31. package/dist/src/connector-client/connectorClient.js.map +1 -1
  32. package/dist/src/headerPropagation.d.ts +71 -0
  33. package/dist/src/headerPropagation.js +76 -0
  34. package/dist/src/headerPropagation.js.map +1 -0
  35. package/dist/src/oauth/userTokenClient.js +34 -17
  36. package/dist/src/oauth/userTokenClient.js.map +1 -1
  37. package/dist/src/state/agentState.d.ts +2 -2
  38. package/dist/src/state/agentState.js +2 -2
  39. package/dist/src/state/agentStatePropertyAccesor.d.ts +18 -21
  40. package/dist/src/state/agentStatePropertyAccesor.js +18 -21
  41. package/dist/src/state/agentStatePropertyAccesor.js.map +1 -1
  42. package/dist/src/storage/fileStorage.d.ts +12 -10
  43. package/dist/src/storage/fileStorage.js +12 -10
  44. package/dist/src/storage/fileStorage.js.map +1 -1
  45. package/dist/src/transcript/transcriptLogger.d.ts +1 -1
  46. package/package.json +2 -2
  47. package/src/app/adaptiveCards/adaptiveCardsActions.ts +9 -6
  48. package/src/app/adaptiveCards/query.ts +1 -1
  49. package/src/app/agentApplication.ts +10 -10
  50. package/src/app/agentApplicationBuilder.ts +1 -1
  51. package/src/app/agentApplicationOptions.ts +11 -1
  52. package/src/app/appMemory.ts +1 -1
  53. package/src/app/appRoute.ts +1 -1
  54. package/src/app/extensions.ts +1 -1
  55. package/src/app/turnState.ts +6 -6
  56. package/src/app/turnStateProperty.ts +2 -2
  57. package/src/auth/authConfiguration.ts +20 -5
  58. package/src/auth/jwt-middleware.ts +1 -1
  59. package/src/auth/msalTokenProvider.ts +4 -4
  60. package/src/cloudAdapter.ts +24 -12
  61. package/src/connector-client/connectorClient.ts +30 -12
  62. package/src/headerPropagation.ts +129 -0
  63. package/src/oauth/userTokenClient.ts +36 -17
  64. package/src/state/agentState.ts +2 -2
  65. package/src/state/agentStatePropertyAccesor.ts +18 -21
  66. package/src/storage/fileStorage.ts +12 -10
  67. package/src/transcript/transcriptLogger.ts +1 -1
@@ -28,7 +28,7 @@ const TYPING_TIMER_DELAY = 1000
28
28
 
29
29
  /**
30
30
  * Event handler function type for application events.
31
- * @template TState - The state type extending TurnState.
31
+ * @typeParam TState - The state type extending TurnState.
32
32
  * @param context - The turn context containing activity information.
33
33
  * @param state - The current turn state.
34
34
  * @returns A promise that resolves to a boolean indicating whether to continue execution.
@@ -36,9 +36,7 @@ const TYPING_TIMER_DELAY = 1000
36
36
  export type ApplicationEventHandler<TState extends TurnState> = (context: TurnContext, state: TState) => Promise<boolean>
37
37
 
38
38
  /**
39
- * Main application class for handling agent conversations and routing.
40
- *
41
- * @template TState - The state type extending TurnState.
39
+ * @summary Main application class for handling agent conversations and routing.
42
40
  *
43
41
  * @remarks
44
42
  * The AgentApplication class provides a framework for building conversational agents.
@@ -66,6 +64,8 @@ export type ApplicationEventHandler<TState extends TurnState> = (context: TurnCo
66
64
  *
67
65
  * await app.run(turnContext);
68
66
  * ```
67
+ *
68
+ * @typeParam TState - The state type extending TurnState.
69
69
  */
70
70
  export class AgentApplication<TState extends TurnState> {
71
71
  protected readonly _options: AgentApplicationOptions<TState>
@@ -79,7 +79,7 @@ export class AgentApplication<TState extends TurnState> {
79
79
  private readonly _adaptiveCards: AdaptiveCardsActions<TState>
80
80
 
81
81
  /**
82
- * Creates a new instance of AgentApplication.
82
+ * @summary Creates a new instance of AgentApplication.
83
83
  *
84
84
  * @param options - Optional configuration options for the application.
85
85
  *
@@ -142,7 +142,7 @@ export class AgentApplication<TState extends TurnState> {
142
142
  }
143
143
 
144
144
  /**
145
- * Gets the authorization instance for the application.
145
+ * @summary Gets the authorization instance for the application.
146
146
  *
147
147
  * @returns The authorization instance.
148
148
  * @throws Error if no authentication options were configured.
@@ -155,7 +155,7 @@ export class AgentApplication<TState extends TurnState> {
155
155
  }
156
156
 
157
157
  /**
158
- * Gets the options used to configure the application.
158
+ * @summary Gets the options used to configure the application.
159
159
  *
160
160
  * @returns The application options.
161
161
  */
@@ -164,7 +164,7 @@ export class AgentApplication<TState extends TurnState> {
164
164
  }
165
165
 
166
166
  /**
167
- * Gets the adapter used by the application.
167
+ * @summary Gets the adapter used by the application.
168
168
  *
169
169
  * @returns The adapter instance.
170
170
  */
@@ -173,7 +173,7 @@ export class AgentApplication<TState extends TurnState> {
173
173
  }
174
174
 
175
175
  /**
176
- * Gets the adaptive cards actions handler for the application.
176
+ * @summary Gets the adaptive cards actions handler for the application.
177
177
  *
178
178
  * @returns The adaptive cards actions instance.
179
179
  *
@@ -766,7 +766,7 @@ export class AgentApplication<TState extends TurnState> {
766
766
  /**
767
767
  * Registers an extension with the application.
768
768
  *
769
- * @template T - The extension type extending AgentExtension.
769
+ * @typeParam T - The extension type extending AgentExtension.
770
770
  * @param extension - The extension instance to register.
771
771
  * @param regcb - Callback function called after successful registration.
772
772
  * @throws Error if the extension is already registered.
@@ -11,7 +11,7 @@ import { TurnState } from './turnState'
11
11
 
12
12
  /**
13
13
  * Builder class for creating and configuring AgentApplication instances.
14
- * @template TState Type extending TurnState that will be used by the application
14
+ * @typeParam TState Type extending TurnState that will be used by the application
15
15
  */
16
16
  export class AgentApplicationBuilder<TState extends TurnState = TurnState> {
17
17
  protected _options: Partial<AgentApplicationOptions<TState>> = {}
@@ -10,13 +10,14 @@ import { AdaptiveCardsOptions } from './adaptiveCards'
10
10
  import { InputFileDownloader } from './inputFileDownloader'
11
11
  import { AuthorizationHandlers } from './authorization'
12
12
  import { TurnState } from './turnState'
13
+ import { HeaderPropagationDefinition } from '../headerPropagation'
13
14
 
14
15
  /**
15
16
  * Configuration options for creating and initializing an Agent Application.
16
17
  * This interface defines all the configurable aspects of an agent's behavior,
17
18
  * including adapter settings, storage, authorization, and various feature flags.
18
19
  *
19
- * @template TState - The type of turn state that extends TurnState, allowing for
20
+ * @typeParam TState - The type of turn state that extends TurnState, allowing for
20
21
  * custom state management specific to your agent's needs.
21
22
  */
22
23
  export interface AgentApplicationOptions<TState extends TurnState> {
@@ -129,4 +130,13 @@ export interface AgentApplicationOptions<TState extends TurnState> {
129
130
  * Optional. The transcript logger to use for logging conversations. If not provided, no logging will occur.
130
131
  */
131
132
  transcriptLogger?: TranscriptLogger
133
+
134
+ /**
135
+ * Optional. A function to handle header propagation for incoming requests.
136
+ * This allows the agent to manage headers from incoming requests and propagate
137
+ * them to outgoing requests as needed.
138
+ *
139
+ * @default undefined
140
+ */
141
+ headerPropagation?: HeaderPropagationDefinition
132
142
  }
@@ -23,7 +23,7 @@ export interface AppMemory {
23
23
 
24
24
  /**
25
25
  * Gets a value from the specified path.
26
- * @template TValue The expected type of the value
26
+ * @typeParam TValue The expected type of the value
27
27
  * @param path The path to get the value from
28
28
  * @returns The value at the specified path cast to type TValue
29
29
  */
@@ -15,7 +15,7 @@ import { TurnState } from './turnState'
15
15
  * a selector function that determines when the route should be activated with a handler
16
16
  * function that processes the matched activities.
17
17
  *
18
- * @template TState - The type of turn state that extends TurnState, allowing for
18
+ * @typeParam TState - The type of turn state that extends TurnState, allowing for
19
19
  * type-safe access to custom state properties within route handlers
20
20
  *
21
21
  * @example
@@ -9,7 +9,7 @@ import { TurnState } from './turnState'
9
9
  * Represents an extension that adds channel-specific routing functionality to an agent application.
10
10
  * This class allows you to register routes that are only active for a specific channel.
11
11
  *
12
- * @template TState - The type of turn state that extends TurnState
12
+ * @typeParam TState - The type of turn state that extends TurnState
13
13
  */
14
14
  export class AgentExtension<TState extends TurnState> {
15
15
  /** The channel ID that this extension is associated with */
@@ -40,7 +40,7 @@ export interface DefaultTempState {
40
40
  }
41
41
 
42
42
  /**
43
- * Base class defining a collection of turn state scopes.
43
+ * @summary Base class defining a collection of turn state scopes.
44
44
  * @remarks
45
45
  * Developers can create a derived class that extends `TurnState` to add additional state scopes.
46
46
  *
@@ -70,10 +70,10 @@ export interface DefaultTempState {
70
70
  * }
71
71
  * }
72
72
  * ```
73
- * @template TConversationState - Type for conversation-scoped state
74
- * @template TUserState - Type for user-scoped state
75
- * @template TTempState - Type for temporary state that exists only for the current turn
76
- * @template TSSOState - Type for Single Sign-On (SSO) state
73
+ * @typeParam TConversationState - Type for conversation-scoped state
74
+ * @typeParam TUserState - Type for user-scoped state
75
+ * @typeParam TTempState - Type for temporary state that exists only for the current turn
76
+ * @typeParam TSSOState - Type for Single Sign-On (SSO) state
77
77
  */
78
78
  export class TurnState<
79
79
  TConversationState = DefaultConversationState,
@@ -248,7 +248,7 @@ export class TurnState<
248
248
  /**
249
249
  * Gets a value from state by dot-notation path.
250
250
  * Format: "scope.property" or just "property" (defaults to temp scope)
251
- * @template TValue - The type of the value to retrieve
251
+ * @typeParam TValue - The type of the value to retrieve
252
252
  * @param path - The path to the value
253
253
  * @returns The value at the specified path
254
254
  */
@@ -10,7 +10,7 @@ import { TurnState } from './turnState'
10
10
 
11
11
  /**
12
12
  * Maps an application's Turn State property to a State property.
13
- * @template T Optional. Type of the property being mapped. Defaults to any.
13
+ * @typeParam T Optional. Type of the property being mapped. Defaults to any.
14
14
  */
15
15
  export class TurnStateProperty<T = any> implements StatePropertyAccessor<T> {
16
16
  private readonly _state: TurnStateEntry
@@ -60,7 +60,7 @@ export class TurnStateProperty<T = any> implements StatePropertyAccessor<T> {
60
60
 
61
61
  /**
62
62
  * Replace's the state property value.
63
- * @template T
63
+ * @typeParam T
64
64
  * @param {TurnContext} context The context object for the turn.
65
65
  * @param {T} value The value to assign to the state property.
66
66
  * @returns {Promise<void>} A promise that represents the work queued to execute.
@@ -45,7 +45,15 @@ export interface AuthConfiguration {
45
45
  /**
46
46
  * The FIC (First-Party Integration Channel) client ID.
47
47
  */
48
- FICClientId?: string
48
+ FICClientId?: string,
49
+
50
+ /**
51
+ * Entra Authentication Endpoint to use, If not populated the Entra Public Cloud endpoint is assumed.
52
+ * This example of Public Cloud Endpoint is https://login.microsoftonline.com
53
+ @remarks
54
+ see also https://learn.microsoft.com/entra/identity-platform/authentication-national-cloud
55
+ */
56
+ authority?: string
49
57
  }
50
58
 
51
59
  /**
@@ -63,6 +71,7 @@ export interface AuthConfiguration {
63
71
  * FICClientId=your-FIC-client-id
64
72
  *
65
73
  * connectionName=your-connection-name
74
+ * authority=your-authority-endpoint
66
75
  * ```
67
76
  * @remarks
68
77
  * - `clientId` is required
@@ -71,6 +80,7 @@ export interface AuthConfiguration {
71
80
  */
72
81
  export const loadAuthConfigFromEnv: (cnxName?: string) => AuthConfiguration = (cnxName?: string) => {
73
82
  if (cnxName === undefined) {
83
+ const authority = process.env.authorityEndpoint ?? 'https://login.microsoftonline.com'
74
84
  if (process.env.clientId === undefined && process.env.NODE_ENV === 'production') {
75
85
  throw new Error('ClientId required in production')
76
86
  }
@@ -82,13 +92,15 @@ export const loadAuthConfigFromEnv: (cnxName?: string) => AuthConfiguration = (c
82
92
  certKeyFile: process.env.certKeyFile,
83
93
  connectionName: process.env.connectionName,
84
94
  FICClientId: process.env.FICClientId,
95
+ authority,
85
96
  issuers: [
86
97
  'https://api.botframework.com',
87
98
  `https://sts.windows.net/${process.env.tenantId}/`,
88
- `https://login.microsoftonline.com/${process.env.tenantId}/v2.0`
89
- ]
99
+ `${authority}/${process.env.tenantId}/v2.0`
100
+ ],
90
101
  }
91
102
  } else {
103
+ const authority = process.env[`${cnxName}_authorityEndpoint`] ?? 'https://login.microsoftonline.com'
92
104
  return {
93
105
  tenantId: process.env[`${cnxName}_tenantId`],
94
106
  clientId: process.env[`${cnxName}_clientId`] ?? (() => { throw new Error(`ClientId not found for connection: ${cnxName}`) })(),
@@ -97,10 +109,11 @@ export const loadAuthConfigFromEnv: (cnxName?: string) => AuthConfiguration = (c
97
109
  certKeyFile: process.env[`${cnxName}_certKeyFile`],
98
110
  connectionName: process.env[`${cnxName}_connectionName`],
99
111
  FICClientId: process.env[`${cnxName}_FICClientId`],
112
+ authority,
100
113
  issuers: [
101
114
  'https://api.botframework.com',
102
115
  `https://sts.windows.net/${process.env[`${cnxName}_tenantId`]}/`,
103
- `https://login.microsoftonline.com/${process.env[`${cnxName}_tenantId`]}/v2.0`
116
+ `${authority}/${process.env[`${cnxName}_tenantId`]}/v2.0`
104
117
  ]
105
118
  }
106
119
  }
@@ -122,6 +135,7 @@ export const loadPrevAuthConfigFromEnv: () => AuthConfiguration = () => {
122
135
  if (process.env.MicrosoftAppId === undefined && process.env.NODE_ENV === 'production') {
123
136
  throw new Error('ClientId required in production')
124
137
  }
138
+ const authority = process.env.authorityEndpoint ?? 'https://login.microsoftonline.com'
125
139
  return {
126
140
  tenantId: process.env.MicrosoftAppTenantId,
127
141
  clientId: process.env.MicrosoftAppId!,
@@ -130,10 +144,11 @@ export const loadPrevAuthConfigFromEnv: () => AuthConfiguration = () => {
130
144
  certKeyFile: process.env.certKeyFile,
131
145
  connectionName: process.env.connectionName,
132
146
  FICClientId: process.env.MicrosoftAppClientId,
147
+ authority,
133
148
  issuers: [
134
149
  'https://api.botframework.com',
135
150
  `https://sts.windows.net/${process.env.MicrosoftAppTenantId}/`,
136
- `https://login.microsoftonline.com/${process.env.MicrosoftAppTenantId}/v2.0`
151
+ `${authority}/${process.env.MicrosoftAppTenantId}/v2.0`
137
152
  ]
138
153
  }
139
154
  }
@@ -24,7 +24,7 @@ const verifyToken = async (raw: string, config: AuthConfiguration): Promise<JwtP
24
24
  logger.debug('jwt.decode ', JSON.stringify(payload))
25
25
  const jwksUri: string = payload.iss === 'https://api.botframework.com'
26
26
  ? 'https://login.botframework.com/v1/.well-known/keys'
27
- : `https://login.microsoftonline.com/${config.tenantId}/discovery/v2.0/keys`
27
+ : `${config.authority}/${config.tenantId}/discovery/v2.0/keys`
28
28
 
29
29
  logger.debug(`fetching keys from ${jwksUri}`)
30
30
  const jwksClient: JwksClient = jwksRsa({ jwksUri })
@@ -55,7 +55,7 @@ export class MsalTokenProvider implements AuthProvider {
55
55
  const cca = new ConfidentialClientApplication({
56
56
  auth: {
57
57
  clientId: authConfig.clientId as string,
58
- authority: `https://login.microsoftonline.com/${authConfig.tenantId || 'botframework.com'}`,
58
+ authority: `${authConfig.authority}/${authConfig.tenantId || 'botframework.com'}`,
59
59
  clientSecret: authConfig.clientSecret
60
60
  },
61
61
  system: this.sysOptions
@@ -137,7 +137,7 @@ export class MsalTokenProvider implements AuthProvider {
137
137
  const cca = new ConfidentialClientApplication({
138
138
  auth: {
139
139
  clientId: authConfig.clientId || '',
140
- authority: `https://login.microsoftonline.com/${authConfig.tenantId || 'botframework.com'}`,
140
+ authority: `${authConfig.authority}/${authConfig.tenantId || 'botframework.com'}`,
141
141
  clientCertificate: {
142
142
  privateKey: privateKey as string,
143
143
  thumbprint: pubKeyObject.fingerprint.replaceAll(':', ''),
@@ -163,7 +163,7 @@ export class MsalTokenProvider implements AuthProvider {
163
163
  const cca = new ConfidentialClientApplication({
164
164
  auth: {
165
165
  clientId: authConfig.clientId as string,
166
- authority: `https://login.microsoftonline.com/${authConfig.tenantId || 'botframework.com'}`,
166
+ authority: `${authConfig.authority}/${authConfig.tenantId || 'botframework.com'}`,
167
167
  clientSecret: authConfig.clientSecret
168
168
  },
169
169
  system: this.sysOptions
@@ -187,7 +187,7 @@ export class MsalTokenProvider implements AuthProvider {
187
187
  const cca = new ConfidentialClientApplication({
188
188
  auth: {
189
189
  clientId: authConfig.clientId as string,
190
- authority: `https://login.microsoftonline.com/${authConfig.tenantId}`,
190
+ authority: `${authConfig.authority}/${authConfig.tenantId}`,
191
191
  clientAssertion
192
192
  },
193
193
  system: this.sysOptions
@@ -22,6 +22,7 @@ import { AttachmentInfo } from './connector-client/attachmentInfo'
22
22
  import { AttachmentData } from './connector-client/attachmentData'
23
23
  import { normalizeIncomingActivity } from './activityWireCompat'
24
24
  import { UserTokenClient } from './oauth'
25
+ import { HeaderPropagation, HeaderPropagationCollection, HeaderPropagationDefinition } from './headerPropagation'
25
26
 
26
27
  const logger = debug('agents:cloud-adapter')
27
28
 
@@ -84,18 +85,21 @@ export class CloudAdapter extends BaseAdapter {
84
85
  *
85
86
  * @param serviceUrl - The URL of the service to connect to
86
87
  * @param scope - The authentication scope to use
88
+ * @param headers - Optional headers to propagate in the request
87
89
  * @returns A promise that resolves to a ConnectorClient instance
88
90
  * @protected
89
91
  */
90
92
  protected async createConnectorClient (
91
93
  serviceUrl: string,
92
- scope: string
94
+ scope: string,
95
+ headers?: HeaderPropagationCollection
93
96
  ): Promise<ConnectorClient> {
94
- return ConnectorClient.createClientWithAuthAsync(
97
+ return ConnectorClient.createClientWithAuth(
95
98
  serviceUrl,
96
99
  this.authConfig,
97
100
  this.authProvider,
98
- scope
101
+ scope,
102
+ headers
99
103
  )
100
104
  }
101
105
 
@@ -122,7 +126,7 @@ export class CloudAdapter extends BaseAdapter {
122
126
  }
123
127
 
124
128
  async createTurnContextWithScope (activity: Activity, logic: AgentHandler, scope: string): Promise<TurnContext> {
125
- this.connectorClient = await ConnectorClient.createClientWithAuthAsync(activity.serviceUrl!, this.authConfig!, this.authProvider, scope)
129
+ this.connectorClient = await ConnectorClient.createClientWithAuth(activity.serviceUrl!, this.authConfig!, this.authProvider, scope)
126
130
  return new TurnContext(this, activity)
127
131
  }
128
132
 
@@ -162,9 +166,9 @@ export class CloudAdapter extends BaseAdapter {
162
166
  }
163
167
 
164
168
  if (activity.replyToId) {
165
- response = await this.connectorClient.replyToActivityAsync(activity.conversation.id, activity.replyToId, activity)
169
+ response = await this.connectorClient.replyToActivity(activity.conversation.id, activity.replyToId, activity)
166
170
  } else {
167
- response = await this.connectorClient.sendToConversationAsync(activity.conversation.id, activity)
171
+ response = await this.connectorClient.sendToConversation(activity.conversation.id, activity)
168
172
  }
169
173
  }
170
174
 
@@ -187,7 +191,7 @@ export class CloudAdapter extends BaseAdapter {
187
191
  if (!activity.serviceUrl || (activity.conversation == null) || !activity.conversation.id || !activity.id) {
188
192
  throw new Error('Invalid activity object')
189
193
  }
190
- return await this.connectorClient.replyToActivityAsync(activity.conversation.id, activity.id, activity)
194
+ return await this.connectorClient.replyToActivity(activity.conversation.id, activity.id, activity)
191
195
  }
192
196
 
193
197
  /**
@@ -195,11 +199,19 @@ export class CloudAdapter extends BaseAdapter {
195
199
  * @param request - The incoming request.
196
200
  * @param res - The response to send.
197
201
  * @param logic - The logic to execute.
202
+ * @param headerPropagation - Optional function to handle header propagation.
198
203
  */
199
204
  public async process (
200
205
  request: Request,
201
206
  res: Response,
202
- logic: (context: TurnContext) => Promise<void>): Promise<void> {
207
+ logic: (context: TurnContext) => Promise<void>,
208
+ headerPropagation?: HeaderPropagationDefinition): Promise<void> {
209
+ const headers = new HeaderPropagation(request.headers)
210
+ if (headerPropagation && typeof headerPropagation === 'function') {
211
+ headerPropagation(headers)
212
+ logger.debug('Headers to propagate: ', headers)
213
+ }
214
+
203
215
  const end = (status: StatusCodes, body?: unknown, isInvokeResponseOrExpectReplies: boolean = false) => {
204
216
  res.status(status)
205
217
  if (isInvokeResponseOrExpectReplies) {
@@ -228,7 +240,7 @@ export class CloudAdapter extends BaseAdapter {
228
240
  // if Delivery Mode == ExpectReplies, we don't need a connector client.
229
241
  if (this.resolveIfConnectorClientIsNeeded(activity)) {
230
242
  logger.debug('Creating connector client with scope: ', scope)
231
- this.connectorClient = await this.createConnectorClient(activity.serviceUrl!, scope)
243
+ this.connectorClient = await this.createConnectorClient(activity.serviceUrl!, scope, headers)
232
244
  this.setConnectorClient(context)
233
245
  }
234
246
 
@@ -287,7 +299,7 @@ export class CloudAdapter extends BaseAdapter {
287
299
  throw new Error('Invalid activity object')
288
300
  }
289
301
 
290
- const response = await this.connectorClient.updateActivityAsync(
302
+ const response = await this.connectorClient.updateActivity(
291
303
  activity.conversation.id,
292
304
  activity.id,
293
305
  activity
@@ -311,7 +323,7 @@ export class CloudAdapter extends BaseAdapter {
311
323
  throw new Error('Invalid conversation reference object')
312
324
  }
313
325
 
314
- await this.connectorClient.deleteActivityAsync(reference.conversation.id, reference.activityId)
326
+ await this.connectorClient.deleteActivity(reference.conversation.id, reference.activityId)
315
327
  }
316
328
 
317
329
  /**
@@ -424,7 +436,7 @@ export class CloudAdapter extends BaseAdapter {
424
436
  if (!logic) throw new TypeError('`logic` must be defined')
425
437
 
426
438
  const restClient = await this.createConnectorClient(serviceUrl, audience)
427
- const createConversationResult = await restClient.createConversationAsync(conversationParameters)
439
+ const createConversationResult = await restClient.createConversation(conversationParameters)
428
440
  const createActivity = this.createCreateActivity(
429
441
  createConversationResult.id,
430
442
  channelId,
@@ -11,6 +11,7 @@ import { AttachmentInfo } from './attachmentInfo'
11
11
  import { AttachmentData } from './attachmentData'
12
12
  import { normalizeOutgoingActivity } from '../activityWireCompat'
13
13
  import { getProductInfo } from '../getProductInfo'
14
+ import { HeaderPropagation, HeaderPropagationCollection } from '../headerPropagation'
14
15
  const logger = debug('agents:connector-client')
15
16
 
16
17
  export { getProductInfo }
@@ -27,6 +28,20 @@ export class ConnectorClient {
27
28
  */
28
29
  protected constructor (axInstance: AxiosInstance) {
29
30
  this._axiosInstance = axInstance
31
+ this._axiosInstance.interceptors.request.use((config) => {
32
+ const { method, url, data, headers, params } = config
33
+ // Clone headers and remove Authorization before logging
34
+ const { Authorization, authorization, ...headersToLog } = headers || {}
35
+ logger.debug('Request: ', {
36
+ host: this._axiosInstance.getUri(),
37
+ url,
38
+ data,
39
+ method,
40
+ params,
41
+ headers: headersToLog
42
+ })
43
+ return config
44
+ })
30
45
  this._axiosInstance.interceptors.response.use(
31
46
  (config) => {
32
47
  const { status, statusText, config: requestConfig } = config
@@ -66,20 +81,23 @@ export class ConnectorClient {
66
81
  * @param authConfig - The authentication configuration.
67
82
  * @param authProvider - The authentication provider.
68
83
  * @param scope - The scope for the authentication token.
84
+ * @param headers - Optional headers to propagate in the request.
69
85
  * @returns A new instance of ConnectorClient.
70
86
  */
71
- static async createClientWithAuthAsync (
87
+ static async createClientWithAuth (
72
88
  baseURL: string,
73
89
  authConfig: AuthConfiguration,
74
90
  authProvider: AuthProvider,
75
- scope: string
91
+ scope: string,
92
+ headers?: HeaderPropagationCollection
76
93
  ): Promise<ConnectorClient> {
94
+ const headerPropagation = headers ?? new HeaderPropagation({ 'User-Agent': '' })
95
+ headerPropagation.concat({ 'User-Agent': getProductInfo() })
96
+ headerPropagation.override({ Accept: 'application/json' })
97
+
77
98
  const axiosInstance = axios.create({
78
99
  baseURL,
79
- headers: {
80
- Accept: 'application/json',
81
- 'User-Agent': getProductInfo(),
82
- },
100
+ headers: headerPropagation.outgoing,
83
101
  transformRequest: [
84
102
  (data, headers) => {
85
103
  return JSON.stringify(normalizeOutgoingActivity(data))
@@ -98,7 +116,7 @@ export class ConnectorClient {
98
116
  * @param continuationToken - The continuation token for pagination.
99
117
  * @returns A list of conversations.
100
118
  */
101
- public async getConversationsAsync (continuationToken?: string): Promise<ConversationsResult> {
119
+ public async getConversations (continuationToken?: string): Promise<ConversationsResult> {
102
120
  const config: AxiosRequestConfig = {
103
121
  method: 'get',
104
122
  url: '/v3/conversations',
@@ -128,7 +146,7 @@ export class ConnectorClient {
128
146
  * @param body - The conversation parameters.
129
147
  * @returns The conversation resource response.
130
148
  */
131
- public async createConversationAsync (body: ConversationParameters): Promise<ConversationResourceResponse> {
149
+ public async createConversation (body: ConversationParameters): Promise<ConversationResourceResponse> {
132
150
  // const payload = normalizeOutgoingConvoParams(body)
133
151
  const config: AxiosRequestConfig = {
134
152
  method: 'post',
@@ -149,7 +167,7 @@ export class ConnectorClient {
149
167
  * @param body - The activity object.
150
168
  * @returns The resource response.
151
169
  */
152
- public async replyToActivityAsync (
170
+ public async replyToActivity (
153
171
  conversationId: string,
154
172
  activityId: string,
155
173
  body: Activity
@@ -177,7 +195,7 @@ export class ConnectorClient {
177
195
  * @param body - The activity object.
178
196
  * @returns The resource response.
179
197
  */
180
- public async sendToConversationAsync (
198
+ public async sendToConversation (
181
199
  conversationId: string,
182
200
  body: Activity
183
201
  ): Promise<ResourceResponse> {
@@ -204,7 +222,7 @@ export class ConnectorClient {
204
222
  * @param body - The activity object.
205
223
  * @returns The resource response.
206
224
  */
207
- public async updateActivityAsync (
225
+ public async updateActivity (
208
226
  conversationId: string,
209
227
  activityId: string,
210
228
  body: Activity
@@ -230,7 +248,7 @@ export class ConnectorClient {
230
248
  * @param activityId - The ID of the activity.
231
249
  * @returns A promise that resolves when the activity is deleted.
232
250
  */
233
- public async deleteActivityAsync (
251
+ public async deleteActivity (
234
252
  conversationId: string,
235
253
  activityId: string
236
254
  ): Promise<void> {