@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.
- package/dist/package.json +7 -6
- package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
- package/dist/src/app/auth/authorizationManager.js +8 -3
- package/dist/src/app/auth/authorizationManager.js.map +1 -1
- package/dist/src/app/auth/handlers/azureBotAuthorization.d.ts +1 -1
- package/dist/src/app/auth/handlers/azureBotAuthorization.js +6 -10
- package/dist/src/app/auth/handlers/azureBotAuthorization.js.map +1 -1
- package/dist/src/app/streaming/streamingResponse.js +15 -23
- package/dist/src/app/streaming/streamingResponse.js.map +1 -1
- package/dist/src/app/teamsAttachmentDownloader.d.ts +7 -2
- package/dist/src/app/teamsAttachmentDownloader.js +10 -4
- package/dist/src/app/teamsAttachmentDownloader.js.map +1 -1
- package/dist/src/auth/jwt-middleware.js +0 -1
- package/dist/src/auth/jwt-middleware.js.map +1 -1
- package/dist/src/auth/msalTokenProvider.js +40 -10
- package/dist/src/auth/msalTokenProvider.js.map +1 -1
- package/dist/src/cloudAdapter.js +1 -1
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/connector-client/connectorClient.js +9 -2
- package/dist/src/connector-client/connectorClient.js.map +1 -1
- package/dist/src/oauth/userTokenClient.js +18 -11
- package/dist/src/oauth/userTokenClient.js.map +1 -1
- package/package.json +7 -6
- package/src/agent-client/agentResponseHandler.ts +3 -3
- package/src/app/auth/authorizationManager.ts +7 -1
- package/src/app/auth/handlers/azureBotAuthorization.ts +4 -9
- package/src/app/streaming/streamingResponse.ts +12 -22
- package/src/app/teamsAttachmentDownloader.ts +8 -3
- package/src/auth/jwt-middleware.ts +0 -1
- package/src/auth/msalTokenProvider.ts +48 -9
- package/src/cloudAdapter.ts +1 -1
- package/src/connector-client/connectorClient.ts +8 -2
- 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
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
|