@microsoft/agents-hosting 0.6.21-g3c2261b2fc → 0.6.22

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 (58) 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 +1 -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/connector-client/connectorClient.js +14 -0
  27. package/dist/src/connector-client/connectorClient.js.map +1 -1
  28. package/dist/src/oauth/userTokenClient.js +34 -17
  29. package/dist/src/oauth/userTokenClient.js.map +1 -1
  30. package/dist/src/state/agentState.d.ts +2 -2
  31. package/dist/src/state/agentState.js +2 -2
  32. package/dist/src/state/agentStatePropertyAccesor.d.ts +18 -21
  33. package/dist/src/state/agentStatePropertyAccesor.js +18 -21
  34. package/dist/src/state/agentStatePropertyAccesor.js.map +1 -1
  35. package/dist/src/storage/fileStorage.d.ts +12 -10
  36. package/dist/src/storage/fileStorage.js +12 -10
  37. package/dist/src/storage/fileStorage.js.map +1 -1
  38. package/dist/src/transcript/transcriptLogger.d.ts +1 -1
  39. package/package.json +2 -2
  40. package/src/app/adaptiveCards/adaptiveCardsActions.ts +9 -6
  41. package/src/app/adaptiveCards/query.ts +1 -1
  42. package/src/app/agentApplication.ts +10 -10
  43. package/src/app/agentApplicationBuilder.ts +1 -1
  44. package/src/app/agentApplicationOptions.ts +1 -1
  45. package/src/app/appMemory.ts +1 -1
  46. package/src/app/appRoute.ts +1 -1
  47. package/src/app/extensions.ts +1 -1
  48. package/src/app/turnState.ts +6 -6
  49. package/src/app/turnStateProperty.ts +2 -2
  50. package/src/auth/authConfiguration.ts +20 -5
  51. package/src/auth/jwt-middleware.ts +1 -1
  52. package/src/auth/msalTokenProvider.ts +4 -4
  53. package/src/connector-client/connectorClient.ts +14 -0
  54. package/src/oauth/userTokenClient.ts +36 -17
  55. package/src/state/agentState.ts +2 -2
  56. package/src/state/agentStatePropertyAccesor.ts +18 -21
  57. package/src/storage/fileStorage.ts +12 -10
  58. package/src/transcript/transcriptLogger.ts +1 -1
@@ -28,7 +28,7 @@ export interface TranscriptInfo {
28
28
  }
29
29
  /**
30
30
  * Paged result of items.
31
- * @template T - The type of items in the paged result.
31
+ * @typeParam T - The type of items in the paged result.
32
32
  */
