@microsoft/agents-hosting 1.5.0-beta.6.ga236d9a19c → 1.5.1
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 -9
- package/dist/src/activityHandler.js +2 -2
- package/dist/src/activityHandler.js.map +1 -1
- package/dist/src/agent-client/agentClient.js +49 -40
- package/dist/src/agent-client/agentClient.js.map +1 -1
- package/dist/src/agent-client/agentResponseHandler.js +2 -2
- package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
- package/dist/src/app/agentApplication.d.ts +36 -10
- package/dist/src/app/agentApplication.js +169 -99
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/agentApplicationBuilder.d.ts +15 -0
- package/dist/src/app/agentApplicationBuilder.js +22 -4
- package/dist/src/app/agentApplicationBuilder.js.map +1 -1
- package/dist/src/app/agentApplicationOptions.d.ts +38 -0
- package/dist/src/app/attachmentDownloader.js +2 -2
- package/dist/src/app/attachmentDownloader.js.map +1 -1
- package/dist/src/app/auth/authorization.js +12 -9
- 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 +258 -45
- 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 +46 -52
- package/dist/src/app/auth/handlers/agenticAuthorization.js.map +1 -1
- package/dist/src/app/auth/handlers/azureBotAuthorization.d.ts +51 -75
- package/dist/src/app/auth/handlers/azureBotAuthorization.js +217 -192
- package/dist/src/app/auth/handlers/azureBotAuthorization.js.map +1 -1
- package/dist/src/app/auth/types.d.ts +100 -1
- package/dist/src/app/auth/utils.d.ts +10 -0
- package/dist/src/app/auth/utils.js +21 -0
- package/dist/src/app/auth/utils.js.map +1 -0
- package/dist/src/app/index.d.ts +1 -0
- package/dist/src/app/index.js +1 -0
- package/dist/src/app/index.js.map +1 -1
- package/dist/src/app/proactive/conversation.d.ts +43 -0
- package/dist/src/app/proactive/conversation.js +67 -0
- package/dist/src/app/proactive/conversation.js.map +1 -0
- package/dist/src/app/proactive/conversationBuilder.d.ts +54 -0
- package/dist/src/app/proactive/conversationBuilder.js +110 -0
- package/dist/src/app/proactive/conversationBuilder.js.map +1 -0
- package/dist/src/app/proactive/conversationReferenceBuilder.d.ts +68 -0
- package/dist/src/app/proactive/conversationReferenceBuilder.js +125 -0
- package/dist/src/app/proactive/conversationReferenceBuilder.js.map +1 -0
- package/dist/src/app/proactive/createConversationOptions.d.ts +30 -0
- package/dist/src/app/proactive/createConversationOptions.js +10 -0
- package/dist/src/app/proactive/createConversationOptions.js.map +1 -0
- package/dist/src/app/proactive/createConversationOptionsBuilder.d.ts +69 -0
- package/dist/src/app/proactive/createConversationOptionsBuilder.js +141 -0
- package/dist/src/app/proactive/createConversationOptionsBuilder.js.map +1 -0
- package/dist/src/app/proactive/index.d.ts +7 -0
- package/dist/src/app/proactive/index.js +26 -0
- package/dist/src/app/proactive/index.js.map +1 -0
- package/dist/src/app/proactive/proactive.d.ts +248 -0
- package/dist/src/app/proactive/proactive.js +310 -0
- package/dist/src/app/proactive/proactive.js.map +1 -0
- package/dist/src/app/proactive/proactiveOptions.d.ts +19 -0
- package/dist/src/app/proactive/proactiveOptions.js +5 -0
- package/dist/src/app/proactive/proactiveOptions.js.map +1 -0
- package/dist/src/app/streaming/streamingResponse.js +2 -2
- package/dist/src/app/streaming/streamingResponse.js.map +1 -1
- package/dist/src/app/teamsAttachmentDownloader.js +2 -2
- package/dist/src/app/teamsAttachmentDownloader.js.map +1 -1
- package/dist/src/app/turnState.js +2 -2
- package/dist/src/app/turnState.js.map +1 -1
- package/dist/src/auth/authConfiguration.d.ts +61 -0
- package/dist/src/auth/authConfiguration.js +52 -3
- package/dist/src/auth/authConfiguration.js.map +1 -1
- package/dist/src/auth/jwt-middleware.js +2 -2
- package/dist/src/auth/jwt-middleware.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 +136 -110
- package/dist/src/auth/msalTokenProvider.js.map +1 -1
- package/dist/src/baseAdapter.js +2 -2
- package/dist/src/baseAdapter.js.map +1 -1
- package/dist/src/cloudAdapter.js +201 -154
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/connector-client/connectorClient.js +176 -127
- package/dist/src/connector-client/connectorClient.js.map +1 -1
- package/dist/src/errorHelper.js +108 -0
- package/dist/src/errorHelper.js.map +1 -1
- package/dist/src/middlewareSet.js +2 -2
- package/dist/src/middlewareSet.js.map +1 -1
- package/dist/src/oauth/userTokenClient.js +78 -48
- package/dist/src/oauth/userTokenClient.js.map +1 -1
- package/dist/src/observability/index.d.ts +2 -0
- package/dist/src/observability/index.js +21 -0
- package/dist/src/observability/index.js.map +1 -0
- package/dist/src/observability/metrics.d.ts +21 -0
- package/dist/src/observability/metrics.js +87 -0
- package/dist/src/observability/metrics.js.map +1 -0
- package/dist/src/observability/traces.d.ts +234 -0
- package/dist/src/observability/traces.js +962 -0
- package/dist/src/observability/traces.js.map +1 -0
- package/dist/src/state/agentState.js +2 -2
- package/dist/src/state/agentState.js.map +1 -1
- package/dist/src/storage/fileStorage.js +38 -28
- package/dist/src/storage/fileStorage.js.map +1 -1
- package/dist/src/storage/memoryStorage.js +41 -30
- package/dist/src/storage/memoryStorage.js.map +1 -1
- package/dist/src/transcript/fileTranscriptLogger.js +2 -2
- package/dist/src/transcript/fileTranscriptLogger.js.map +1 -1
- package/dist/src/transcript/transcriptLoggerMiddleware.js +2 -2
- package/dist/src/transcript/transcriptLoggerMiddleware.js.map +1 -1
- package/dist/src/turnContext.js +48 -42
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +10 -9
- package/src/activityHandler.ts +1 -1
- package/src/agent-client/agentClient.ts +53 -42
- package/src/agent-client/agentResponseHandler.ts +1 -1
- package/src/app/agentApplication.ts +212 -86
- package/src/app/agentApplicationBuilder.ts +26 -4
- package/src/app/agentApplicationOptions.ts +43 -0
- package/src/app/attachmentDownloader.ts +1 -1
- package/src/app/auth/authorization.ts +11 -8
- package/src/app/auth/authorizationManager.ts +297 -45
- package/src/app/auth/handlerStorage.ts +3 -1
- package/src/app/auth/handlers/agenticAuthorization.ts +68 -72
- package/src/app/auth/handlers/azureBotAuthorization.ts +260 -264
- package/src/app/auth/types.ts +102 -1
- package/src/app/auth/utils.ts +22 -0
- package/src/app/index.ts +1 -0
- package/src/app/proactive/conversation.ts +87 -0
- package/src/app/proactive/conversationBuilder.ts +139 -0
- package/src/app/proactive/conversationReferenceBuilder.ts +161 -0
- package/src/app/proactive/createConversationOptions.ts +35 -0
- package/src/app/proactive/createConversationOptionsBuilder.ts +181 -0
- package/src/app/proactive/index.ts +10 -0
- package/src/app/proactive/proactive.ts +524 -0
- package/src/app/proactive/proactiveOptions.ts +24 -0
- package/src/app/streaming/streamingResponse.ts +1 -1
- package/src/app/teamsAttachmentDownloader.ts +1 -1
- package/src/app/turnState.ts +1 -1
- package/src/auth/authConfiguration.ts +58 -1
- package/src/auth/jwt-middleware.ts +1 -1
- package/src/auth/msalConnectionManager.ts +22 -0
- package/src/auth/msalTokenCredential.ts +4 -0
- package/src/auth/msalTokenProvider.ts +138 -107
- package/src/baseAdapter.ts +1 -1
- package/src/cloudAdapter.ts +239 -184
- package/src/connector-client/connectorClient.ts +169 -126
- package/src/errorHelper.ts +124 -0
- package/src/middlewareSet.ts +1 -1
- package/src/oauth/userTokenClient.ts +70 -46
- package/src/observability/index.ts +5 -0
- package/src/observability/metrics.ts +103 -0
- package/src/observability/traces.ts +988 -0
- package/src/state/agentState.ts +1 -1
- package/src/storage/fileStorage.ts +36 -26
- package/src/storage/memoryStorage.ts +40 -29
- package/src/transcript/fileTranscriptLogger.ts +1 -1
- package/src/transcript/transcriptLoggerMiddleware.ts +1 -1
- package/src/turnContext.ts +47 -41
|
@@ -7,24 +7,30 @@ import { AuthorizationHandler, AuthorizationHandlerSettings, AuthorizationHandle
|
|
|
7
7
|
import { TokenResponse } from '../../../oauth';
|
|
8
8
|
/**
|
|
9
9
|
* Options for configuring the Agentic authorization handler.
|
|
10
|
+
* @remarks
|
|
11
|
+
* Properties can be configured via environment variables (case-insensitive).
|
|
12
|
+
* Use the format: `AgentApplication__UserAuthorization__handlers__{handlerId}__settings__{propertyName}`
|
|
13
|
+
* where `{handlerId}` is the handler's unique identifier and `{propertyName}` matches the property name.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```env
|
|
17
|
+
* # For a handler with id "myAuth":
|
|
18
|
+
* AgentApplication__UserAuthorization__handlers__myAuth__settings__type=AgenticUserAuthorization
|
|
19
|
+
* AgentApplication__UserAuthorization__handlers__myAuth__settings__scopes=api://scope1 api://scope2
|
|
20
|
+
* ```
|
|
10
21
|
*/
|
|
11
22
|
export interface AgenticAuthorizationOptions {
|
|
12
23
|
/**
|
|
13
24
|
* The type of authorization handler.
|
|
14
|
-
* @remarks
|
|
15
|
-
* When using environment variables, this can be set using the `${authHandlerId}_type` variable.
|
|
16
25
|
*/
|
|
17
|
-
type: 'agentic';
|
|
26
|
+
type: 'AgenticUserAuthorization' | 'agentic';
|
|
18
27
|
/**
|
|
19
28
|
* The scopes required for the authorization.
|
|
20
|
-
* @remarks
|
|
21
|
-
* When using environment variables, this can be set using the `${authHandlerId}_scopes` variable (comma-separated values, e.g. `scope1,scope2`).
|
|
29
|
+
* @remarks When set via environment variable, use comma or space-separated values (e.g. `scope1,scope2` or `scope1 scope2`).
|
|
22
30
|
*/
|
|
23
31
|
scopes?: string[];
|
|
24
32
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @remarks
|
|
27
|
-
* When using environment variables, this can be set using the `${authHandlerId}_altBlueprintConnectionName` variable.
|
|
33
|
+
* An alternative connection name to use for the authorization process.
|
|
28
34
|
*/
|
|
29
35
|
altBlueprintConnectionName?: string;
|
|
30
36
|
}
|
|
@@ -38,21 +44,22 @@ export interface AgenticAuthorizationSettings extends AuthorizationHandlerSettin
|
|
|
38
44
|
*/
|
|
39
45
|
export declare class AgenticAuthorization implements AuthorizationHandler {
|
|
40
46
|
readonly id: string;
|
|
47
|
+
private options;
|
|
41
48
|
private settings;
|
|
42
|
-
private _options;
|
|
43
49
|
private _onSuccess?;
|
|
44
50
|
private _onFailure?;
|
|
45
51
|
/**
|
|
46
52
|
* Creates an instance of the AgenticAuthorization class.
|
|
47
53
|
* @param id The unique identifier for the authorization handler.
|
|
48
|
-
* @param options The options for configuring the authorization handler.
|
|
54
|
+
* @param options The options for configuring the authorization handler (must be fully resolved).
|
|
49
55
|
* @param settings The settings for the authorization handler.
|
|
50
56
|
*/
|
|
51
57
|
constructor(id: string, options: AgenticAuthorizationOptions, settings: AgenticAuthorizationSettings);
|
|
58
|
+
readonly type = "agentic";
|
|
52
59
|
/**
|
|
53
|
-
*
|
|
60
|
+
* The scopes configured for this handler.
|
|
54
61
|
*/
|
|
55
|
-
|
|
62
|
+
get scopes(): string[] | undefined;
|
|
56
63
|
/**
|
|
57
64
|
* @inheritdoc
|
|
58
65
|
*/
|
|
@@ -90,8 +97,4 @@ export declare class AgenticAuthorization implements AuthorizationHandler {
|
|
|
90
97
|
* @param scopes The OAuth scopes for which the context is being retrieved.
|
|
91
98
|
*/
|
|
92
99
|
private getContext;
|
|
93
|
-
/**
|
|
94
|
-
* Loads the OAuth scopes from the environment variables.
|
|
95
|
-
*/
|
|
96
|
-
private loadScopes;
|
|
97
100
|
}
|
|
@@ -6,8 +6,11 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.AgenticAuthorization = void 0;
|
|
8
8
|
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
9
|
+
const agents_telemetry_1 = require("@microsoft/agents-telemetry");
|
|
9
10
|
const types_1 = require("../types");
|
|
10
|
-
const
|
|
11
|
+
const observability_1 = require("../../../observability");
|
|
12
|
+
const errorHelper_1 = require("../../../errorHelper");
|
|
13
|
+
const logger = (0, agents_telemetry_1.debug)('agents:authorization:agentic');
|
|
11
14
|
/**
|
|
12
15
|
* Authorization handler for Agentic authentication.
|
|
13
16
|
*/
|
|
@@ -15,32 +18,27 @@ class AgenticAuthorization {
|
|
|
15
18
|
/**
|
|
16
19
|
* Creates an instance of the AgenticAuthorization class.
|
|
17
20
|
* @param id The unique identifier for the authorization handler.
|
|
18
|
-
* @param options The options for configuring the authorization handler.
|
|
21
|
+
* @param options The options for configuring the authorization handler (must be fully resolved).
|
|
19
22
|
* @param settings The settings for the authorization handler.
|
|
20
23
|
*/
|
|
21
24
|
constructor(id, options, settings) {
|
|
22
25
|
this.id = id;
|
|
26
|
+
this.options = options;
|
|
23
27
|
this.settings = settings;
|
|
28
|
+
this.type = 'agentic';
|
|
24
29
|
this._key = `${AgenticAuthorization.name}/${this.id}`;
|
|
25
30
|
if (!this.settings.connections) {
|
|
26
|
-
throw
|
|
31
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ConnectionsOptionNotAvailable);
|
|
32
|
+
}
|
|
33
|
+
if (!options.scopes || options.scopes.length === 0) {
|
|
34
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.AtLeastOneScopeRequired);
|
|
27
35
|
}
|
|
28
|
-
this._options = this.loadOptions(options);
|
|
29
36
|
}
|
|
30
37
|
/**
|
|
31
|
-
*
|
|
38
|
+
* The scopes configured for this handler.
|
|
32
39
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const result = {
|
|
36
|
-
type: 'agentic',
|
|
37
|
-
altBlueprintConnectionName: (_a = settings.altBlueprintConnectionName) !== null && _a !== void 0 ? _a : (process.env[`${this.id}_altBlueprintConnectionName`]),
|
|
38
|
-
scopes: (_b = settings.scopes) !== null && _b !== void 0 ? _b : this.loadScopes(process.env[`${this.id}_scopes`]),
|
|
39
|
-
};
|
|
40
|
-
if (!result.scopes || result.scopes.length === 0) {
|
|
41
|
-
throw new Error(this.prefix('At least one scope must be specified for the Agentic authorization handler.'));
|
|
42
|
-
}
|
|
43
|
-
return result;
|
|
40
|
+
get scopes() {
|
|
41
|
+
return this.options.scopes;
|
|
44
42
|
}
|
|
45
43
|
/**
|
|
46
44
|
* @inheritdoc
|
|
@@ -58,32 +56,41 @@ class AgenticAuthorization {
|
|
|
58
56
|
* @inheritdoc
|
|
59
57
|
*/
|
|
60
58
|
async token(context, options) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const scopes = (options === null || options === void 0 ? void 0 : options.scopes) || this._options.scopes;
|
|
64
|
-
const tokenResponse = this.getContext(context, scopes);
|
|
65
|
-
if (tokenResponse.token) {
|
|
66
|
-
logger.debug(this.prefix('Using cached Agentic user token'));
|
|
67
|
-
return tokenResponse;
|
|
68
|
-
}
|
|
59
|
+
return (0, agents_telemetry_1.trace)(observability_1.AuthorizationTraceDefinitions.agenticToken, async ({ record }) => {
|
|
60
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
69
61
|
let connection;
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
const scopes = (options === null || options === void 0 ? void 0 : options.scopes) || this.options.scopes;
|
|
63
|
+
try {
|
|
64
|
+
const tokenResponse = this.getContext(context, scopes);
|
|
65
|
+
if (tokenResponse.token) {
|
|
66
|
+
logger.debug(this.prefix('Using cached Agentic user token'));
|
|
67
|
+
return tokenResponse;
|
|
68
|
+
}
|
|
69
|
+
if ((_a = this.options.altBlueprintConnectionName) === null || _a === void 0 ? void 0 : _a.trim()) {
|
|
70
|
+
connection = this.settings.connections.getConnection(this.options.altBlueprintConnectionName);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
connection = this.settings.connections.getTokenProvider(context.identity, (_b = context.activity.serviceUrl) !== null && _b !== void 0 ? _b : '');
|
|
74
|
+
}
|
|
75
|
+
const token = await connection.getAgenticUserToken((_c = context.activity.getAgenticTenantId()) !== null && _c !== void 0 ? _c : '', (_d = context.activity.getAgenticInstanceId()) !== null && _d !== void 0 ? _d : '', (_e = context.activity.getAgenticUser()) !== null && _e !== void 0 ? _e : '', scopes);
|
|
76
|
+
this.setContext(context, scopes, { token });
|
|
77
|
+
(_f = this._onSuccess) === null || _f === void 0 ? void 0 : _f.call(this, context);
|
|
78
|
+
return { token };
|
|
72
79
|
}
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
catch (error) {
|
|
81
|
+
const reason = 'Error retrieving Agentic user token';
|
|
82
|
+
logger.error(this.prefix(reason), error);
|
|
83
|
+
(_g = this._onFailure) === null || _g === void 0 ? void 0 : _g.call(this, context, `${reason}: ${error.message}`);
|
|
84
|
+
return { token: undefined };
|
|
75
85
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
(_g = this._onFailure) === null || _g === void 0 ? void 0 : _g.call(this, context, `${reason}: ${error.message}`);
|
|
85
|
-
return { token: undefined };
|
|
86
|
-
}
|
|
86
|
+
finally {
|
|
87
|
+
record({
|
|
88
|
+
handlerId: this.id,
|
|
89
|
+
connectionName: (_k = (_j = (_h = connection === null || connection === void 0 ? void 0 : connection.connectionSettings) === null || _h === void 0 ? void 0 : _h.connectionName) !== null && _j !== void 0 ? _j : this.options.altBlueprintConnectionName) !== null && _k !== void 0 ? _k : 'unknown',
|
|
90
|
+
authScopes: scopes !== null && scopes !== void 0 ? scopes : []
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
87
94
|
}
|
|
88
95
|
/**
|
|
89
96
|
* @inheritdoc
|
|
@@ -121,19 +128,6 @@ class AgenticAuthorization {
|
|
|
121
128
|
const result = context.turnState.get(`${this._key}:${scopes.join(';')}`);
|
|
122
129
|
return (_a = result === null || result === void 0 ? void 0 : result()) !== null && _a !== void 0 ? _a : { token: undefined };
|
|
123
130
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Loads the OAuth scopes from the environment variables.
|
|
126
|
-
*/
|
|
127
|
-
loadScopes(value) {
|
|
128
|
-
var _a;
|
|
129
|
-
return (_a = value === null || value === void 0 ? void 0 : value.split(',').reduce((acc, scope) => {
|
|
130
|
-
const trimmed = scope.trim();
|
|
131
|
-
if (trimmed) {
|
|
132
|
-
acc.push(trimmed);
|
|
133
|
-
}
|
|
134
|
-
return acc;
|
|
135
|
-
}, [])) !== null && _a !== void 0 ? _a : [];
|
|
136
|
-
}
|
|
137
131
|
}
|
|
138
132
|
exports.AgenticAuthorization = AgenticAuthorization;
|
|
139
133
|
//# sourceMappingURL=agenticAuthorization.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agenticAuthorization.js","sourceRoot":"","sources":["../../../../../src/app/auth/handlers/agenticAuthorization.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"agenticAuthorization.js","sourceRoot":"","sources":["../../../../../src/app/auth/handlers/agenticAuthorization.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAA4D;AAE5D,kEAA0D;AAC1D,oCAA2I;AAG3I,0DAAsE;AACtE,sDAA6C;AAE7C,MAAM,MAAM,GAAG,IAAA,wBAAK,EAAC,8BAA8B,CAAC,CAAA;AAqCpD;;GAEG;AACH,MAAa,oBAAoB;IAI/B;;;;;OAKG;IACH,YAA6B,EAAU,EAAU,OAAoC,EAAU,QAAsC;QAAxG,OAAE,GAAF,EAAE,CAAQ;QAAU,YAAO,GAAP,OAAO,CAA6B;QAAU,aAAQ,GAAR,QAAQ,CAA8B;QAU5H,SAAI,GAAG,SAAS,CAAA;QA0FjB,SAAI,GAAG,GAAG,oBAAoB,CAAC,IAAI,IAAI,IAAI,CAAC,EAA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
|
*/
|
|
23
23
|
category?: Category;
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Messages configuration for the AzureBotAuthorization handler.
|
|
27
|
-
*/
|
|
28
|
-
export interface AzureBotAuthorizationOptionsMessages {
|
|
29
|
-
/**
|
|
30
|
-
* Message displayed when an invalid code is entered.
|
|
31
|
-
* Use `{code}` as a placeholder for the entered code.
|
|
32
|
-
* Defaults to: 'The code entered is invalid. Please sign-in again to continue.'
|
|
33
|
-
*/
|
|
34
|
-
invalidCode?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Message displayed when the entered code format is invalid.
|
|
37
|
-
* Use `{attemptsLeft}` as a placeholder for the number of attempts left.
|
|
38
|
-
* Defaults to: 'Please enter a valid **6-digit** code format (_e.g. 123456_).\r\n**{attemptsLeft} attempt(s) left...**'
|
|
39
|
-
*/
|
|
40
|
-
invalidCodeFormat?: string;
|
|
41
|
-
/**
|
|
42
|
-
* Message displayed when the maximum number of attempts is exceeded.
|
|
43
|
-
* Use `{maxAttempts}` as a placeholder for the maximum number of attempts.
|
|
44
|
-
* Defaults to: 'You have exceeded the maximum number of sign-in attempts ({maxAttempts}).'
|
|
45
|
-
*/
|
|
46
|
-
maxAttemptsExceeded?: string;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Settings for on-behalf-of token acquisition.
|
|
50
|
-
*/
|
|
51
|
-
export interface AzureBotAuthorizationOptionsOBO {
|
|
52
|
-
/**
|
|
53
|
-
* Connection name to use for on-behalf-of token acquisition.
|
|
54
|
-
*/
|
|
55
|
-
connection?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Scopes to request for on-behalf-of token acquisition.
|
|
58
|
-
*/
|
|
59
|
-
scopes?: string[];
|
|
60
|
-
}
|
|
61
25
|
/**
|
|
62
26
|
* Interface defining an authorization handler configuration.
|
|
27
|
+
* @remarks
|
|
28
|
+
* Properties can be configured via environment variables (case-insensitive).
|
|
29
|
+
* Use the format: `AgentApplication__UserAuthorization__handlers__{handlerId}__settings__{propertyName}`
|
|
30
|
+
* where `{handlerId}` is the handler's unique identifier and `{propertyName}` matches the property name.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```env
|
|
34
|
+
* # For a handler with id "myAuth":
|
|
35
|
+
* AgentApplication__UserAuthorization__handlers__myAuth__settings__azureBotOAuthConnectionName=MyConnection
|
|
36
|
+
* AgentApplication__UserAuthorization__handlers__myAuth__settings__oboScopes=api://scope1 api://scope2
|
|
37
|
+
* ```
|
|
63
38
|
*/
|
|
64
39
|
export interface AzureBotAuthorizationOptions {
|
|
65
40
|
/**
|
|
@@ -67,48 +42,50 @@ export interface AzureBotAuthorizationOptions {
|
|
|
67
42
|
* This property is optional and should not be set when configuring this handler.
|
|
68
43
|
* It is included here for completeness and type safety.
|
|
69
44
|
*/
|
|
70
|
-
type?: undefined;
|
|
45
|
+
type?: 'AzureBotUserAuthorization' | undefined;
|
|
71
46
|
/**
|
|
72
47
|
* Connection name for the auth provider.
|
|
73
|
-
* @remarks
|
|
74
|
-
* When using environment variables, this can be set using the `${authHandlerId}_connectionName` variable.
|
|
75
48
|
*/
|
|
76
|
-
|
|
49
|
+
azureBotOAuthConnectionName?: string;
|
|
77
50
|
/**
|
|
78
51
|
* Title to display on auth cards/UI.
|
|
79
|
-
* @remarks
|
|
80
|
-
* When using environment variables, this can be set using the `${authHandlerId}_connectionTitle` variable.
|
|
81
52
|
*/
|
|
82
53
|
title?: string;
|
|
83
54
|
/**
|
|
84
55
|
* Text to display on auth cards/UI.
|
|
85
|
-
* @remarks
|
|
86
|
-
* When using environment variables, this can be set using the `${authHandlerId}_connectionText` variable.
|
|
87
56
|
*/
|
|
88
57
|
text?: string;
|
|
89
58
|
/**
|
|
90
59
|
* Maximum number of attempts for entering the magic code. Defaults to 2.
|
|
91
|
-
* @remarks
|
|
92
|
-
* When using environment variables, this can be set using the `${authHandlerId}_maxAttempts` variable.
|
|
93
60
|
*/
|
|
94
|
-
|
|
61
|
+
invalidSignInRetryMax?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Message displayed when an invalid code is entered.
|
|
64
|
+
* Use `{code}` as a placeholder to display the entered code.
|
|
65
|
+
* Defaults to: 'The code entered is invalid. Please sign-in again to continue.'
|
|
66
|
+
*/
|
|
67
|
+
invalidSignInRetryMessage?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Message displayed when the entered code format is invalid.
|
|
70
|
+
* Use `{attemptsLeft}` as a placeholder to display the number of attempts left.
|
|
71
|
+
* Defaults to: 'Please enter a valid **6-digit** code format (_e.g. 123456_).\r\n**{attemptsLeft} attempt(s) left...**'
|
|
72
|
+
*/
|
|
73
|
+
invalidSignInRetryMessageFormat?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Message displayed when the maximum number of attempts is exceeded.
|
|
76
|
+
* Use `{maxAttempts}` as a placeholder to display the maximum number of attempts.
|
|
77
|
+
* Defaults to: 'You have exceeded the maximum number of sign-in attempts ({maxAttempts}).'
|
|
78
|
+
*/
|
|
79
|
+
invalidSignInRetryMaxExceededMessage?: string;
|
|
95
80
|
/**
|
|
96
|
-
*
|
|
97
|
-
* @remarks
|
|
98
|
-
* When using environment variables, these can be set using the following variables:
|
|
99
|
-
* - `${authHandlerId}_messages_invalidCode`
|
|
100
|
-
* - `${authHandlerId}_messages_invalidCodeFormat`
|
|
101
|
-
* - `${authHandlerId}_messages_maxAttemptsExceeded`
|
|
81
|
+
* Connection name to use for on-behalf-of token acquisition.
|
|
102
82
|
*/
|
|
103
|
-
|
|
83
|
+
oboConnectionName?: string;
|
|
104
84
|
/**
|
|
105
|
-
*
|
|
106
|
-
* @remarks
|
|
107
|
-
* When using environment variables, these can be set using the following variables:
|
|
108
|
-
* - `${authHandlerId}_obo_connection`
|
|
109
|
-
* - `${authHandlerId}_obo_scopes` (comma-separated values, e.g. `scope1,scope2`)
|
|
85
|
+
* Scopes to request for on-behalf-of token acquisition.
|
|
86
|
+
* @remarks When set via environment variable, use comma or space-separated values (e.g. `scope1,scope2` or `scope1 scope2`).
|
|
110
87
|
*/
|
|
111
|
-
|
|
88
|
+
oboScopes?: string[];
|
|
112
89
|
/**
|
|
113
90
|
* Option to enable SSO when authenticating using Azure Active Directory (AAD). Defaults to true.
|
|
114
91
|
*/
|
|
@@ -124,21 +101,22 @@ export interface AzureBotAuthorizationSettings extends AuthorizationHandlerSetti
|
|
|
124
101
|
*/
|
|
125
102
|
export declare class AzureBotAuthorization implements AuthorizationHandler {
|
|
126
103
|
readonly id: string;
|
|
104
|
+
private options;
|
|
127
105
|
private settings;
|
|
128
|
-
private _options;
|
|
129
106
|
private _onSuccess?;
|
|
130
107
|
private _onFailure?;
|
|
131
108
|
/**
|
|
132
109
|
* Creates an instance of the AzureBotAuthorization.
|
|
133
110
|
* @param id The unique identifier for the handler.
|
|
134
|
-
* @param options The settings for the handler.
|
|
135
|
-
* @param
|
|
111
|
+
* @param options The settings for the handler (must be fully resolved).
|
|
112
|
+
* @param settings The authorization handler settings.
|
|
136
113
|
*/
|
|
137
114
|
constructor(id: string, options: AzureBotAuthorizationOptions, settings: AzureBotAuthorizationSettings);
|
|
115
|
+
readonly type = "azurebot";
|
|
138
116
|
/**
|
|
139
|
-
*
|
|
117
|
+
* The OBO scopes configured for this handler.
|
|
140
118
|
*/
|
|
141
|
-
|
|
119
|
+
get scopes(): string[] | undefined;
|
|
142
120
|
/**
|
|
143
121
|
* Maximum number of attempts for magic code entry.
|
|
144
122
|
*/
|
|
@@ -174,9 +152,15 @@ export declare class AzureBotAuthorization implements AuthorizationHandler {
|
|
|
174
152
|
*/
|
|
175
153
|
signin(context: TurnContext, active?: AzureBotActiveHandler): Promise<AuthorizationHandlerStatus>;
|
|
176
154
|
/**
|
|
177
|
-
*
|
|
155
|
+
* Retrieves the base token from the turn state or the user token client.
|
|
156
|
+
* @param context The turn context.
|
|
157
|
+
* @returns The token string or undefined if not available.
|
|
178
158
|
*/
|
|
179
|
-
private
|
|
159
|
+
private getBaseToken;
|
|
160
|
+
/**
|
|
161
|
+
* Acquires an on-behalf-of token for the user based on the provided scopes and connection.
|
|
162
|
+
*/
|
|
163
|
+
private getOBOToken;
|
|
180
164
|
/**
|
|
181
165
|
* Checks if a token is exchangeable for an on-behalf-of flow.
|
|
182
166
|
*/
|
|
@@ -206,10 +190,6 @@ export declare class AzureBotAuthorization implements AuthorizationHandler {
|
|
|
206
190
|
* Gets the user token client from the turn context.
|
|
207
191
|
*/
|
|
208
192
|
private getUserTokenClient;
|
|
209
|
-
/**
|
|
210
|
-
* Sends an InvokeResponse activity if the channel is Microsoft Teams, including Copilot within MS Teams.
|
|
211
|
-
*/
|
|
212
|
-
private sendInvokeResponse;
|
|
213
193
|
/**
|
|
214
194
|
* Prefixes a message with the handler ID.
|
|
215
195
|
*/
|
|
@@ -218,9 +198,5 @@ export declare class AzureBotAuthorization implements AuthorizationHandler {
|
|
|
218
198
|
* Predefined messages with dynamic placeholders.
|
|
219
199
|
*/
|
|
220
200
|
private messages;
|
|
221
|
-
/**
|
|
222
|
-
* Loads the OAuth scopes from the environment variables.
|
|
223
|
-
*/
|
|
224
|
-
private loadScopes;
|
|
225
201
|
}
|
|
226
202
|
export {};
|