@microsoft/agents-hosting 1.1.0-alpha.5 → 1.1.0-alpha.75
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 +10 -6
- package/dist/src/activityWireCompat.d.ts +1 -1
- package/dist/src/activityWireCompat.js +11 -3
- package/dist/src/activityWireCompat.js.map +1 -1
- package/dist/src/agent-client/agentClient.js +7 -3
- package/dist/src/agent-client/agentClient.js.map +1 -1
- package/dist/src/agent-client/agentResponseHandler.js +6 -2
- package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
- package/dist/src/app/agentApplication.d.ts +28 -13
- package/dist/src/app/agentApplication.js +93 -82
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/agentApplicationBuilder.d.ts +2 -2
- package/dist/src/app/agentApplicationBuilder.js.map +1 -1
- package/dist/src/app/agentApplicationOptions.d.ts +9 -2
- package/dist/src/app/appRoute.d.ts +7 -0
- package/dist/src/app/{authorization.d.ts → auth/authorization.d.ts} +33 -139
- package/dist/src/app/auth/authorization.js +188 -0
- package/dist/src/app/auth/authorization.js.map +1 -0
- package/dist/src/app/auth/authorizationManager.d.ts +71 -0
- package/dist/src/app/auth/authorizationManager.js +170 -0
- package/dist/src/app/auth/authorizationManager.js.map +1 -0
- package/dist/src/app/auth/handlerStorage.d.ts +36 -0
- package/dist/src/app/auth/handlerStorage.js +62 -0
- package/dist/src/app/auth/handlerStorage.js.map +1 -0
- package/dist/src/app/auth/handlers/agenticAuthorization.d.ts +93 -0
- package/dist/src/app/auth/handlers/agenticAuthorization.js +134 -0
- package/dist/src/app/auth/handlers/agenticAuthorization.js.map +1 -0
- package/dist/src/app/auth/handlers/azureBotAuthorization.d.ts +222 -0
- package/dist/src/app/auth/handlers/azureBotAuthorization.js +428 -0
- package/dist/src/app/auth/handlers/azureBotAuthorization.js.map +1 -0
- package/dist/src/app/auth/handlers/index.d.ts +2 -0
- package/dist/src/app/auth/handlers/index.js +19 -0
- package/dist/src/app/auth/handlers/index.js.map +1 -0
- package/dist/src/app/auth/index.d.ts +2 -0
- package/dist/src/app/auth/index.js +19 -0
- package/dist/src/app/auth/index.js.map +1 -0
- package/dist/src/app/auth/types.d.ts +104 -0
- package/dist/src/app/auth/types.js +24 -0
- package/dist/src/app/auth/types.js.map +1 -0
- package/dist/src/app/index.d.ts +2 -3
- package/dist/src/app/index.js +2 -3
- package/dist/src/app/index.js.map +1 -1
- package/dist/src/app/routeList.d.ts +1 -1
- package/dist/src/app/routeList.js +22 -5
- package/dist/src/app/routeList.js.map +1 -1
- package/dist/src/app/streaming/streamingResponse.js +2 -1
- package/dist/src/app/streaming/streamingResponse.js.map +1 -1
- package/dist/src/auth/MemoryCache.d.ts +16 -0
- package/dist/src/auth/MemoryCache.js +58 -0
- package/dist/src/auth/MemoryCache.js.map +1 -0
- package/dist/src/auth/authConfiguration.d.ts +44 -2
- package/dist/src/auth/authConfiguration.js +209 -53
- package/dist/src/auth/authConfiguration.js.map +1 -1
- package/dist/src/auth/authConstants.d.ts +11 -0
- package/dist/src/auth/authConstants.js +15 -0
- package/dist/src/auth/authConstants.js.map +1 -0
- package/dist/src/auth/authProvider.d.ts +23 -0
- package/dist/src/auth/connections.d.ts +41 -0
- package/dist/src/auth/connections.js +7 -0
- package/dist/src/auth/connections.js.map +1 -0
- package/dist/src/auth/index.d.ts +2 -0
- package/dist/src/auth/index.js +2 -0
- package/dist/src/auth/index.js.map +1 -1
- package/dist/src/auth/jwt-middleware.js +31 -18
- package/dist/src/auth/jwt-middleware.js.map +1 -1
- package/dist/src/auth/msalConnectionManager.d.ts +64 -0
- package/dist/src/auth/msalConnectionManager.js +148 -0
- package/dist/src/auth/msalConnectionManager.js.map +1 -0
- package/dist/src/auth/msalTokenProvider.d.ts +31 -0
- package/dist/src/auth/msalTokenProvider.js +167 -16
- package/dist/src/auth/msalTokenProvider.js.map +1 -1
- package/dist/src/baseAdapter.d.ts +10 -25
- package/dist/src/baseAdapter.js +2 -15
- package/dist/src/baseAdapter.js.map +1 -1
- package/dist/src/cloudAdapter.d.ts +40 -23
- package/dist/src/cloudAdapter.js +128 -60
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/connector-client/connectorClient.d.ts +15 -0
- package/dist/src/connector-client/connectorClient.js +49 -15
- package/dist/src/connector-client/connectorClient.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/oauth/customUserTokenAPI.d.ts +1 -0
- package/dist/src/oauth/customUserTokenAPI.js +11 -0
- package/dist/src/oauth/customUserTokenAPI.js.map +1 -0
- package/dist/src/oauth/index.d.ts +0 -1
- package/dist/src/oauth/index.js +0 -1
- package/dist/src/oauth/index.js.map +1 -1
- package/dist/src/oauth/userTokenClient.d.ts +30 -13
- package/dist/src/oauth/userTokenClient.js +60 -26
- package/dist/src/oauth/userTokenClient.js.map +1 -1
- package/dist/src/oauth/userTokenClient.types.d.ts +19 -6
- package/dist/src/turnContext.d.ts +7 -1
- package/dist/src/turnContext.js +11 -4
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +10 -6
- package/src/activityWireCompat.ts +12 -4
- package/src/agent-client/agentClient.ts +9 -3
- package/src/agent-client/agentResponseHandler.ts +5 -2
- package/src/app/agentApplication.ts +98 -77
- package/src/app/agentApplicationBuilder.ts +2 -2
- package/src/app/agentApplicationOptions.ts +10 -2
- package/src/app/appRoute.ts +8 -0
- package/src/app/auth/authorization.ts +252 -0
- package/src/app/auth/authorizationManager.ts +213 -0
- package/src/app/auth/handlerStorage.ts +61 -0
- package/src/app/auth/handlers/agenticAuthorization.ts +182 -0
- package/src/app/auth/handlers/azureBotAuthorization.ts +599 -0
- package/src/app/auth/handlers/index.ts +2 -0
- package/src/app/auth/index.ts +2 -0
- package/src/app/auth/types.ts +111 -0
- package/src/app/index.ts +2 -3
- package/src/app/routeList.ts +24 -5
- package/src/app/streaming/streamingResponse.ts +2 -1
- package/src/auth/MemoryCache.ts +59 -0
- package/src/auth/authConfiguration.ts +245 -52
- package/src/auth/authConstants.ts +11 -0
- package/src/auth/authProvider.ts +31 -0
- package/src/auth/connections.ts +47 -0
- package/src/auth/index.ts +2 -0
- package/src/auth/jwt-middleware.ts +38 -21
- package/src/auth/msalConnectionManager.ts +175 -0
- package/src/auth/msalTokenProvider.ts +209 -9
- package/src/baseAdapter.ts +10 -29
- package/src/cloudAdapter.ts +189 -71
- package/src/connector-client/connectorClient.ts +59 -15
- package/src/index.ts +0 -1
- package/src/oauth/customUserTokenAPI.ts +5 -0
- package/src/oauth/index.ts +0 -1
- package/src/oauth/userTokenClient.ts +74 -22
- package/src/oauth/userTokenClient.types.ts +20 -8
- package/src/turnContext.ts +16 -5
- package/dist/src/app/authorization.js +0 -387
- package/dist/src/app/authorization.js.map +0 -1
- package/dist/src/claimsIdentity.d.ts +0 -35
- package/dist/src/claimsIdentity.js +0 -43
- package/dist/src/claimsIdentity.js.map +0 -1
- package/dist/src/oauth/oAuthFlow.d.ts +0 -119
- package/dist/src/oauth/oAuthFlow.js +0 -316
- package/dist/src/oauth/oAuthFlow.js.map +0 -1
- package/src/app/authorization.ts +0 -432
- package/src/claimsIdentity.ts +0 -47
- package/src/oauth/oAuthFlow.ts +0 -378
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTokenServiceEndpoint = void 0;
|
|
4
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
+
// Licensed under the MIT License.
|
|
6
|
+
const getTokenServiceEndpoint = () => {
|
|
7
|
+
var _a;
|
|
8
|
+
return (_a = process.env.TOKEN_SERVICE_ENDPOINT) !== null && _a !== void 0 ? _a : 'https://api.botframework.com';
|
|
9
|
+
};
|
|
10
|
+
exports.getTokenServiceEndpoint = getTokenServiceEndpoint;
|
|
11
|
+
//# sourceMappingURL=customUserTokenAPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customUserTokenAPI.js","sourceRoot":"","sources":["../../../src/oauth/customUserTokenAPI.ts"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC5D,kCAAkC;AAC3B,MAAM,uBAAuB,GAAG,GAAW,EAAE;;IAClD,OAAO,MAAA,OAAO,CAAC,GAAG,CAAC,sBAAsB,mCAAI,8BAA8B,CAAA;AAC7E,CAAC,CAAA;AAFY,QAAA,uBAAuB,2BAEnC"}
|
package/dist/src/oauth/index.js
CHANGED
|
@@ -15,6 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./userTokenClient"), exports);
|
|
18
|
-
__exportStar(require("./oAuthFlow"), exports);
|
|
19
18
|
__exportStar(require("./userTokenClient.types"), exports);
|
|
20
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/oauth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/oauth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,0DAAuC"}
|
|
@@ -1,34 +1,51 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import { ConversationReference } from '@microsoft/agents-activity';
|
|
3
3
|
import { AadResourceUrls, SignInResource, TokenExchangeRequest, TokenOrSinginResourceResponse, TokenResponse, TokenStatus } from './userTokenClient.types';
|
|
4
|
+
import { AuthProvider } from '../auth';
|
|
5
|
+
import { HeaderPropagationCollection } from '../headerPropagation';
|
|
4
6
|
/**
|
|
5
7
|
* Client for managing user tokens.
|
|
6
8
|
*/
|
|
7
9
|
export declare class UserTokenClient {
|
|
8
|
-
private msAppId;
|
|
9
10
|
client: AxiosInstance;
|
|
11
|
+
private msAppId;
|
|
10
12
|
/**
|
|
11
13
|
* Creates a new instance of UserTokenClient.
|
|
12
14
|
* @param msAppId The Microsoft application ID.
|
|
13
15
|
*/
|
|
14
16
|
constructor(msAppId: string);
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new instance of UserTokenClient.
|
|
19
|
+
* @param axiosInstance The axios instance.
|
|
20
|
+
*/
|
|
21
|
+
constructor(axiosInstance: AxiosInstance);
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new instance of UserTokenClient with authentication.
|
|
24
|
+
* @param baseURL - The base URL for the API.
|
|
25
|
+
* @param authConfig - The authentication configuration.
|
|
26
|
+
* @param authProvider - The authentication provider.
|
|
27
|
+
* @param scope - The scope for the authentication token.
|
|
28
|
+
* @param headers - Optional headers to propagate in the request.
|
|
29
|
+
* @returns A new instance of ConnectorClient.
|
|
30
|
+
*/
|
|
31
|
+
static createClientWithScope(baseURL: string, authProvider: AuthProvider, scope: string, headers?: HeaderPropagationCollection): Promise<UserTokenClient>;
|
|
15
32
|
/**
|
|
16
33
|
* Gets the user token.
|
|
17
34
|
* @param connectionName The connection name.
|
|
18
|
-
* @param
|
|
35
|
+
* @param channelIdComposite The channel ID.
|
|
19
36
|
* @param userId The user ID.
|
|
20
37
|
* @param code The optional code.
|
|
21
38
|
* @returns A promise that resolves to the user token.
|
|
22
39
|
*/
|
|
23
|
-
getUserToken(connectionName: string,
|
|
40
|
+
getUserToken(connectionName: string, channelIdComposite: string, userId: string, code?: string): Promise<TokenResponse>;
|
|
24
41
|
/**
|
|
25
42
|
* Signs the user out.
|
|
26
43
|
* @param userId The user ID.
|
|
27
44
|
* @param connectionName The connection name.
|
|
28
|
-
* @param
|
|
45
|
+
* @param channelIdComposite The channel ID.
|
|
29
46
|
* @returns A promise that resolves when the sign-out operation is complete.
|
|
30
47
|
*/
|
|
31
|
-
signOut(userId: string, connectionName: string,
|
|
48
|
+
signOut(userId: string, connectionName: string, channelIdComposite: string): Promise<void>;
|
|
32
49
|
/**
|
|
33
50
|
* Gets the sign-in resource.
|
|
34
51
|
* @param msAppId The application ID.
|
|
@@ -42,16 +59,16 @@ export declare class UserTokenClient {
|
|
|
42
59
|
* Exchanges the token.
|
|
43
60
|
* @param userId The user ID.
|
|
44
61
|
* @param connectionName The connection name.
|
|
45
|
-
* @param
|
|
62
|
+
* @param channelIdComposite The channel ID.
|
|
46
63
|
* @param tokenExchangeRequest The token exchange request.
|
|
47
64
|
* @returns A promise that resolves to the exchanged token.
|
|
48
65
|
*/
|
|
49
|
-
exchangeTokenAsync(userId: string, connectionName: string,
|
|
66
|
+
exchangeTokenAsync(userId: string, connectionName: string, channelIdComposite: string, tokenExchangeRequest: TokenExchangeRequest): Promise<TokenResponse>;
|
|
50
67
|
/**
|
|
51
68
|
* Gets the token or sign-in resource.
|
|
52
69
|
* @param userId The user ID.
|
|
53
70
|
* @param connectionName The connection name.
|
|
54
|
-
* @param
|
|
71
|
+
* @param channelIdComposite The channel ID.
|
|
55
72
|
* @param conversation The conversation reference.
|
|
56
73
|
* @param relatesTo The related conversation reference.
|
|
57
74
|
* @param code The code.
|
|
@@ -59,23 +76,23 @@ export declare class UserTokenClient {
|
|
|
59
76
|
* @param fwdUrl The forward URL.
|
|
60
77
|
* @returns A promise that resolves to the token or sign-in resource response.
|
|
61
78
|
*/
|
|
62
|
-
getTokenOrSignInResource(userId: string, connectionName: string,
|
|
79
|
+
getTokenOrSignInResource(userId: string, connectionName: string, channelIdComposite: string, conversation: ConversationReference, relatesTo: ConversationReference, code: string, finalRedirect?: string, fwdUrl?: string): Promise<TokenOrSinginResourceResponse>;
|
|
63
80
|
/**
|
|
64
81
|
* Gets the token status.
|
|
65
82
|
* @param userId The user ID.
|
|
66
|
-
* @param
|
|
83
|
+
* @param channelIdComposite The channel ID.
|
|
67
84
|
* @param include The optional include parameter.
|
|
68
85
|
* @returns A promise that resolves to the token status.
|
|
69
86
|
*/
|
|
70
|
-
getTokenStatus(userId: string,
|
|
87
|
+
getTokenStatus(userId: string, channelIdComposite: string, include?: string): Promise<TokenStatus[]>;
|
|
71
88
|
/**
|
|
72
89
|
* Gets the AAD tokens.
|
|
73
90
|
* @param userId The user ID.
|
|
74
91
|
* @param connectionName The connection name.
|
|
75
|
-
* @param
|
|
92
|
+
* @param channelIdComposite The channel ID.
|
|
76
93
|
* @param resourceUrls The resource URLs.
|
|
77
94
|
* @returns A promise that resolves to the AAD tokens.
|
|
78
95
|
*/
|
|
79
|
-
getAadTokens(userId: string, connectionName: string,
|
|
96
|
+
getAadTokens(userId: string, connectionName: string, channelIdComposite: string, resourceUrls: AadResourceUrls): Promise<Record<string, TokenResponse>>;
|
|
80
97
|
updateAuthToken(token: string): void;
|
|
81
98
|
}
|
|
@@ -7,28 +7,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.UserTokenClient = void 0;
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
|
+
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
10
11
|
const logger_1 = require("@microsoft/agents-activity/logger");
|
|
11
12
|
const activityWireCompat_1 = require("../activityWireCompat");
|
|
12
13
|
const getProductInfo_1 = require("../getProductInfo");
|
|
14
|
+
const customUserTokenAPI_1 = require("./customUserTokenAPI");
|
|
13
15
|
const logger = (0, logger_1.debug)('agents:user-token-client');
|
|
14
16
|
/**
|
|
15
17
|
* Client for managing user tokens.
|
|
16
18
|
*/
|
|
17
19
|
class UserTokenClient {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
constructor(param) {
|
|
21
|
+
this.msAppId = '';
|
|
22
|
+
if (typeof param === 'string') {
|
|
23
|
+
const baseURL = (0, customUserTokenAPI_1.getTokenServiceEndpoint)();
|
|
24
|
+
this.client = axios_1.default.create({
|
|
25
|
+
baseURL,
|
|
26
|
+
headers: {
|
|
27
|
+
Accept: 'application/json',
|
|
28
|
+
'User-Agent': (0, getProductInfo_1.getProductInfo)(),
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
this.client = param;
|
|
34
|
+
}
|
|
32
35
|
this.client.interceptors.request.use((config) => {
|
|
33
36
|
const { method, url, data, headers, params } = config;
|
|
34
37
|
const { Authorization, authorization, ...headersToLog } = headers || {};
|
|
@@ -75,15 +78,41 @@ class UserTokenClient {
|
|
|
75
78
|
}
|
|
76
79
|
});
|
|
77
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new instance of UserTokenClient with authentication.
|
|
83
|
+
* @param baseURL - The base URL for the API.
|
|
84
|
+
* @param authConfig - The authentication configuration.
|
|
85
|
+
* @param authProvider - The authentication provider.
|
|
86
|
+
* @param scope - The scope for the authentication token.
|
|
87
|
+
* @param headers - Optional headers to propagate in the request.
|
|
88
|
+
* @returns A new instance of ConnectorClient.
|
|
89
|
+
*/
|
|
90
|
+
static async createClientWithScope(baseURL, authProvider, scope, headers) {
|
|
91
|
+
// TODO: add header propagation logic
|
|
92
|
+
const axiosInstance = axios_1.default.create({
|
|
93
|
+
baseURL,
|
|
94
|
+
headers: {
|
|
95
|
+
Accept: 'application/json',
|
|
96
|
+
'Content-Type': 'application/json', // Required by transformRequest
|
|
97
|
+
'User-Agent': (0, getProductInfo_1.getProductInfo)(),
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
const token = await authProvider.getAccessToken(scope);
|
|
101
|
+
if (token.length > 1) {
|
|
102
|
+
axiosInstance.defaults.headers.common.Authorization = `Bearer ${token}`;
|
|
103
|
+
}
|
|
104
|
+
return new UserTokenClient(axiosInstance);
|
|
105
|
+
}
|
|
78
106
|
/**
|
|
79
107
|
* Gets the user token.
|
|
80
108
|
* @param connectionName The connection name.
|
|
81
|
-
* @param
|
|
109
|
+
* @param channelIdComposite The channel ID.
|
|
82
110
|
* @param userId The user ID.
|
|
83
111
|
* @param code The optional code.
|
|
84
112
|
* @returns A promise that resolves to the user token.
|
|
85
113
|
*/
|
|
86
|
-
async getUserToken(connectionName,
|
|
114
|
+
async getUserToken(connectionName, channelIdComposite, userId, code) {
|
|
115
|
+
const [channelId] = agents_activity_1.Activity.parseChannelId(channelIdComposite);
|
|
87
116
|
const params = { connectionName, channelId, userId, code };
|
|
88
117
|
const response = await this.client.get('/api/usertoken/GetToken', { params });
|
|
89
118
|
if (response === null || response === void 0 ? void 0 : response.data) {
|
|
@@ -95,10 +124,11 @@ class UserTokenClient {
|
|
|
95
124
|
* Signs the user out.
|
|
96
125
|
* @param userId The user ID.
|
|
97
126
|
* @param connectionName The connection name.
|
|
98
|
-
* @param
|
|
127
|
+
* @param channelIdComposite The channel ID.
|
|
99
128
|
* @returns A promise that resolves when the sign-out operation is complete.
|
|
100
129
|
*/
|
|
101
|
-
async signOut(userId, connectionName,
|
|
130
|
+
async signOut(userId, connectionName, channelIdComposite) {
|
|
131
|
+
const [channelId] = agents_activity_1.Activity.parseChannelId(channelIdComposite);
|
|
102
132
|
const params = { userId, connectionName, channelId };
|
|
103
133
|
const response = await this.client.delete('/api/usertoken/SignOut', { params });
|
|
104
134
|
if (response.status !== 200) {
|
|
@@ -130,11 +160,12 @@ class UserTokenClient {
|
|
|
130
160
|
* Exchanges the token.
|
|
131
161
|
* @param userId The user ID.
|
|
132
162
|
* @param connectionName The connection name.
|
|
133
|
-
* @param
|
|
163
|
+
* @param channelIdComposite The channel ID.
|
|
134
164
|
* @param tokenExchangeRequest The token exchange request.
|
|
135
165
|
* @returns A promise that resolves to the exchanged token.
|
|
136
166
|
*/
|
|
137
|
-
async exchangeTokenAsync(userId, connectionName,
|
|
167
|
+
async exchangeTokenAsync(userId, connectionName, channelIdComposite, tokenExchangeRequest) {
|
|
168
|
+
const [channelId] = agents_activity_1.Activity.parseChannelId(channelIdComposite);
|
|
138
169
|
const params = { userId, connectionName, channelId };
|
|
139
170
|
const response = await this.client.post('/api/usertoken/exchange', tokenExchangeRequest, { params });
|
|
140
171
|
if (response === null || response === void 0 ? void 0 : response.data) {
|
|
@@ -148,7 +179,7 @@ class UserTokenClient {
|
|
|
148
179
|
* Gets the token or sign-in resource.
|
|
149
180
|
* @param userId The user ID.
|
|
150
181
|
* @param connectionName The connection name.
|
|
151
|
-
* @param
|
|
182
|
+
* @param channelIdComposite The channel ID.
|
|
152
183
|
* @param conversation The conversation reference.
|
|
153
184
|
* @param relatesTo The related conversation reference.
|
|
154
185
|
* @param code The code.
|
|
@@ -156,7 +187,8 @@ class UserTokenClient {
|
|
|
156
187
|
* @param fwdUrl The forward URL.
|
|
157
188
|
* @returns A promise that resolves to the token or sign-in resource response.
|
|
158
189
|
*/
|
|
159
|
-
async getTokenOrSignInResource(userId, connectionName,
|
|
190
|
+
async getTokenOrSignInResource(userId, connectionName, channelIdComposite, conversation, relatesTo, code, finalRedirect = '', fwdUrl = '') {
|
|
191
|
+
const [channelId] = agents_activity_1.Activity.parseChannelId(channelIdComposite);
|
|
160
192
|
const state = Buffer.from(JSON.stringify({ conversation, relatesTo, connectionName, msAppId: this.msAppId })).toString('base64');
|
|
161
193
|
const params = { userId, connectionName, channelId, state, code, finalRedirect, fwdUrl };
|
|
162
194
|
const response = await this.client.get('/api/usertoken/GetTokenOrSignInResource', { params });
|
|
@@ -165,11 +197,12 @@ class UserTokenClient {
|
|
|
165
197
|
/**
|
|
166
198
|
* Gets the token status.
|
|
167
199
|
* @param userId The user ID.
|
|
168
|
-
* @param
|
|
200
|
+
* @param channelIdComposite The channel ID.
|
|
169
201
|
* @param include The optional include parameter.
|
|
170
202
|
* @returns A promise that resolves to the token status.
|
|
171
203
|
*/
|
|
172
|
-
async getTokenStatus(userId,
|
|
204
|
+
async getTokenStatus(userId, channelIdComposite, include = null) {
|
|
205
|
+
const [channelId] = agents_activity_1.Activity.parseChannelId(channelIdComposite);
|
|
173
206
|
const params = { userId, channelId, include };
|
|
174
207
|
const response = await this.client.get('/api/usertoken/GetTokenStatus', { params });
|
|
175
208
|
return response.data;
|
|
@@ -178,11 +211,12 @@ class UserTokenClient {
|
|
|
178
211
|
* Gets the AAD tokens.
|
|
179
212
|
* @param userId The user ID.
|
|
180
213
|
* @param connectionName The connection name.
|
|
181
|
-
* @param
|
|
214
|
+
* @param channelIdComposite The channel ID.
|
|
182
215
|
* @param resourceUrls The resource URLs.
|
|
183
216
|
* @returns A promise that resolves to the AAD tokens.
|
|
184
217
|
*/
|
|
185
|
-
async getAadTokens(userId, connectionName,
|
|
218
|
+
async getAadTokens(userId, connectionName, channelIdComposite, resourceUrls) {
|
|
219
|
+
const [channelId] = agents_activity_1.Activity.parseChannelId(channelIdComposite);
|
|
186
220
|
const params = { userId, connectionName, channelId };
|
|
187
221
|
const response = await this.client.post('/api/usertoken/GetAadTokens', resourceUrls, { params });
|
|
188
222
|
return response.data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userTokenClient.js","sourceRoot":"","sources":["../../../src/oauth/userTokenClient.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;AAElC,kDAA4C;
|
|
1
|
+
{"version":3,"file":"userTokenClient.js","sourceRoot":"","sources":["../../../src/oauth/userTokenClient.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;AAElC,kDAA4C;AAC5C,gEAA4E;AAC5E,8DAAyD;AACzD,8DAAmE;AAEnE,sDAAkD;AAGlD,6DAA8D;AAE9D,MAAM,MAAM,GAAG,IAAA,cAAK,EAAC,0BAA0B,CAAC,CAAA;AAEhD;;GAEG;AACH,MAAa,eAAe;IAc1B,YAAa,KAA6B;QAZlC,YAAO,GAAW,EAAE,CAAA;QAa1B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,OAAO,GAAG,IAAA,4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A;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,+BAA+B,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;QACnF,OAAO,QAAQ,CAAC,IAAqB,CAAA;IACvC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,YAAY,CAAE,MAAc,EAAE,cAAsB,EAAE,kBAA0B,EAAE,YAA6B;QACnH,MAAM,CAAC,SAAS,CAAC,GAAG,0BAAQ,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAA;QAC/D,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,CAAA;QACpD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;QAChG,OAAO,QAAQ,CAAC,IAAqC,CAAA;IACvD,CAAC;IAEM,eAAe,CAAE,KAAa;QACnC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAA;IACvE,CAAC;CACF;AA5OD,0CA4OC"}
|
|
@@ -15,17 +15,30 @@ export interface TokenResponse {
|
|
|
15
15
|
*/
|
|
16
16
|
export interface TokenExchangeRequest {
|
|
17
17
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
* The URI for the token exchange request.
|
|
19
|
+
*/
|
|
20
20
|
uri?: string;
|
|
21
21
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
* The token to be exchanged.
|
|
23
|
+
*/
|
|
24
24
|
token?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Represents the response for a token exchange invoke operation.
|
|
28
|
+
*/
|
|
29
|
+
export interface TokenExchangeInvokeResponse {
|
|
25
30
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
* The connection name associated with the token exchange response.
|
|
32
|
+
*/
|
|
33
|
+
connectionName: string;
|
|
34
|
+
/**
|
|
35
|
+
* The ID associated with the token exchange response.
|
|
36
|
+
*/
|
|
28
37
|
id?: string;
|
|
38
|
+
/**
|
|
39
|
+
* (Optional) Details about any failure that occurred during the token exchange.
|
|
40
|
+
*/
|
|
41
|
+
failureDetail?: string;
|
|
29
42
|
}
|
|
30
43
|
/**
|
|
31
44
|
* Represents a resource for exchanging tokens.
|
|
@@ -5,6 +5,7 @@ import { TurnContextStateCollection } from './turnContextStateCollection';
|
|
|
5
5
|
import { AttachmentInfo } from './connector-client/attachmentInfo';
|
|
6
6
|
import { AttachmentData } from './connector-client/attachmentData';
|
|
7
7
|
import { StreamingResponse } from './app/streaming/streamingResponse';
|
|
8
|
+
import { JwtPayload } from 'jsonwebtoken';
|
|
8
9
|
/**
|
|
9
10
|
* Defines a handler for processing and sending activities.
|
|
10
11
|
* Used for middleware that needs to intercept or modify activities being sent.
|
|
@@ -64,13 +65,14 @@ export declare class TurnContext {
|
|
|
64
65
|
private readonly _turn;
|
|
65
66
|
private readonly _locale;
|
|
66
67
|
private readonly _streamingResponse;
|
|
68
|
+
private readonly _identity?;
|
|
67
69
|
/**
|
|
68
70
|
* Initializes a new instance of the TurnContext class.
|
|
69
71
|
*
|
|
70
72
|
* @param adapterOrContext The adapter that created this context, or another TurnContext to clone
|
|
71
73
|
* @param request The activity for the turn (required when first parameter is an adapter)
|
|
72
74
|
*/
|
|
73
|
-
constructor(adapterOrContext: BaseAdapter, request: Activity);
|
|
75
|
+
constructor(adapterOrContext: BaseAdapter, request: Activity, identity?: JwtPayload);
|
|
74
76
|
constructor(adapterOrContext: TurnContext);
|
|
75
77
|
/**
|
|
76
78
|
* A list of reply activities that are buffered until the end of the turn.
|
|
@@ -138,6 +140,7 @@ export declare class TurnContext {
|
|
|
138
140
|
*/
|
|
139
141
|
deleteActivity(idOrReference: string | ConversationReference): Promise<void>;
|
|
140
142
|
/**
|
|
143
|
+
* @deprecated This function will not be supported in future versions. Use TurnContext.turnState.get<ConnectorClient>(CloudAdapter.ConnectorClientKey).
|
|
141
144
|
* Uploads an attachment to the conversation.
|
|
142
145
|
*
|
|
143
146
|
* @param conversationId The ID of the conversation
|
|
@@ -146,6 +149,7 @@ export declare class TurnContext {
|
|
|
146
149
|
*/
|
|
147
150
|
uploadAttachment(conversationId: string, attachmentData: AttachmentData): Promise<ResourceResponse>;
|
|
148
151
|
/**
|
|
152
|
+
* @deprecated This function will not be supported in future versions. Use TurnContext.turnState.get<ConnectorClient>(CloudAdapter.ConnectorClientKey).
|
|
149
153
|
* Gets information about an attachment.
|
|
150
154
|
*
|
|
151
155
|
* @param attachmentId The ID of the attachment
|
|
@@ -153,6 +157,7 @@ export declare class TurnContext {
|
|
|
153
157
|
*/
|
|
154
158
|
getAttachmentInfo(attachmentId: string): Promise<AttachmentInfo>;
|
|
155
159
|
/**
|
|
160
|
+
* @deprecated This function will not be supported in future versions. Use TurnContext.turnState.get<ConnectorClient>(CloudAdapter.ConnectorClientKey).
|
|
156
161
|
* Gets the content of an attachment.
|
|
157
162
|
*
|
|
158
163
|
* @param attachmentId The ID of the attachment
|
|
@@ -210,6 +215,7 @@ export declare class TurnContext {
|
|
|
210
215
|
* and triggered the creation of this context.
|
|
211
216
|
*/
|
|
212
217
|
get activity(): Activity;
|
|
218
|
+
get identity(): JwtPayload;
|
|
213
219
|
/**
|
|
214
220
|
* Gets or sets whether the turn has sent a response to the user.
|
|
215
221
|
*
|
package/dist/src/turnContext.js
CHANGED
|
@@ -28,7 +28,7 @@ exports.AgentCallbackHandlerKey = 'agentCallbackHandler';
|
|
|
28
28
|
* This class follows the builder pattern for registering middleware handlers.
|
|
29
29
|
*/
|
|
30
30
|
class TurnContext {
|
|
31
|
-
constructor(adapterOrContext, request) {
|
|
31
|
+
constructor(adapterOrContext, request, identity) {
|
|
32
32
|
this._respondedRef = { responded: false };
|
|
33
33
|
this._turnState = new turnContextStateCollection_1.TurnContextStateCollection();
|
|
34
34
|
this._onSendActivities = [];
|
|
@@ -49,6 +49,7 @@ class TurnContext {
|
|
|
49
49
|
else {
|
|
50
50
|
this._adapter = adapterOrContext;
|
|
51
51
|
this._activity = request;
|
|
52
|
+
this._identity = identity;
|
|
52
53
|
}
|
|
53
54
|
this._streamingResponse = new streamingResponse_1.StreamingResponse(this);
|
|
54
55
|
}
|
|
@@ -196,6 +197,7 @@ class TurnContext {
|
|
|
196
197
|
return await this.emit(this._onDeleteActivity, reference, async () => await this.adapter.deleteActivity(this, reference));
|
|
197
198
|
}
|
|
198
199
|
/**
|
|
200
|
+
* @deprecated This function will not be supported in future versions. Use TurnContext.turnState.get<ConnectorClient>(CloudAdapter.ConnectorClientKey).
|
|
199
201
|
* Uploads an attachment to the conversation.
|
|
200
202
|
*
|
|
201
203
|
* @param conversationId The ID of the conversation
|
|
@@ -203,18 +205,20 @@ class TurnContext {
|
|
|
203
205
|
* @returns A promise that resolves to the resource response
|
|
204
206
|
*/
|
|
205
207
|
async uploadAttachment(conversationId, attachmentData) {
|
|
206
|
-
return await this.adapter.uploadAttachment(conversationId, attachmentData);
|
|
208
|
+
return await this.adapter.uploadAttachment(this, conversationId, attachmentData);
|
|
207
209
|
}
|
|
208
210
|
/**
|
|
211
|
+
* @deprecated This function will not be supported in future versions. Use TurnContext.turnState.get<ConnectorClient>(CloudAdapter.ConnectorClientKey).
|
|
209
212
|
* Gets information about an attachment.
|
|
210
213
|
*
|
|
211
214
|
* @param attachmentId The ID of the attachment
|
|
212
215
|
* @returns A promise that resolves to the attachment information
|
|
213
216
|
*/
|
|
214
217
|
async getAttachmentInfo(attachmentId) {
|
|
215
|
-
return await this.adapter.getAttachmentInfo(attachmentId);
|
|
218
|
+
return await this.adapter.getAttachmentInfo(this, attachmentId);
|
|
216
219
|
}
|
|
217
220
|
/**
|
|
221
|
+
* @deprecated This function will not be supported in future versions. Use TurnContext.turnState.get<ConnectorClient>(CloudAdapter.ConnectorClientKey).
|
|
218
222
|
* Gets the content of an attachment.
|
|
219
223
|
*
|
|
220
224
|
* @param attachmentId The ID of the attachment
|
|
@@ -222,7 +226,7 @@ class TurnContext {
|
|
|
222
226
|
* @returns A promise that resolves to a readable stream of the attachment content
|
|
223
227
|
*/
|
|
224
228
|
async getAttachment(attachmentId, viewId) {
|
|
225
|
-
return await this.adapter.getAttachment(attachmentId, viewId);
|
|
229
|
+
return await this.adapter.getAttachment(this, attachmentId, viewId);
|
|
226
230
|
}
|
|
227
231
|
/**
|
|
228
232
|
* Registers a handler for intercepting and processing activities being sent.
|
|
@@ -289,6 +293,9 @@ class TurnContext {
|
|
|
289
293
|
get activity() {
|
|
290
294
|
return this._activity;
|
|
291
295
|
}
|
|
296
|
+
get identity() {
|
|
297
|
+
return this._identity;
|
|
298
|
+
}
|
|
292
299
|
/**
|
|
293
300
|
* Gets or sets whether the turn has sent a response to the user.
|
|
294
301
|
*
|
|
@@ -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;
|
|
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,MAAa,WAAW;IAqBtB,YAAa,gBAA2C,EAAE,OAAkB,EAAE,QAAqB;QAlBlF,kBAAa,GAA2B,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;QAC5D,eAAU,GAAG,IAAI,uDAA0B,EAAE,CAAA;QAC7C,sBAAiB,GAA4B,EAAE,CAAA;QAC/C,sBAAiB,GAA4B,EAAE,CAAA;QAC/C,sBAAiB,GAA4B,EAAE,CAAA;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AAG,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;AA7XD,kCA6XC"}
|
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.1.0-alpha.
|
|
4
|
+
"version": "1.1.0-alpha.75",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
"main": "dist/src/index.js",
|
|
20
20
|
"types": "dist/src/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@azure/core-auth": "^1.10.
|
|
23
|
-
"@azure/msal-node": "^3.
|
|
24
|
-
"@microsoft/agents-activity": "1.1.0-alpha.
|
|
25
|
-
"axios": "^1.
|
|
22
|
+
"@azure/core-auth": "^1.10.1",
|
|
23
|
+
"@azure/msal-node": "^3.8.1",
|
|
24
|
+
"@microsoft/agents-activity": "1.1.0-alpha.75",
|
|
25
|
+
"axios": "^1.13.1",
|
|
26
26
|
"jsonwebtoken": "^9.0.2",
|
|
27
|
-
"jwks-rsa": "^3.2.0"
|
|
27
|
+
"jwks-rsa": "^3.2.0",
|
|
28
|
+
"object-path": "^0.11.8"
|
|
28
29
|
},
|
|
29
30
|
"license": "MIT",
|
|
30
31
|
"files": [
|
|
@@ -43,5 +44,8 @@
|
|
|
43
44
|
},
|
|
44
45
|
"engines": {
|
|
45
46
|
"node": ">=20.0.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/object-path": "^0.11.4"
|
|
46
50
|
}
|
|
47
51
|
}
|
|
@@ -24,14 +24,22 @@ export function normalizeIncomingActivity (payload: any): object {
|
|
|
24
24
|
* @param payload - The outgoing payload object to normalize.
|
|
25
25
|
* @returns The normalized payload object with `agent` replaced by `bot` in `relatesTo`.
|
|
26
26
|
*/
|
|
27
|
-
export function normalizeOutgoingActivity (payload: any): object {
|
|
28
|
-
if (payload
|
|
29
|
-
|
|
27
|
+
export function normalizeOutgoingActivity (payload: any): object | undefined | null {
|
|
28
|
+
if (!payload) {
|
|
29
|
+
return payload
|
|
30
|
+
}
|
|
31
|
+
const modifiedPayload = JSON.parse(JSON.stringify(payload))
|
|
32
|
+
if (modifiedPayload && modifiedPayload['relatesTo'] && modifiedPayload['relatesTo']['agent']) {
|
|
33
|
+
const relatesTo = modifiedPayload['relatesTo']
|
|
30
34
|
const ov = relatesTo['agent']
|
|
31
35
|
delete relatesTo['agent']
|
|
32
36
|
relatesTo['bot'] = ov
|
|
33
37
|
}
|
|
34
|
-
|
|
38
|
+
if (modifiedPayload && modifiedPayload['_channelId']) {
|
|
39
|
+
modifiedPayload['channelId'] = modifiedPayload['_channelId'].toString()
|
|
40
|
+
delete modifiedPayload['_channelId']
|
|
41
|
+
}
|
|
42
|
+
return modifiedPayload
|
|
35
43
|
}
|
|
36
44
|
|
|
37
45
|
export function normalizeTokenExchangeState (payload: any): object {
|
|
@@ -92,17 +92,23 @@ export class AgentClient {
|
|
|
92
92
|
const stateChanges = JSON.stringify(convRef)
|
|
93
93
|
logger.debug('stateChanges: ', stateChanges)
|
|
94
94
|
|
|
95
|
-
const authProvider = new MsalTokenProvider()
|
|
96
|
-
const token = await authProvider.getAccessToken(
|
|
95
|
+
const authProvider = new MsalTokenProvider(authConfig)
|
|
96
|
+
const token = await authProvider.getAccessToken(this.agentClientConfig.clientId)
|
|
97
97
|
|
|
98
98
|
logger.debug('agent request: ', activityCopy)
|
|
99
99
|
|
|
100
|
+
let authHeader = '' // Allow anonymous auth.
|
|
101
|
+
|
|
102
|
+
if (token.trim().length > 0) {
|
|
103
|
+
authHeader = `Bearer ${token}`
|
|
104
|
+
}
|
|
105
|
+
|
|
100
106
|
await conversationState.saveChanges(context, false, { channelId: activityCopy.channelId!, conversationId: activityCopy.conversation!.id })
|
|
101
107
|
const response = await fetch(this.agentClientConfig.endPoint, {
|
|
102
108
|
method: 'POST',
|
|
103
109
|
headers: {
|
|
104
110
|
'Content-Type': 'application/json',
|
|
105
|
-
Authorization:
|
|
111
|
+
Authorization: authHeader,
|
|
106
112
|
'x-ms-conversation-id': activityCopy.conversation!.id
|
|
107
113
|
},
|
|
108
114
|
body: JSON.stringify(activityCopy)
|