@microsoft/agents-hosting 1.4.0-beta.7.g541749904d → 1.4.2
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 +5 -5
- package/dist/src/app/adaptiveCards/activityValueParsers.d.ts +2 -1
- package/dist/src/app/adaptiveCards/adaptiveCardsSearchParams.d.ts +1 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsSearchParams.js +1 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsSearchParams.js.map +1 -1
- package/dist/src/app/agentApplication.d.ts +17 -9
- package/dist/src/app/agentApplication.js +94 -80
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/auth/authorizationManager.d.ts +7 -2
- package/dist/src/app/auth/authorizationManager.js +10 -9
- 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 +3 -3
- package/dist/src/app/auth/handlers/azureBotAuthorization.js.map +1 -1
- package/dist/src/app/streaming/streamingResponse.js +3 -3
- package/dist/src/app/streaming/streamingResponse.js.map +1 -1
- package/dist/src/auth/authConfiguration.d.ts +8 -0
- package/dist/src/auth/authConfiguration.js +24 -2
- package/dist/src/auth/authConfiguration.js.map +1 -1
- package/dist/src/auth/jwt-middleware.d.ts +7 -0
- package/dist/src/auth/jwt-middleware.js +14 -3
- package/dist/src/auth/jwt-middleware.js.map +1 -1
- package/dist/src/auth/msalConnectionManager.js +3 -2
- package/dist/src/auth/msalConnectionManager.js.map +1 -1
- package/dist/src/auth/msalTokenProvider.js +12 -19
- package/dist/src/auth/msalTokenProvider.js.map +1 -1
- package/dist/src/cloudAdapter.d.ts +4 -0
- package/dist/src/cloudAdapter.js +5 -0
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/turnContext.js +7 -1
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +5 -5
- package/src/app/adaptiveCards/activityValueParsers.ts +1 -1
- package/src/app/adaptiveCards/adaptiveCardsSearchParams.ts +1 -0
- package/src/app/agentApplication.ts +97 -79
- package/src/app/auth/authorizationManager.ts +16 -11
- package/src/app/auth/handlers/azureBotAuthorization.ts +4 -4
- package/src/app/streaming/streamingResponse.ts +3 -3
- package/src/auth/authConfiguration.ts +24 -2
- package/src/auth/jwt-middleware.ts +14 -4
- package/src/auth/msalConnectionManager.ts +3 -3
- package/src/auth/msalTokenProvider.ts +11 -21
- package/src/cloudAdapter.ts +5 -0
- package/src/index.ts +1 -1
- package/src/turnContext.ts +6 -1
package/dist/src/index.js
CHANGED
|
@@ -18,10 +18,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.HostingErrors = exports.authorizeJWT = void 0;
|
|
21
|
+
exports.HostingErrors = exports.buildJwksUri = exports.authorizeJWT = void 0;
|
|
22
22
|
__exportStar(require("./auth/"), exports);
|
|
23
23
|
var jwt_middleware_1 = require("./auth/jwt-middleware");
|
|
24
24
|
Object.defineProperty(exports, "authorizeJWT", { enumerable: true, get: function () { return jwt_middleware_1.authorizeJWT; } });
|
|
25
|
+
Object.defineProperty(exports, "buildJwksUri", { enumerable: true, get: function () { return jwt_middleware_1.buildJwksUri; } });
|
|
25
26
|
__exportStar(require("./app"), exports);
|
|
26
27
|
__exportStar(require("./cards"), exports);
|
|
27
28
|
__exportStar(require("./connector-client"), exports);
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;AAEH,0CAAuB;AACvB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;AAEH,0CAAuB;AACvB,wDAAkE;AAAzD,8GAAA,YAAY,OAAA;AAAE,8GAAA,YAAY,OAAA;AAEnC,wCAAqB;AACrB,0CAAuB;AACvB,qDAAkC;AAClC,6CAAuD;AAA9C,4GAAA,MAAM,OAAiB;AAChC,2CAAwB;AACxB,0CAAuB;AACvB,0CAAuB;AACvB,4CAAyB;AACzB,+CAA4B;AAE5B,oDAAiC;AACjC,gDAA6B;AAC7B,iDAA8B;AAC9B,kDAA+B;AAC/B,mDAAgC;AAChC,gDAA6B;AAC7B,gDAA6B;AAC7B,+DAA4C;AAC5C,oDAAiC;AACjC,sDAAmC;AAEnC,iDAA8B"}
|
package/dist/src/turnContext.js
CHANGED
|
@@ -271,7 +271,13 @@ class TurnContext {
|
|
|
271
271
|
* @protected
|
|
272
272
|
*/
|
|
273
273
|
copyTo(context) {
|
|
274
|
-
|
|
274
|
+
// Skip _streamingResponse: it holds a reference to the HTTP response of the original request.
|
|
275
|
+
// Copying it to a cloned context would cause the clone to write to an already-completed response.
|
|
276
|
+
const copyableProperties = Object.keys(this).filter((prop) => prop !== '_streamingResponse');
|
|
277
|
+
for (const prop of copyableProperties) {
|
|
278
|
+
;
|
|
279
|
+
context[prop] = this[prop];
|
|
280
|
+
}
|
|
275
281
|
}
|
|
276
282
|
/**
|
|
277
283
|
* Gets the adapter that created this context.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turnContext.js","sourceRoot":"","sources":["../../src/turnContext.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,uDAAuD;AAEvD,gEAAsH;AAEtH,6EAAyE;AAGzE,yEAAqE;AAiCrE;;GAEG;AACU,QAAA,uBAAuB,GAAG,sBAAsB,CAAA;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACH,MAA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SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAED,IAAI,iBAAiB;QACnB,OAAO,IAAI,CAAC,kBAAkB,CAAA;IAChC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACK,KAAK,CAAC,IAAI,CAAO,QAAqF,EAAE,GAAM,EAAE,IAAsB;QAC5I,MAAM,WAAW,GAAG,KAAK,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAkB,EAAc,EAAE;YACjF,IAAI,CAAC;gBACH,OAAO,OAAO,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;YACrH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAClC,CAAC;QACH,CAAC,CAAA;QACD,OAAO,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAA;IACpC,CAAC;CACF;AAlYD,kCAkYC"}
|
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": "1.4.
|
|
4
|
+
"version": "1.4.2",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"types": "dist/src/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@azure/core-auth": "^1.10.1",
|
|
23
|
-
"@azure/msal-node": "^5.0.
|
|
24
|
-
"@microsoft/agents-activity": "1.4.
|
|
25
|
-
"axios": "^1.13.
|
|
23
|
+
"@azure/msal-node": "^5.0.6",
|
|
24
|
+
"@microsoft/agents-activity": "1.4.2",
|
|
25
|
+
"axios": "^1.13.6",
|
|
26
26
|
"jsonwebtoken": "^9.0.3",
|
|
27
|
-
"jwks-rsa": "^
|
|
27
|
+
"jwks-rsa": "^4.0.1",
|
|
28
28
|
"object-path": "^0.11.8",
|
|
29
29
|
"zod": "3.25.75"
|
|
30
30
|
},
|
|
@@ -583,10 +583,10 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
583
583
|
* While this method is public, it's typically called internally by the `run` method.
|
|
584
584
|
*
|
|
585
585
|
* The method performs the following operations:
|
|
586
|
-
* 1.
|
|
587
|
-
* 2.
|
|
588
|
-
* 3.
|
|
589
|
-
* 4.
|
|
586
|
+
* 1. Handles authentication flows for routes that have auth handlers configured. If NOT authorized, it will not continue with the 2nd step, returning false.
|
|
587
|
+
* 2. Starts typing timer if configured
|
|
588
|
+
* 3. Processes mentions if configured
|
|
589
|
+
* 4. Loads turn state
|
|
590
590
|
* 5. Downloads files if file downloaders are configured
|
|
591
591
|
* 6. Executes before-turn event handlers
|
|
592
592
|
* 7. Routes to appropriate handlers
|
|
@@ -600,76 +600,98 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
600
600
|
* console.log('No handler matched the activity');
|
|
601
601
|
* }
|
|
602
602
|
* ```
|
|
603
|
-
*
|
|
604
603
|
*/
|
|
605
604
|
public async runInternal (turnContext: TurnContext): Promise<boolean> {
|
|
606
|
-
|
|
605
|
+
const { authorized, context } = await this.handleAuthorization(turnContext)
|
|
606
|
+
|
|
607
|
+
if (!authorized) {
|
|
608
|
+
// We don't log a message here because it is handled by the authorization manager and could cause confusion during mid sign-in operations.
|
|
607
609
|
return false
|
|
608
610
|
}
|
|
609
611
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
if (this._options.startTypingTimer) {
|
|
614
|
-
this.startTypingTimer(context)
|
|
615
|
-
}
|
|
612
|
+
const isLongRunning =
|
|
613
|
+
(turnContext.activity.type === ActivityTypes.Invoke && turnContext.activity.name === 'signin/tokenExchange') ||
|
|
614
|
+
(this._options.longRunningMessages && turnContext.activity.type === ActivityTypes.Message)
|
|
616
615
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
616
|
+
if (isLongRunning) {
|
|
617
|
+
logger.debug('Starting long-running messages for activity:', context.activity.id!)
|
|
618
|
+
this.startLongRunningCall(context, ctx => this.runTurn(ctx))
|
|
619
|
+
return true
|
|
620
|
+
}
|
|
620
621
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
622
|
+
logger.info('Running application with activity:', context.activity.id!)
|
|
623
|
+
return this.runTurn(context)
|
|
624
|
+
}
|
|
624
625
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
626
|
+
/**
|
|
627
|
+
* Determines if the incoming activity is authorized to be processed by the application.
|
|
628
|
+
* @returns An object containing the authorization status and the context (could have the continuation activity) to be used for further processing.
|
|
629
|
+
*/
|
|
630
|
+
private async handleAuthorization (context: TurnContext) {
|
|
631
|
+
if (context.activity.type === ActivityTypes.Typing) {
|
|
632
|
+
return { authorized: true, context }
|
|
633
|
+
}
|
|
628
634
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
+
return this._authorizationManager?.process(context, async activity => {
|
|
636
|
+
// The incoming activity may come from the storage, so we need to restore the auth handlers.
|
|
637
|
+
// Since the current route may not have auth handlers.
|
|
638
|
+
const route = await this.getRoute(new TurnContext(context.adapter, activity, context.identity))
|
|
639
|
+
return route?.authHandlers ?? []
|
|
640
|
+
}) ?? { authorized: true, context } // If no authorization manager is configured, we assume the activity is authorized.
|
|
641
|
+
}
|
|
635
642
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
643
|
+
/**
|
|
644
|
+
* Executes the turn processing logic for the given context, including routing and handler execution.
|
|
645
|
+
*/
|
|
646
|
+
private async runTurn (context: TurnContext): Promise<boolean> {
|
|
647
|
+
try {
|
|
648
|
+
if (this._options.startTypingTimer) {
|
|
649
|
+
this.startTypingTimer(context)
|
|
650
|
+
}
|
|
640
651
|
|
|
641
|
-
|
|
652
|
+
if (this._options.removeRecipientMention && context.activity.type === ActivityTypes.Message) {
|
|
653
|
+
context.activity.removeRecipientMention()
|
|
654
|
+
}
|
|
642
655
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
}
|
|
656
|
+
if (this._options.normalizeMentions && context.activity.type === ActivityTypes.Message) {
|
|
657
|
+
context.activity.normalizeMentions()
|
|
658
|
+
}
|
|
647
659
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}
|
|
652
|
-
}
|
|
660
|
+
const { storage, turnStateFactory } = this._options
|
|
661
|
+
const state = turnStateFactory()
|
|
662
|
+
await state.load(context, storage)
|
|
653
663
|
|
|
654
|
-
|
|
655
|
-
await state.save(context, storage)
|
|
656
|
-
return false
|
|
657
|
-
}
|
|
664
|
+
const route = await this.getRoute(context)
|
|
658
665
|
|
|
659
|
-
|
|
666
|
+
if (!route) {
|
|
667
|
+
logger.debug('No matching route found for activity:', context.activity)
|
|
668
|
+
return false
|
|
669
|
+
}
|
|
660
670
|
|
|
661
|
-
|
|
662
|
-
|
|
671
|
+
if (Array.isArray(this._options.fileDownloaders) && this._options.fileDownloaders.length > 0) {
|
|
672
|
+
for (let i = 0; i < this._options.fileDownloaders.length; i++) {
|
|
673
|
+
await this._options.fileDownloaders[i].downloadAndStoreFiles(context, state)
|
|
663
674
|
}
|
|
675
|
+
}
|
|
664
676
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
throw err
|
|
669
|
-
} finally {
|
|
670
|
-
this.stopTypingTimer()
|
|
677
|
+
if (!(await this.callEventHandlers(context, state, this._beforeTurn))) {
|
|
678
|
+
await state.save(context, storage)
|
|
679
|
+
return false
|
|
671
680
|
}
|
|
672
|
-
|
|
681
|
+
|
|
682
|
+
await route.handler(context, state)
|
|
683
|
+
|
|
684
|
+
if (await this.callEventHandlers(context, state, this._afterTurn)) {
|
|
685
|
+
await state.save(context, storage)
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
return true
|
|
689
|
+
} catch (err: any) {
|
|
690
|
+
logger.error(err)
|
|
691
|
+
throw err
|
|
692
|
+
} finally {
|
|
693
|
+
this.stopTypingTimer()
|
|
694
|
+
}
|
|
673
695
|
}
|
|
674
696
|
|
|
675
697
|
/**
|
|
@@ -900,35 +922,31 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
900
922
|
}
|
|
901
923
|
|
|
902
924
|
/**
|
|
903
|
-
* Starts a long-running call
|
|
925
|
+
* Starts a long-running call by continuing the conversation asynchronously (fire-and-forget).
|
|
926
|
+
* The current request/response cycle is not blocked; errors are forwarded to the adapter's error handler.
|
|
904
927
|
*
|
|
905
928
|
* @param context - The turn context for the current conversation.
|
|
906
|
-
* @param handler - The handler function to execute.
|
|
907
|
-
* @returns A promise that resolves to the result of the handler.
|
|
929
|
+
* @param handler - The handler function to execute in the continued conversation.
|
|
908
930
|
*/
|
|
909
931
|
protected startLongRunningCall (
|
|
910
932
|
context: TurnContext,
|
|
911
|
-
handler: (context: TurnContext) => Promise<
|
|
912
|
-
)
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
})
|
|
929
|
-
} else {
|
|
930
|
-
return handler(context)
|
|
931
|
-
}
|
|
933
|
+
handler: (context: TurnContext) => Promise<any>
|
|
934
|
+
) {
|
|
935
|
+
const activity = Activity.fromObject(context.activity)
|
|
936
|
+
this.continueConversationAsync(context.identity, activity.getConversationReference(), async (ctx) => {
|
|
937
|
+
try {
|
|
938
|
+
Object.assign(ctx.activity, activity)
|
|
939
|
+
await handler(ctx)
|
|
940
|
+
} catch (err) {
|
|
941
|
+
if (this.adapter.onTurnError && err instanceof Error) {
|
|
942
|
+
await this.adapter.onTurnError(ctx, err)
|
|
943
|
+
} else {
|
|
944
|
+
throw err
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
}).catch(err => {
|
|
948
|
+
logger.error(`Unhandled error in long-running call for activity '${activity.type}' (id: ${activity.id}):`, err)
|
|
949
|
+
})
|
|
932
950
|
}
|
|
933
951
|
|
|
934
952
|
/**
|
|
@@ -24,17 +24,21 @@ interface ManagerActiveHandler {
|
|
|
24
24
|
/**
|
|
25
25
|
* Result of the authorization manager process.
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
interface AuthorizationManagerProcessResult {
|
|
28
28
|
/**
|
|
29
29
|
* Indicates whether the authorization was successful.
|
|
30
30
|
*/
|
|
31
31
|
authorized: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The context associated with the authorization process.
|
|
34
|
+
*/
|
|
35
|
+
context: TurnContext;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
/**
|
|
35
39
|
* Function to retrieve handler IDs for the current activity.
|
|
36
40
|
*/
|
|
37
|
-
|
|
41
|
+
type GetHandlerIds = (activity: Activity) => string[] | Promise<string[]>
|
|
38
42
|
|
|
39
43
|
/**
|
|
40
44
|
* Manages multiple authorization handlers and their interactions.
|
|
@@ -111,13 +115,16 @@ export class AuthorizationManager {
|
|
|
111
115
|
if (active !== undefined && active?.data.activity.conversation?.id !== context.activity.conversation?.id) {
|
|
112
116
|
logger.warn('Discarding the active session due to the conversation has changed during an active sign-in process', active?.data.activity)
|
|
113
117
|
await storage.delete()
|
|
114
|
-
return { authorized: true }
|
|
118
|
+
return { authorized: true, context }
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
const handlers = active?.handlers ?? this.mapHandlers(await getHandlerIds(context.activity) ?? []) ?? []
|
|
118
122
|
|
|
123
|
+
// Create a shallow copy to modify the activity, since the signin process depends on it and we want to ensure the next handler depends on the initial activity, not the modified one.
|
|
124
|
+
const sharedContext = new TurnContext(context)
|
|
125
|
+
|
|
119
126
|
for (const handler of handlers) {
|
|
120
|
-
const status = await this.signin(storage, handler,
|
|
127
|
+
const status = await this.signin(storage, handler, sharedContext, active?.data)
|
|
121
128
|
logger.debug(this.prefix(handler.id, `Sign-in status: ${status}`))
|
|
122
129
|
|
|
123
130
|
if (status === AuthorizationHandlerStatus.IGNORED) {
|
|
@@ -126,17 +133,17 @@ export class AuthorizationManager {
|
|
|
126
133
|
}
|
|
127
134
|
|
|
128
135
|
if (status === AuthorizationHandlerStatus.PENDING) {
|
|
129
|
-
return { authorized: false }
|
|
136
|
+
return { authorized: false, context: sharedContext }
|
|
130
137
|
}
|
|
131
138
|
|
|
132
139
|
if (status === AuthorizationHandlerStatus.REJECTED) {
|
|
133
140
|
await storage.delete()
|
|
134
|
-
return { authorized: false }
|
|
141
|
+
return { authorized: false, context: sharedContext }
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
if (status === AuthorizationHandlerStatus.REVALIDATE) {
|
|
138
145
|
await storage.delete()
|
|
139
|
-
return this.process(
|
|
146
|
+
return this.process(sharedContext, getHandlerIds)
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
if (status !== AuthorizationHandlerStatus.APPROVED) {
|
|
@@ -146,14 +153,12 @@ export class AuthorizationManager {
|
|
|
146
153
|
await storage.delete()
|
|
147
154
|
|
|
148
155
|
if (active) {
|
|
149
|
-
|
|
150
|
-
// This is done like this to avoid losing data that may be set in the turn context.
|
|
151
|
-
(context as any)._activity = Activity.fromObject(active.data.activity)
|
|
156
|
+
(sharedContext as any)._activity = Activity.fromObject(active.data.activity)
|
|
152
157
|
active = undefined
|
|
153
158
|
}
|
|
154
159
|
}
|
|
155
160
|
|
|
156
|
-
return { authorized: true }
|
|
161
|
+
return { authorized: true, context: sharedContext }
|
|
157
162
|
}
|
|
158
163
|
|
|
159
164
|
/**
|
|
@@ -26,7 +26,7 @@ enum Category {
|
|
|
26
26
|
/**
|
|
27
27
|
* Active handler manager information.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
interface AzureBotActiveHandler extends ActiveAuthorizationHandler {
|
|
30
30
|
/**
|
|
31
31
|
* The number of attempts left for the handler to process in case of failure.
|
|
32
32
|
*/
|
|
@@ -307,7 +307,8 @@ export class AzureBotAuthorization implements AuthorizationHandler {
|
|
|
307
307
|
if (status !== AuthorizationHandlerStatus.IGNORED) {
|
|
308
308
|
return status
|
|
309
309
|
}
|
|
310
|
-
} else if (active.category === Category.SIGNIN) {
|
|
310
|
+
} else if (active.category === Category.SIGNIN && activity.channelId === Channels.Msteams) {
|
|
311
|
+
// Specific to MS Teams, M365 does not send signin/verifyState when user consent is required.
|
|
311
312
|
// This is only for safety in case of unexpected behaviors during the MS Teams sign-in process,
|
|
312
313
|
// e.g., user interrupts the flow by clicking the Consent Cancel button.
|
|
313
314
|
logger.warn(this.prefix('The incoming activity will be revalidated due to a change in the sign-in flow'), activity)
|
|
@@ -550,8 +551,7 @@ export class AzureBotAuthorization implements AuthorizationHandler {
|
|
|
550
551
|
* Sends an InvokeResponse activity if the channel is Microsoft Teams, including Copilot within MS Teams.
|
|
551
552
|
*/
|
|
552
553
|
private sendInvokeResponse <T>(context: TurnContext, response: InvokeResponse<T>) {
|
|
553
|
-
|
|
554
|
-
if (parentChannel !== Channels.Msteams) {
|
|
554
|
+
if (context.activity.channelIdChannel !== Channels.Msteams) {
|
|
555
555
|
return Promise.resolve()
|
|
556
556
|
}
|
|
557
557
|
|
|
@@ -164,7 +164,7 @@ export class StreamingResponse {
|
|
|
164
164
|
*
|
|
165
165
|
*/
|
|
166
166
|
public queueTextChunk (text: string, citations?: Citation[]): void {
|
|
167
|
-
if (
|
|
167
|
+
if (text === null || text === undefined || this._canceled) {
|
|
168
168
|
return
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -513,7 +513,7 @@ export class StreamingResponse {
|
|
|
513
513
|
|
|
514
514
|
if (activity.deliveryMode === DeliveryModes.ExpectReplies) {
|
|
515
515
|
this._isStreamingChannel = false
|
|
516
|
-
} else if (Channels.Msteams === activity.
|
|
516
|
+
} else if (Channels.Msteams === activity.channelIdChannel) {
|
|
517
517
|
if (activity.isAgenticRequest()) {
|
|
518
518
|
// Agentic requests do not support streaming responses at this time.
|
|
519
519
|
// TODO: Enable streaming for agentic requests when supported.
|
|
@@ -522,7 +522,7 @@ export class StreamingResponse {
|
|
|
522
522
|
this._isStreamingChannel = true
|
|
523
523
|
this._delayInMs = 1000
|
|
524
524
|
}
|
|
525
|
-
} else if (Channels.Webchat === activity.channelId || Channels.Directline === activity.channelId) {
|
|
525
|
+
} else if (Channels.Webchat === activity.channelId || Channels.Directline === activity.channelId || Channels.Emulator === activity.channelId) {
|
|
526
526
|
this._isStreamingChannel = true
|
|
527
527
|
this._delayInMs = 500
|
|
528
528
|
} else {
|
|
@@ -356,10 +356,32 @@ function buildLegacyAuthConfig (envPrefix: string = '', customConfig?: AuthConfi
|
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
+
/**
|
|
360
|
+
* Resolves the full authority URL including the tenant ID.
|
|
361
|
+
* Supports both patterns:
|
|
362
|
+
* - Tenant embedded in authority: https://login.microsoftonline.com/my-tenant
|
|
363
|
+
* - Authority + separate tenantId: https://login.microsoftonline.com + tenantId
|
|
364
|
+
* Also handles trailing slashes on authority.
|
|
365
|
+
*/
|
|
366
|
+
export function resolveAuthority (authority?: string, tenantId?: string): string {
|
|
367
|
+
const base = (authority ?? 'https://login.microsoftonline.com').replace(/\/+$/, '')
|
|
368
|
+
const url = new URL(base)
|
|
369
|
+
const hasPathSegment = url.pathname !== '/'
|
|
370
|
+
if (hasPathSegment) {
|
|
371
|
+
return base
|
|
372
|
+
}
|
|
373
|
+
return `${base}/${tenantId ?? 'botframework.com'}`
|
|
374
|
+
}
|
|
375
|
+
|
|
359
376
|
function getDefaultIssuers (tenantId: string, authority: string) : string[] {
|
|
377
|
+
// Convert empty string to undefined so resolveAuthority applies its 'botframework.com' default
|
|
378
|
+
const t = tenantId || undefined
|
|
379
|
+
if (!t) {
|
|
380
|
+
logger.warn('tenantId is not configured, defaulting to botframework.com')
|
|
381
|
+
}
|
|
360
382
|
return [
|
|
361
383
|
'https://api.botframework.com',
|
|
362
|
-
|
|
363
|
-
`${authority}
|
|
384
|
+
`${resolveAuthority('https://sts.windows.net', t)}/`,
|
|
385
|
+
`${resolveAuthority(authority, t)}/v2.0`
|
|
364
386
|
]
|
|
365
387
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { AuthConfiguration } from './authConfiguration'
|
|
6
|
+
import { AuthConfiguration, resolveAuthority } from './authConfiguration'
|
|
7
7
|
import { Response, NextFunction } from 'express'
|
|
8
8
|
import { Request } from './request'
|
|
9
9
|
import jwksRsa, { JwksClient, SigningKey } from 'jwks-rsa'
|
|
@@ -12,6 +12,18 @@ import { debug } from '@microsoft/agents-activity/logger'
|
|
|
12
12
|
|
|
13
13
|
const logger = debug('agents:jwt-middleware')
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Builds the JWKS URI for the given token issuer and auth configuration.
|
|
17
|
+
* @param iss The token issuer claim.
|
|
18
|
+
* @param authConfig The authentication configuration for the matched audience.
|
|
19
|
+
* @returns The JWKS URI string.
|
|
20
|
+
*/
|
|
21
|
+
export function buildJwksUri (iss: string, authConfig: AuthConfiguration): string {
|
|
22
|
+
return iss === 'https://api.botframework.com'
|
|
23
|
+
? 'https://login.botframework.com/v1/.well-known/keys'
|
|
24
|
+
: `${resolveAuthority(authConfig.authority, authConfig.tenantId)}/discovery/v2.0/keys`
|
|
25
|
+
}
|
|
26
|
+
|
|
15
27
|
/**
|
|
16
28
|
* Verifies the JWT token.
|
|
17
29
|
* @param raw The raw JWT token.
|
|
@@ -40,9 +52,7 @@ const verifyToken = async (raw: string, config: AuthConfiguration): Promise<JwtP
|
|
|
40
52
|
const [key, authConfig] = matchingEntry
|
|
41
53
|
logger.debug(`Audience found at key: ${key}`)
|
|
42
54
|
|
|
43
|
-
const jwksUri = payload.iss
|
|
44
|
-
? 'https://login.botframework.com/v1/.well-known/keys'
|
|
45
|
-
: `${authConfig.authority}/${authConfig.tenantId}/discovery/v2.0/keys`
|
|
55
|
+
const jwksUri = buildJwksUri(payload.iss as string, authConfig)
|
|
46
56
|
|
|
47
57
|
logger.debug(`fetching keys from ${jwksUri}`)
|
|
48
58
|
const jwksClient: JwksClient = jwksRsa({ jwksUri })
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { Activity, RoleTypes } from '@microsoft/agents-activity'
|
|
7
|
-
import { AuthConfiguration } from './authConfiguration'
|
|
7
|
+
import { AuthConfiguration, resolveAuthority } from './authConfiguration'
|
|
8
8
|
import { Connections } from './connections'
|
|
9
9
|
import { MsalTokenProvider } from './msalTokenProvider'
|
|
10
10
|
import { JwtPayload } from 'jsonwebtoken'
|
|
@@ -166,8 +166,8 @@ export class MsalConnectionManager implements Connections {
|
|
|
166
166
|
conn.connectionSettings.authority ??= 'https://login.microsoftonline.com'
|
|
167
167
|
conn.connectionSettings.issuers ??= [
|
|
168
168
|
'https://api.botframework.com',
|
|
169
|
-
|
|
170
|
-
`${conn.connectionSettings.authority
|
|
169
|
+
`${resolveAuthority('https://sts.windows.net', conn.connectionSettings.tenantId)}/`,
|
|
170
|
+
`${resolveAuthority(conn.connectionSettings.authority, conn.connectionSettings.tenantId)}/v2.0`
|
|
171
171
|
]
|
|
172
172
|
}
|
|
173
173
|
return conn
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { ConfidentialClientApplication, LogLevel, ManagedIdentityApplication, NodeSystemOptions } from '@azure/msal-node'
|
|
7
7
|
import axios from 'axios'
|
|
8
|
-
import { AuthConfiguration } from './authConfiguration'
|
|
8
|
+
import { AuthConfiguration, resolveAuthority as resolveAuthorityUtil } from './authConfiguration'
|
|
9
9
|
import { AuthProvider } from './authProvider'
|
|
10
10
|
import { debug } from '@microsoft/agents-activity/logger'
|
|
11
11
|
import { v4 } from 'uuid'
|
|
@@ -167,36 +167,26 @@ export class MsalTokenProvider implements AuthProvider {
|
|
|
167
167
|
* @returns
|
|
168
168
|
*/
|
|
169
169
|
private resolveAuthority (tenantId?: string) : string {
|
|
170
|
-
|
|
171
|
-
if (!tenantId) {
|
|
172
|
-
return this.connectionSettings?.authority ? `${this.connectionSettings.authority}/${this.connectionSettings?.tenantId}` : `https://login.microsoftonline.com/${this.connectionSettings?.tenantId || 'botframework.com'}`
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const configuredAuth = this.connectionSettings?.authority
|
|
176
|
-
const configuredTenantId = this.connectionSettings?.tenantId
|
|
170
|
+
const { authority: configuredAuth, tenantId: configuredTenantId } = this.connectionSettings ?? {}
|
|
177
171
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
// Use default Microsoft login endpoint when no custom authority is configured
|
|
182
|
-
if (!configuredAuth) {
|
|
183
|
-
return `https://login.microsoftonline.com/${finalTenant}`
|
|
172
|
+
if (!tenantId) {
|
|
173
|
+
// No agentic tenant override — delegate to shared utility
|
|
174
|
+
return resolveAuthorityUtil(configuredAuth, configuredTenantId)
|
|
184
175
|
}
|
|
185
176
|
|
|
186
|
-
//
|
|
187
|
-
|
|
177
|
+
// Agentic override: build a clean base using the override tenant, then replace any
|
|
178
|
+
// /common or GUID placeholder left in the authority (e.g. from a multi-tenant config)
|
|
179
|
+
const base = resolveAuthorityUtil(configuredAuth, tenantId)
|
|
188
180
|
const guidPattern = /\/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/
|
|
189
|
-
const hasTenantGuid = guidPattern.test(configuredAuth)
|
|
190
181
|
|
|
191
|
-
if (
|
|
192
|
-
return
|
|
182
|
+
if (base.endsWith('/common') || guidPattern.test(base)) {
|
|
183
|
+
return base.replace(
|
|
193
184
|
/\/(?:common|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})(?=\/|$)/,
|
|
194
185
|
`/${tenantId}`
|
|
195
186
|
)
|
|
196
187
|
}
|
|
197
188
|
|
|
198
|
-
|
|
199
|
-
return `${configuredAuth}/${finalTenant}`
|
|
189
|
+
return base
|
|
200
190
|
}
|
|
201
191
|
|
|
202
192
|
/**
|