33
33
  export interface PagedResult<T> {
34
34
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@microsoft/agents-hosting",
4
- "version": "0.6.21-g3c2261b2fc",
4
+ "version": "0.6.22",
5
5
  "homepage": "https://github.com/microsoft/Agents-for-js",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@azure/core-auth": "^1.10.0",
23
23
  "@azure/msal-node": "^3.6.0",
24
- "@microsoft/agents-activity": "0.6.21-g3c2261b2fc",
24
+ "@microsoft/agents-activity": "0.6.22",
25
25
  "axios": "^1.10.0",
26
26
  "jsonwebtoken": "^9.0.2",
27
27
  "jwks-rsa": "^3.2.0"
@@ -34,7 +34,8 @@ enum AdaptiveCardInvokeResponseType {
34
34
  }
35
35
 
36
36
  /**
37
- * Represents a single search result item returned from an Adaptive Card search operation.
37
+ * @summary Represents a single search result item returned from an Adaptive Card search operation.
38
+ * @remarks
38
39
  * This interface defines the structure for search results that are displayed to users
39
40
  * when they perform searches within Adaptive Cards, such as typeahead or dropdown searches.
40
41
  *
@@ -48,7 +49,8 @@ enum AdaptiveCardInvokeResponseType {
48
49
  */
49
50
  export interface AdaptiveCardSearchResult {
50
51
  /**
51
- * The display text shown to the user in the search results.
52
+ * @summary The display text shown to the user in the search results.
53
+ * @remarks
52
54
  * This is typically the human-readable label that appears in dropdowns,
53
55
  * typeahead suggestions, or search result lists.
54
56
  *
@@ -57,7 +59,8 @@ export interface AdaptiveCardSearchResult {
57
59
  title: string;
58
60
 
59
61
  /**
60
- * The underlying value associated with this search result.
62
+ * @summary The underlying value associated with this search result.
63
+ * @remarks
61
64
  * This is usually the actual data value that gets selected when the user
62
65
  * chooses this result, such as an ID, email address, or other identifier.
63
66
  *
@@ -68,7 +71,7 @@ export interface AdaptiveCardSearchResult {
68
71
 
69
72
  /**
70
73
  * A class to handle Adaptive Card actions such as executing actions, submitting actions, and performing searches.
71
- * @template TState - The type of the TurnState used in the application.
74
+ * @typeParam TState - The type of the TurnState used in the application.
72
75
  */
73
76
  export class AdaptiveCardsActions<TState extends TurnState> {
74
77
  /**
@@ -86,7 +89,7 @@ export class AdaptiveCardsActions<TState extends TurnState> {
86
89
 
87
90
  /**
88
91
  * Registers a handler for the Action.Execute event.
89
- * @template TData - The type of the data passed to the handler.
92
+ * @typeParam TData - The type of the data passed to the handler.
90
93
  * @param verb - A string, RegExp, RouteSelector, or an array of these to match the action verb.
91
94
  * @param handler - A function to handle the action execution.
92
95
  * @returns The Teams application instance.
@@ -171,7 +174,7 @@ export class AdaptiveCardsActions<TState extends TurnState> {
171
174
 
172
175
  /**
173
176
  * Registers a handler for the Action.Submit event.
174
- * @template TData - The type of the data passed to the handler.
177
+ * @typeParam TData - The type of the data passed to the handler.
175
178
  * @param verb - A string, RegExp, RouteSelector, or an array of these to match the action verb.
176
179
  * @param handler - A function to handle the action submission.
177
180
  * @returns The Teams application instance.
@@ -5,7 +5,7 @@
5
5
 
6
6
  /**
7
7
  * Represents a query with pagination and parameters.
8
- * @template TParams - The type of the query parameters.
8
+ * @typeParam TParams - The type of the query parameters.
9
9
  */
10
10
  export interface Query<TParams extends Record<string, any>> {
11
11
  /**
@@ -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>> = {}
@@ -16,7 +16,7 @@ import { TurnState } from './turnState'
16
16
  * This interface defines all the configurable aspects of an agent's behavior,
17
17
  * including adapter settings, storage, authorization, and various feature flags.
18
18
  *
19
- * @template TState - The type of turn state that extends TurnState, allowing for
19
+ * @typeParam TState - The type of turn state that extends TurnState, allowing for
20
20
  * custom state management specific to your agent's needs.
21
21
  */
22
22
  export interface AgentApplicationOptions<TState extends TurnState> {
@@ -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
@@ -27,6 +27,20 @@ export class ConnectorClient {
27
27
  */
28
28
  protected constructor (axInstance: AxiosInstance) {
29
29
  this._axiosInstance = axInstance
30
+ this._axiosInstance.interceptors.request.use((config) => {
31
+ const { method, url, data, headers, params } = config
32
+ // Clone headers and remove Authorization before logging
33
+ const { Authorization, authorization, ...headersToLog } = headers || {}
34
+ logger.debug('Request: ', {
35
+ host: this._axiosInstance.getUri(),
36
+ url,
37
+ data,
38
+ method,
39
+ params,
40
+ headers: headersToLog
41
+ })
42
+ return config
43
+ })
30
44
  this._axiosInstance.interceptors.response.use(
31
45
  (config) => {
32
46
  const { status, statusText, config: requestConfig } = config
@@ -22,43 +22,62 @@ export class UserTokenClient {
22
22
  */
23
23
  constructor (private msAppId: string) {
24
24
  const baseURL = 'https://api.botframework.com'
25
- const axiosInstance = axios.create({
25
+ this.client = axios.create({
26
26
  baseURL,
27
27
  headers: {
28
28
  Accept: 'application/json',
29
29
  'User-Agent': getProductInfo(),
30
30
  }
31
31
  })
32
- // axiosInstance.defaults.headers.common.Authorization = `Bearer ${token}`
33
- axiosInstance.interceptors.response.use(
32
+
33
+ this.client.interceptors.request.use((config) => {
34
+ const { method, url, data, headers, params } = config
35
+ const { Authorization, authorization, ...headersToLog } = headers || {}
36
+ logger.debug('Request: ', {
37
+ host: this.client.getUri(),
38
+ url,
39
+ data,
40
+ method,
41
+ params,
42
+ headers: headersToLog
43
+ })
44
+ return config
45
+ })
46
+
47
+ this.client.interceptors.response.use(
34
48
  (config) => {
35
- const { status, statusText, config: requestConfig } = config
49
+ const { status, statusText, config: requestConfig, headers } = config
50
+ const { Authorization, authorization, ...headersToLog } = headers || {}
51
+ const { token, ...redactedData } = requestConfig?.data || {}
36
52
  logger.debug('Response: ', {
37
53
  status,
38
54
  statusText,
39
- host: axiosInstance.getUri(),
55
+ host: this.client.getUri(),
40
56
  url: requestConfig?.url,
41
- data: config.config.data,
57
+ data: redactedData,
42
58
  method: requestConfig?.method,
59
+ headers: headersToLog
43
60
  })
44
61
  return config
45
62
  },
46
63
  (error) => {
47
64
  const { code, status, message, stack, response } = error
48
- if (status !== 404) {
49
- const errorDetails = {
50
- code,
51
- host: axiosInstance.getUri(),
52
- url: error.config.url,
53
- method: error.config.method,
54
- data: error.config.data,
55
- message: message + JSON.stringify(response?.data),
56
- stack,
57
- }
65
+ const { headers } = response || {}
66
+ const errorDetails = {
67
+ code,
68
+ host: this.client.getUri(),
69
+ url: error.config.url,
70
+ method: error.config.method,
71
+ data: error.config.data,
72
+ message: message + JSON.stringify(response?.data),
73
+ headers,
74
+ stack,
75
+ }
76
+ logger.debug('Response error: ', errorDetails)
77
+ if (errorDetails.url === '/api/usertoken/GetToken' && status !== 404) {
58
78
  return Promise.reject(errorDetails)
59
79
  }
60
80
  })
61
- this.client = axiosInstance
62
81
  }
63
82
 
64
83
  /**
@@ -44,8 +44,8 @@ export interface CustomKey {
44
44
  }
45
45
 
46
46
  /**
47
- * Manages the state of an Agent across turns in a conversation.
48
- *
47
+ * @summary Manages the state of an Agent across turns in a conversation.
48
+ * @remarks
49
49
  * AgentState provides functionality to persist and retrieve state data using
50
50
  * a storage provider. It handles caching state in the turn context for performance,
51
51
  * calculating change hashes to detect modifications, and managing property accessors
@@ -73,7 +73,7 @@ export interface StatePropertyAccessor<T = any> {
73
73
  }
74
74
 
75
75
  /**
76
- * Provides typed access to an Agent state property with automatic state loading and persistence management.
76
+ * @summary Provides typed access to an Agent state property with automatic state loading and persistence management.
77
77
  *
78
78
  * @remarks
79
79
  * AgentStatePropertyAccessor simplifies working with persisted state by abstracting
@@ -86,9 +86,9 @@ export interface StatePropertyAccessor<T = any> {
86
86
  * - **Memory Management**: Efficient in-memory caching with explicit persistence control
87
87
  * - **Custom Keys**: Support for custom storage keys for advanced scenarios
88
88
  *
89
- * ## Key Features
89
+ * ### Key Features
90
90
  *
91
- * ### Type Safety
91
+ * #### Type Safety
92
92
  * The accessor provides compile-time type checking when using TypeScript:
93
93
  * ```typescript
94
94
  * interface UserProfile {
@@ -98,7 +98,7 @@ export interface StatePropertyAccessor<T = any> {
98
98
  * const userProfile = userState.createProperty<UserProfile>("userProfile");
99
99
  * ```
100
100
  *
101
- * ### Automatic Default Value Handling
101
+ * #### Automatic Default Value Handling
102
102
  * When a property doesn't exist, default values are automatically cloned and stored:
103
103
  * ```typescript
104
104
  * // If userProfile doesn't exist, the default will be cloned and saved
@@ -108,7 +108,7 @@ export interface StatePropertyAccessor<T = any> {
108
108
  * });
109
109
  * ```
110
110
  *
111
- * ### Explicit Persistence Control
111
+ * #### Explicit Persistence Control
112
112
  * Changes are kept in memory until explicitly persisted:
113
113
  * ```typescript
114
114
  * // Modify the state
@@ -120,9 +120,9 @@ export interface StatePropertyAccessor<T = any> {
120
120
  * await userState.saveChanges(context);
121
121
  * ```
122
122
  *
123
- * ## Usage Examples
123
+ * ### Usage Examples
124
124
  *
125
- * ### Basic Usage
125
+ * @example Basic Usage
126
126
  * ```typescript
127
127
  * // Create a property accessor
128
128
  * const userProfile = userState.createProperty<UserProfile>("userProfile");
@@ -141,7 +141,7 @@ export interface StatePropertyAccessor<T = any> {
141
141
  * await userState.saveChanges(context); // Persist to storage
142
142
  * ```
143
143
  *
144
- * ### Working with Primitive Types
144
+ * @example Working with Primitive Types
145
145
  * ```typescript
146
146
  * const counterProperty = userState.createProperty<number>("counter");
147
147
  *
@@ -151,7 +151,7 @@ export interface StatePropertyAccessor<T = any> {
151
151
  * await userState.saveChanges(context);
152
152
  * ```
153
153
  *
154
- * ### Conditional Logic
154
+ * @example Conditional Logic
155
155
  * ```typescript
156
156
  * const settingsProperty = userState.createProperty<Settings>("settings");
157
157
  *
@@ -163,7 +163,7 @@ export interface StatePropertyAccessor<T = any> {
163
163
  * }
164
164
  * ```
165
165
  *
166
- * ### Custom Storage Keys
166
+ * @example Custom Storage Keys
167
167
  * ```typescript
168
168
  * // Store state with a custom key for multi-tenant scenarios
169
169
  * const customKey = { key: `tenant_${tenantId}` };
@@ -171,7 +171,7 @@ export interface StatePropertyAccessor<T = any> {
171
171
  * await dataProperty.set(context, updatedData, customKey);
172
172
  * ```
173
173
  *
174
- * ## Important Notes
174
+ * ### Important Notes
175
175
  *
176
176
  * - **Thread Safety**: This class is not thread-safe. Ensure proper synchronization in concurrent scenarios.
177
177
  * - **Memory Usage**: State objects are kept in memory until the context is disposed.
@@ -206,20 +206,19 @@ export class AgentStatePropertyAccessor<T = any> implements StatePropertyAccesso
206
206
  constructor (protected readonly state: AgentState, public readonly name: string) { }
207
207
 
208
208
  /**
209
- * Deletes the property from the state storage.
210
- *
209
+ * @summary Deletes the property from the state storage.
210
+ * @remarks
211
211
  * This operation removes the property from the in-memory state object but does not
212
212
  * automatically persist the change to the underlying storage. You must call
213
213
  * `state.saveChanges(context)` afterwards to persist the deletion.
214
214
  *
215
- * @remarks
216
215
  * - If the property doesn't exist, this operation is a no-op
217
216
  * - The deletion only affects the in-memory state until `saveChanges()` is called
218
217
  * - After deletion, subsequent `get()` calls will return `undefined` (or the default value if provided)
219
218
  *
220
219
  * @param context The turn context for the current conversation turn
221
220
  * @param customKey Optional custom key for accessing state in a specific storage location.
222
- * Useful for multi-tenant scenarios or when state needs to be partitioned.
221
+ * Useful for multi-tenant scenarios or when state needs to be partitioned.
223
222
  *
224
223
  * @returns A promise that resolves when the delete operation is complete
225
224
  *
@@ -252,15 +251,14 @@ export class AgentStatePropertyAccessor<T = any> implements StatePropertyAccesso
252
251
  }
253
252
 
254
253
  /**
255
- * Retrieves the value of the property from state storage.
256
- *
254
+ * @summary Retrieves the value of the property from state storage.
255
+ * @remarks
257
256
  * This method provides intelligent default value handling:
258
257
  * - If the property exists, its value is returned
259
258
  * - If the property doesn't exist and a default value is provided, the default is deep cloned,
260
259
  * stored in state, and returned
261
260
  * - If the property doesn't exist and no default is provided, `undefined` is returned
262
261
  *
263
- * @remarks
264
262
  * **Deep Cloning**: Default values are deep cloned using JSON serialization to prevent
265
263
  * reference sharing issues. This means:
266
264
  * - Functions, symbols, and circular references will be lost
@@ -331,13 +329,12 @@ export class AgentStatePropertyAccessor<T = any> implements StatePropertyAccesso
331
329
  }
332
330
 
333
331
  /**
334
- * Sets the value of the property in state storage.
335
- *
332
+ * @summary Sets the value of the property in state storage.
333
+ * @remarks
336
334
  * This operation updates the property in the in-memory state object but does not
337
335
  * automatically persist the change to the underlying storage. You must call
338
336
  * `state.saveChanges(context)` afterwards to persist the changes.
339
337
  *
340
- * @remarks
341
338
  * **Memory vs Storage**: Changes are immediately reflected in memory and will be
342
339
  * available to subsequent `get()` calls within the same context, but are not
343
340
  * persisted to storage until `saveChanges()` is called.