@microsoft/agents-hosting 1.5.0-beta.14.g1372abd1dc → 1.5.0-beta.19.g3a0f01fc43
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 +2 -2
- package/dist/src/app/agentApplication.d.ts +2 -2
- package/dist/src/app/agentApplication.js +3 -5
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/auth/authorization.js +10 -7
- package/dist/src/app/auth/authorization.js.map +1 -1
- package/dist/src/app/auth/authorizationManager.d.ts +18 -5
- package/dist/src/app/auth/authorizationManager.js +245 -43
- package/dist/src/app/auth/authorizationManager.js.map +1 -1
- package/dist/src/app/auth/handlerStorage.js +3 -1
- package/dist/src/app/auth/handlerStorage.js.map +1 -1
- package/dist/src/app/auth/handlers/agenticAuthorization.d.ts +19 -16
- package/dist/src/app/auth/handlers/agenticAuthorization.js +16 -32
- package/dist/src/app/auth/handlers/agenticAuthorization.js.map +1 -1
- package/dist/src/app/auth/handlers/azureBotAuthorization.d.ts +43 -69
- package/dist/src/app/auth/handlers/azureBotAuthorization.js +37 -65
- package/dist/src/app/auth/handlers/azureBotAuthorization.js.map +1 -1
- package/dist/src/app/auth/types.d.ts +100 -1
- package/dist/src/auth/authConfiguration.d.ts +61 -0
- package/dist/src/auth/authConfiguration.js +50 -1
- package/dist/src/auth/authConfiguration.js.map +1 -1
- package/dist/src/auth/msalConnectionManager.js +20 -0
- package/dist/src/auth/msalConnectionManager.js.map +1 -1
- package/dist/src/auth/msalTokenCredential.js +3 -0
- package/dist/src/auth/msalTokenCredential.js.map +1 -1
- package/dist/src/auth/msalTokenProvider.js +11 -4
- package/dist/src/auth/msalTokenProvider.js.map +1 -1
- package/dist/src/cloudAdapter.js +7 -0
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/errorHelper.js +14 -0
- package/dist/src/errorHelper.js.map +1 -1
- package/package.json +2 -2
- package/src/app/agentApplication.ts +7 -8
- package/src/app/auth/authorization.ts +10 -7
- package/src/app/auth/authorizationManager.ts +282 -43
- package/src/app/auth/handlerStorage.ts +3 -1
- package/src/app/auth/handlers/agenticAuthorization.ts +31 -43
- package/src/app/auth/handlers/azureBotAuthorization.ts +73 -129
- package/src/app/auth/types.ts +102 -1
- package/src/auth/authConfiguration.ts +57 -0
- package/src/auth/msalConnectionManager.ts +22 -0
- package/src/auth/msalTokenCredential.ts +4 -0
- package/src/auth/msalTokenProvider.ts +11 -4
- package/src/cloudAdapter.ts +8 -0
- package/src/errorHelper.ts +16 -0
|
@@ -66,17 +66,22 @@ export class MsalTokenProvider implements AuthProvider {
|
|
|
66
66
|
}
|
|
67
67
|
let token
|
|
68
68
|
if (authConfig.WIDAssertionFile !== undefined) {
|
|
69
|
+
logger.debug('getAccessToken via WID clientId=%s scope=%s', authConfig.clientId, actualScope)
|
|
69
70
|
token = await this.acquireAccessTokenViaWID(authConfig, actualScope)
|
|
70
71
|
} else if (authConfig.FICClientId !== undefined) {
|
|
72
|
+
logger.debug('getAccessToken via FIC clientId=%s scope=%s', authConfig.clientId, actualScope)
|
|
71
73
|
token = await this.acquireAccessTokenViaFIC(authConfig, actualScope)
|
|
72
74
|
} else if (authConfig.clientSecret !== undefined) {
|
|
75
|
+
logger.debug('getAccessToken via secret clientId=%s scope=%s', authConfig.clientId, actualScope)
|
|
73
76
|
token = await this.acquireAccessTokenViaSecret(authConfig, actualScope)
|
|
74
77
|
} else if (authConfig.certPemFile !== undefined &&
|
|
75
78
|
authConfig.certKeyFile !== undefined) {
|
|
79
|
+
logger.debug('getAccessToken via certificate clientId=%s scope=%s', authConfig.clientId, actualScope)
|
|
76
80
|
token = await this.acquireTokenWithCertificate(authConfig, actualScope)
|
|
77
81
|
} else if (authConfig.clientSecret === undefined &&
|
|
78
82
|
authConfig.certPemFile === undefined &&
|
|
79
83
|
authConfig.certKeyFile === undefined) {
|
|
84
|
+
logger.debug('getAccessToken via managed identity clientId=%s scope=%s', authConfig.clientId, actualScope)
|
|
80
85
|
token = await this.acquireTokenWithUserAssignedIdentity(authConfig, actualScope)
|
|
81
86
|
} else {
|
|
82
87
|
throw new Error('Invalid authConfig. ')
|
|
@@ -115,6 +120,7 @@ export class MsalTokenProvider implements AuthProvider {
|
|
|
115
120
|
actualOboAssertion = oboAssertion!
|
|
116
121
|
}
|
|
117
122
|
|
|
123
|
+
logger.debug('acquireTokenOnBehalfOf clientId=%s scopes=%o', authConfig.clientId, actualScopes)
|
|
118
124
|
const cca = new ConfidentialClientApplication({
|
|
119
125
|
auth: {
|
|
120
126
|
clientId: authConfig.clientId as string,
|
|
@@ -134,7 +140,7 @@ export class MsalTokenProvider implements AuthProvider {
|
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
public async getAgenticInstanceToken (tenantId: string, agentAppInstanceId: string): Promise<string> {
|
|
137
|
-
logger.debug('
|
|
143
|
+
logger.debug('getAgenticInstanceToken tenantId=%s agentAppInstanceId=%s', tenantId, agentAppInstanceId)
|
|
138
144
|
if (!this.connectionSettings) {
|
|
139
145
|
throw new Error('Connection settings must be provided when calling getAgenticInstanceToken')
|
|
140
146
|
}
|
|
@@ -205,6 +211,7 @@ export class MsalTokenProvider implements AuthProvider {
|
|
|
205
211
|
throw new Error('Connection settings must be provided when calling getAgenticInstanceToken')
|
|
206
212
|
}
|
|
207
213
|
|
|
214
|
+
logger.debug('acquireTokenForAgenticScenarios clientId=%s tenantId=%s scopes=%o grant_type=%s', clientId, tenantId, scopes, tokenBodyParameters.grant_type)
|
|
208
215
|
// Check cache first
|
|
209
216
|
const cacheKey = `${clientId}/${Object.keys(tokenBodyParameters).map(key => key !== 'user_federated_identity_credential' ? `${key}=${tokenBodyParameters[key]}` : '').join('&')}/${scopes.join(';')}`
|
|
210
217
|
if (this._agenticTokenCache.get(cacheKey)) {
|
|
@@ -249,7 +256,7 @@ export class MsalTokenProvider implements AuthProvider {
|
|
|
249
256
|
}
|
|
250
257
|
|
|
251
258
|
public async getAgenticUserToken (tenantId: string, agentAppInstanceId: string, agenticUserId: string, scopes: string[]): Promise<string> {
|
|
252
|
-
logger.debug('
|
|
259
|
+
logger.debug('getAgenticUserToken tenantId=%s agentAppInstanceId=%s scopes=%o', tenantId, agentAppInstanceId, scopes)
|
|
253
260
|
const agentToken = await this.getAgenticApplicationToken(tenantId, agentAppInstanceId)
|
|
254
261
|
const instanceToken = await this.getAgenticInstanceToken(tenantId, agentAppInstanceId)
|
|
255
262
|
|
|
@@ -270,7 +277,7 @@ export class MsalTokenProvider implements AuthProvider {
|
|
|
270
277
|
if (!this.connectionSettings?.clientId) {
|
|
271
278
|
throw new Error('Connection settings must be provided when calling getAgenticApplicationToken')
|
|
272
279
|
}
|
|
273
|
-
logger.debug('
|
|
280
|
+
logger.debug('getAgenticApplicationToken clientId=%s tenantId=%s agentAppInstanceId=%s', this.connectionSettings.clientId, tenantId, agentAppInstanceId)
|
|
274
281
|
|
|
275
282
|
let clientAssertion
|
|
276
283
|
|
|
@@ -496,7 +503,7 @@ export class MsalTokenProvider implements AuthProvider {
|
|
|
496
503
|
system: this.sysOptions
|
|
497
504
|
})
|
|
498
505
|
const token = await cca.acquireTokenByClientCredential({ scopes })
|
|
499
|
-
logger.
|
|
506
|
+
logger.debug('got token using WID client assertion')
|
|
500
507
|
if (!token?.accessToken) {
|
|
501
508
|
throw new Error('Failed to acquire token using WID client assertion')
|
|
502
509
|
}
|
package/src/cloudAdapter.ts
CHANGED
|
@@ -336,6 +336,14 @@ export class CloudAdapter extends BaseAdapter {
|
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
const end = (status: StatusCodes, body?: unknown, isInvokeResponseOrExpectReplies: boolean = false) => {
|
|
339
|
+
if (res.writableEnded) {
|
|
340
|
+
return
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (res.headersSent) {
|
|
344
|
+
res.end()
|
|
345
|
+
return
|
|
346
|
+
}
|
|
339
347
|
res.status(status)
|
|
340
348
|
if (isInvokeResponseOrExpectReplies) {
|
|
341
349
|
res.setHeader('content-type', 'application/json')
|
package/src/errorHelper.ts
CHANGED
|
@@ -500,6 +500,22 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
|
|
|
500
500
|
description: 'Storage is required for Authorization. Ensure that a storage provider is configured in the app options.'
|
|
501
501
|
},
|
|
502
502
|
|
|
503
|
+
/**
|
|
504
|
+
* Error thrown when the azureBotOAuthConnectionName option is missing for AzureBot authorization.
|
|
505
|
+
*/
|
|
506
|
+
AzureBotOAuthConnectionNameRequired: {
|
|
507
|
+
code: -120591,
|
|
508
|
+
description: "The 'azureBotOAuthConnectionName' option is not available in the app options. Ensure that the app is properly configured."
|
|
509
|
+
},
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Error thrown when the AzureBot connection token is not exchangeable for an OBO flow.
|
|
513
|
+
*/
|
|
514
|
+
AzureBotConnectionTokenNotExchangeable: {
|
|
515
|
+
code: -120592,
|
|
516
|
+
description: "The current token for the '{connectionName}' AzureBot connection is not exchangeable for an on-behalf-of flow. Ensure the token exchange URL starts with 'api://'."
|
|
517
|
+
},
|
|
518
|
+
|
|
503
519
|
// ============================================================================
|
|
504
520
|
// Agent and Client Errors (-120600 to -120630)
|
|
505
521
|
// ============================================================================
|