@microsoft/agents-hosting 1.3.0-beta.3.g8403174470 → 1.3.0-beta.31.g024f219993

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 (33) hide show
  1. package/dist/package.json +7 -6
  2. package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
  3. package/dist/src/app/auth/authorizationManager.js +8 -3
  4. package/dist/src/app/auth/authorizationManager.js.map +1 -1
  5. package/dist/src/app/auth/handlers/azureBotAuthorization.d.ts +1 -1
  6. package/dist/src/app/auth/handlers/azureBotAuthorization.js +6 -10
  7. package/dist/src/app/auth/handlers/azureBotAuthorization.js.map +1 -1
  8. package/dist/src/app/streaming/streamingResponse.js +15 -23
  9. package/dist/src/app/streaming/streamingResponse.js.map +1 -1
  10. package/dist/src/app/teamsAttachmentDownloader.d.ts +7 -2
  11. package/dist/src/app/teamsAttachmentDownloader.js +10 -4
  12. package/dist/src/app/teamsAttachmentDownloader.js.map +1 -1
  13. package/dist/src/auth/jwt-middleware.js +0 -1
  14. package/dist/src/auth/jwt-middleware.js.map +1 -1
  15. package/dist/src/auth/msalTokenProvider.js +40 -10
  16. package/dist/src/auth/msalTokenProvider.js.map +1 -1
  17. package/dist/src/cloudAdapter.js +1 -1
  18. package/dist/src/cloudAdapter.js.map +1 -1
  19. package/dist/src/connector-client/connectorClient.js +9 -2
  20. package/dist/src/connector-client/connectorClient.js.map +1 -1
  21. package/dist/src/oauth/userTokenClient.js +18 -11
  22. package/dist/src/oauth/userTokenClient.js.map +1 -1
  23. package/package.json +7 -6
  24. package/src/agent-client/agentResponseHandler.ts +3 -3
  25. package/src/app/auth/authorizationManager.ts +7 -1
  26. package/src/app/auth/handlers/azureBotAuthorization.ts +4 -9
  27. package/src/app/streaming/streamingResponse.ts +12 -22
  28. package/src/app/teamsAttachmentDownloader.ts +8 -3
  29. package/src/auth/jwt-middleware.ts +0 -1
  30. package/src/auth/msalTokenProvider.ts +48 -9
  31. package/src/cloudAdapter.ts +1 -1
  32. package/src/connector-client/connectorClient.ts +8 -2
  33. package/src/oauth/userTokenClient.ts +20 -12
@@ -8,7 +8,7 @@ import { normalizeTokenExchangeState } from '../activityWireCompat'
8
8
  import { AadResourceUrls, SignInResource, TokenExchangeRequest, TokenOrSinginResourceResponse, TokenResponse, TokenStatus } from './userTokenClient.types'
9
9
  import { getProductInfo } from '../getProductInfo'
10
10
  import { AuthProvider } from '../auth'
11
- import { HeaderPropagationCollection } from '../headerPropagation'
11
+ import { HeaderPropagation, HeaderPropagationCollection } from '../headerPropagation'
12
12
  import { getTokenServiceEndpoint } from './customUserTokenAPI'
13
13
 
14
14
  const logger = debug('agents:user-token-client')
@@ -109,21 +109,29 @@ export class UserTokenClient {
109
109
  scope: string,
110
110
  headers?: HeaderPropagationCollection
111
111
  ): Promise<UserTokenClient> {
112
- // TODO: add header propagation logic
112
+ const headerPropagation = headers ?? new HeaderPropagation({})
113
+ const userAgent = headerPropagation.outgoing['user-agent']
114
+ const productInfo = getProductInfo()
115
+ if (!userAgent) {
116
+ headerPropagation.add({ 'User-Agent': productInfo })
117
+ } else if (!userAgent.includes(productInfo)) {
118
+ headerPropagation.concat({ 'User-Agent': productInfo })
119
+ }
120
+ headerPropagation.override({
121
+ Accept: 'application/json',
122
+ 'Content-Type': 'application/json', // Required by transformRequest
123
+ })
124
+
113
125
  const axiosInstance = axios.create({
114
126
  baseURL,
115
- headers: {
116
- Accept: 'application/json',
117
- 'Content-Type': 'application/json', // Required by transformRequest
118
- 'User-Agent': getProductInfo(),
119
- },
127
+ headers: headerPropagation.outgoing,
120
128
  })
121
- if (authProvider) {
122
- const token = await authProvider.getAccessToken(scope)
123
- if (token.length > 1) {
124
- axiosInstance.defaults.headers.common.Authorization = `Bearer ${token}`
125
- }
129
+
130
+ const token = await authProvider?.getAccessToken(scope)
131
+ if (token && token.length > 1) {
132
+ axiosInstance.defaults.headers.common.Authorization = `Bearer ${token}`
126
133
  }
134
+
127
135
  return new UserTokenClient(axiosInstance)
128
136
  }
129
137