@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.
Files changed (144) hide show
  1. package/dist/package.json +10 -6
  2. package/dist/src/activityWireCompat.d.ts +1 -1
  3. package/dist/src/activityWireCompat.js +11 -3
  4. package/dist/src/activityWireCompat.js.map +1 -1
  5. package/dist/src/agent-client/agentClient.js +7 -3
  6. package/dist/src/agent-client/agentClient.js.map +1 -1
  7. package/dist/src/agent-client/agentResponseHandler.js +6 -2
  8. package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
  9. package/dist/src/app/agentApplication.d.ts +28 -13
  10. package/dist/src/app/agentApplication.js +93 -82
  11. package/dist/src/app/agentApplication.js.map +1 -1
  12. package/dist/src/app/agentApplicationBuilder.d.ts +2 -2
  13. package/dist/src/app/agentApplicationBuilder.js.map +1 -1
  14. package/dist/src/app/agentApplicationOptions.d.ts +9 -2
  15. package/dist/src/app/appRoute.d.ts +7 -0
  16. package/dist/src/app/{authorization.d.ts → auth/authorization.d.ts} +33 -139
  17. package/dist/src/app/auth/authorization.js +188 -0
  18. package/dist/src/app/auth/authorization.js.map +1 -0
  19. package/dist/src/app/auth/authorizationManager.d.ts +71 -0
  20. package/dist/src/app/auth/authorizationManager.js +170 -0
  21. package/dist/src/app/auth/authorizationManager.js.map +1 -0
  22. package/dist/src/app/auth/handlerStorage.d.ts +36 -0
  23. package/dist/src/app/auth/handlerStorage.js +62 -0
  24. package/dist/src/app/auth/handlerStorage.js.map +1 -0
  25. package/dist/src/app/auth/handlers/agenticAuthorization.d.ts +93 -0
  26. package/dist/src/app/auth/handlers/agenticAuthorization.js +134 -0
  27. package/dist/src/app/auth/handlers/agenticAuthorization.js.map +1 -0
  28. package/dist/src/app/auth/handlers/azureBotAuthorization.d.ts +222 -0
  29. package/dist/src/app/auth/handlers/azureBotAuthorization.js +428 -0
  30. package/dist/src/app/auth/handlers/azureBotAuthorization.js.map +1 -0
  31. package/dist/src/app/auth/handlers/index.d.ts +2 -0
  32. package/dist/src/app/auth/handlers/index.js +19 -0
  33. package/dist/src/app/auth/handlers/index.js.map +1 -0
  34. package/dist/src/app/auth/index.d.ts +2 -0
  35. package/dist/src/app/auth/index.js +19 -0
  36. package/dist/src/app/auth/index.js.map +1 -0
  37. package/dist/src/app/auth/types.d.ts +104 -0
  38. package/dist/src/app/auth/types.js +24 -0
  39. package/dist/src/app/auth/types.js.map +1 -0
  40. package/dist/src/app/index.d.ts +2 -3
  41. package/dist/src/app/index.js +2 -3
  42. package/dist/src/app/index.js.map +1 -1
  43. package/dist/src/app/routeList.d.ts +1 -1
  44. package/dist/src/app/routeList.js +22 -5
  45. package/dist/src/app/routeList.js.map +1 -1
  46. package/dist/src/app/streaming/streamingResponse.js +2 -1
  47. package/dist/src/app/streaming/streamingResponse.js.map +1 -1
  48. package/dist/src/auth/MemoryCache.d.ts +16 -0
  49. package/dist/src/auth/MemoryCache.js +58 -0
  50. package/dist/src/auth/MemoryCache.js.map +1 -0
  51. package/dist/src/auth/authConfiguration.d.ts +44 -2
  52. package/dist/src/auth/authConfiguration.js +209 -53
  53. package/dist/src/auth/authConfiguration.js.map +1 -1
  54. package/dist/src/auth/authConstants.d.ts +11 -0
  55. package/dist/src/auth/authConstants.js +15 -0
  56. package/dist/src/auth/authConstants.js.map +1 -0
  57. package/dist/src/auth/authProvider.d.ts +23 -0
  58. package/dist/src/auth/connections.d.ts +41 -0
  59. package/dist/src/auth/connections.js +7 -0
  60. package/dist/src/auth/connections.js.map +1 -0
  61. package/dist/src/auth/index.d.ts +2 -0
  62. package/dist/src/auth/index.js +2 -0
  63. package/dist/src/auth/index.js.map +1 -1
  64. package/dist/src/auth/jwt-middleware.js +31 -18
  65. package/dist/src/auth/jwt-middleware.js.map +1 -1
  66. package/dist/src/auth/msalConnectionManager.d.ts +64 -0
  67. package/dist/src/auth/msalConnectionManager.js +148 -0
  68. package/dist/src/auth/msalConnectionManager.js.map +1 -0
  69. package/dist/src/auth/msalTokenProvider.d.ts +31 -0
  70. package/dist/src/auth/msalTokenProvider.js +167 -16
  71. package/dist/src/auth/msalTokenProvider.js.map +1 -1
  72. package/dist/src/baseAdapter.d.ts +10 -25
  73. package/dist/src/baseAdapter.js +2 -15
  74. package/dist/src/baseAdapter.js.map +1 -1
  75. package/dist/src/cloudAdapter.d.ts +40 -23
  76. package/dist/src/cloudAdapter.js +128 -60
  77. package/dist/src/cloudAdapter.js.map +1 -1
  78. package/dist/src/connector-client/connectorClient.d.ts +15 -0
  79. package/dist/src/connector-client/connectorClient.js +49 -15
  80. package/dist/src/connector-client/connectorClient.js.map +1 -1
  81. package/dist/src/index.d.ts +0 -1
  82. package/dist/src/index.js +0 -1
  83. package/dist/src/index.js.map +1 -1
  84. package/dist/src/oauth/customUserTokenAPI.d.ts +1 -0
  85. package/dist/src/oauth/customUserTokenAPI.js +11 -0
  86. package/dist/src/oauth/customUserTokenAPI.js.map +1 -0
  87. package/dist/src/oauth/index.d.ts +0 -1
  88. package/dist/src/oauth/index.js +0 -1
  89. package/dist/src/oauth/index.js.map +1 -1
  90. package/dist/src/oauth/userTokenClient.d.ts +30 -13
  91. package/dist/src/oauth/userTokenClient.js +60 -26
  92. package/dist/src/oauth/userTokenClient.js.map +1 -1
  93. package/dist/src/oauth/userTokenClient.types.d.ts +19 -6
  94. package/dist/src/turnContext.d.ts +7 -1
  95. package/dist/src/turnContext.js +11 -4
  96. package/dist/src/turnContext.js.map +1 -1
  97. package/package.json +10 -6
  98. package/src/activityWireCompat.ts +12 -4
  99. package/src/agent-client/agentClient.ts +9 -3
  100. package/src/agent-client/agentResponseHandler.ts +5 -2
  101. package/src/app/agentApplication.ts +98 -77
  102. package/src/app/agentApplicationBuilder.ts +2 -2
  103. package/src/app/agentApplicationOptions.ts +10 -2
  104. package/src/app/appRoute.ts +8 -0
  105. package/src/app/auth/authorization.ts +252 -0
  106. package/src/app/auth/authorizationManager.ts +213 -0
  107. package/src/app/auth/handlerStorage.ts +61 -0
  108. package/src/app/auth/handlers/agenticAuthorization.ts +182 -0
  109. package/src/app/auth/handlers/azureBotAuthorization.ts +599 -0
  110. package/src/app/auth/handlers/index.ts +2 -0
  111. package/src/app/auth/index.ts +2 -0
  112. package/src/app/auth/types.ts +111 -0
  113. package/src/app/index.ts +2 -3
  114. package/src/app/routeList.ts +24 -5
  115. package/src/app/streaming/streamingResponse.ts +2 -1
  116. package/src/auth/MemoryCache.ts +59 -0
  117. package/src/auth/authConfiguration.ts +245 -52
  118. package/src/auth/authConstants.ts +11 -0
  119. package/src/auth/authProvider.ts +31 -0
  120. package/src/auth/connections.ts +47 -0
  121. package/src/auth/index.ts +2 -0
  122. package/src/auth/jwt-middleware.ts +38 -21
  123. package/src/auth/msalConnectionManager.ts +175 -0
  124. package/src/auth/msalTokenProvider.ts +209 -9
  125. package/src/baseAdapter.ts +10 -29
  126. package/src/cloudAdapter.ts +189 -71
  127. package/src/connector-client/connectorClient.ts +59 -15
  128. package/src/index.ts +0 -1
  129. package/src/oauth/customUserTokenAPI.ts +5 -0
  130. package/src/oauth/index.ts +0 -1
  131. package/src/oauth/userTokenClient.ts +74 -22
  132. package/src/oauth/userTokenClient.types.ts +20 -8
  133. package/src/turnContext.ts +16 -5
  134. package/dist/src/app/authorization.js +0 -387
  135. package/dist/src/app/authorization.js.map +0 -1
  136. package/dist/src/claimsIdentity.d.ts +0 -35
  137. package/dist/src/claimsIdentity.js +0 -43
  138. package/dist/src/claimsIdentity.js.map +0 -1
  139. package/dist/src/oauth/oAuthFlow.d.ts +0 -119
  140. package/dist/src/oauth/oAuthFlow.js +0 -316
  141. package/dist/src/oauth/oAuthFlow.js.map +0 -1
  142. package/src/app/authorization.ts +0 -432
  143. package/src/claimsIdentity.ts +0 -47
  144. package/src/oauth/oAuthFlow.ts +0 -378
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorizationManager.js","sourceRoot":"","sources":["../../../../src/app/auth/authorizationManager.ts"],"names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M,OAAO,CAAC,MAAM,EAAE,CAAA;YACtB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,mBAAmB,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QAC1E,CAAC;IACH,CAAC;IAED;;OAEG;IACK,WAAW,CAAE,GAAa;QAChC,IAAI,eAAe,GAAG,EAAE,CAAA;QACxB,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;gBACxB,eAAe,IAAI,IAAI,EAAE,EAAE,CAAA;YAC7B,CAAC;YACD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC3B,CAAC,CAAC,CAAA;QACF,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,yCAAyC,eAAe,EAAE,CAAC,CAAA;QAC7E,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED;;OAEG;IACK,MAAM,CAAE,EAAU,EAAE,OAAe;QACzC,OAAO,YAAY,EAAE,KAAK,OAAO,EAAE,CAAA;IACrC,CAAC;CACF;AAtKD,oDAsKC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ActiveAuthorizationHandler } from './types';
6
+ import { TurnContext } from '../../turnContext';
7
+ import { Storage } from '../../storage';
8
+ /**
9
+ * Storage manager for handler state.
10
+ */
11
+ export declare class HandlerStorage<TActiveHandler extends ActiveAuthorizationHandler = ActiveAuthorizationHandler> {
12
+ private storage;
13
+ private context;
14
+ /**
15
+ * Creates an instance of the HandlerStorage.
16
+ * @param storage The storage provider.
17
+ * @param context The turn context.
18
+ */
19
+ constructor(storage: Storage, context: TurnContext);
20
+ /**
21
+ * Gets the unique key for a handler session.
22
+ */
23
+ get key(): string;
24
+ /**
25
+ * Reads the active handler state from storage.
26
+ */
27
+ read(): Promise<TActiveHandler | undefined>;
28
+ /**
29
+ * Writes handler state to storage.
30
+ */
31
+ write(data: TActiveHandler): Promise<void>;
32
+ /**
33
+ * Deletes handler state from storage.
34
+ */
35
+ delete(): Promise<void>;
36
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.HandlerStorage = void 0;
8
+ /**
9
+ * Storage manager for handler state.
10
+ */
11
+ class HandlerStorage {
12
+ /**
13
+ * Creates an instance of the HandlerStorage.
14
+ * @param storage The storage provider.
15
+ * @param context The turn context.
16
+ */
17
+ constructor(storage, context) {
18
+ this.storage = storage;
19
+ this.context = context;
20
+ }
21
+ /**
22
+ * Gets the unique key for a handler session.
23
+ */
24
+ get key() {
25
+ var _a, _b, _c;
26
+ const channelId = (_a = this.context.activity.channelId) === null || _a === void 0 ? void 0 : _a.trim();
27
+ const userId = (_c = (_b = this.context.activity.from) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.trim();
28
+ if (!channelId || !userId) {
29
+ throw new Error(`Both 'activity.channelId' and 'activity.from.id' are required to generate the ${HandlerStorage.name} key.`);
30
+ }
31
+ return `auth/${channelId}/${userId}`;
32
+ }
33
+ /**
34
+ * Reads the active handler state from storage.
35
+ */
36
+ async read() {
37
+ const ongoing = await this.storage.read([this.key]);
38
+ return ongoing === null || ongoing === void 0 ? void 0 : ongoing[this.key];
39
+ }
40
+ /**
41
+ * Writes handler state to storage.
42
+ */
43
+ write(data) {
44
+ return this.storage.write({ [this.key]: data });
45
+ }
46
+ /**
47
+ * Deletes handler state from storage.
48
+ */
49
+ async delete() {
50
+ try {
51
+ await this.storage.delete([this.key]);
52
+ }
53
+ catch (error) {
54
+ if (error instanceof Error && 'code' in error && error.code === 404) {
55
+ return;
56
+ }
57
+ throw error;
58
+ }
59
+ }
60
+ }
61
+ exports.HandlerStorage = HandlerStorage;
62
+ //# sourceMappingURL=handlerStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlerStorage.js","sourceRoot":"","sources":["../../../../src/app/auth/handlerStorage.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;GAEG;AACH,MAAa,cAAc;IACzB;;;;OAIG;IACH,YAAqB,OAAgB,EAAU,OAAoB;QAA9C,YAAO,GAAP,OAAO,CAAS;QAAU,YAAO,GAAP,OAAO,CAAa;IAAI,CAAC;IAExE;;OAEG;IACH,IAAW,GAAG;;QACZ,MAAM,SAAS,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,0CAAE,IAAI,EAAE,CAAA;QACzD,MAAM,MAAM,GAAG,MAAA,MAAA,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,0CAAE,EAAE,0CAAE,IAAI,EAAE,CAAA;QACrD,IAAI,CAAC,SAAS,IAAI,CAAC,MAAM,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,iFAAiF,cAAc,CAAC,IAAI,OAAO,CAAC,CAAA;QAC9H,CAAC;QACD,OAAO,QAAQ,SAAS,IAAI,MAAM,EAAE,CAAA;IACtC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI;QACf,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;QACnD,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,IAAI,CAAC,GAAG,CAAC,CAAA;IAC5B,CAAC;IAED;;OAEG;IACI,KAAK,CAAE,IAAoB;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;IACjD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM;QACjB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;QACvC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;gBACpE,OAAM;YACR,CAAC;YACD,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;CACF;AAhDD,wCAgDC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { TurnContext } from '../../../turnContext';
6
+ import { AuthorizationHandler, AuthorizationHandlerSettings, AuthorizationHandlerStatus, AuthorizationHandlerTokenOptions } from '../types';
7
+ import { TokenResponse } from '../../../oauth';
8
+ /**
9
+ * Options for configuring the Agentic authorization handler.
10
+ */
11
+ export interface AgenticAuthorizationOptions {
12
+ /**
13
+ * The type of authorization handler.
14
+ * @remarks
15
+ * When using environment variables, this can be set using the `${authHandlerId}_type` variable.
16
+ */
17
+ type: 'agentic';
18
+ /**
19
+ * 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`).
22
+ */
23
+ scopes?: string[];
24
+ /**
25
+ * (Optional) An alternative connection name to use for the authorization process.
26
+ * @remarks
27
+ * When using environment variables, this can be set using the `${authHandlerId}_altBlueprintConnectionName` variable.
28
+ */
29
+ altBlueprintConnectionName?: string;
30
+ }
31
+ /**
32
+ * Settings for configuring the Agentic authorization handler.
33
+ */
34
+ export interface AgenticAuthorizationSettings extends AuthorizationHandlerSettings {
35
+ }
36
+ /**
37
+ * Authorization handler for Agentic authentication.
38
+ */
39
+ export declare class AgenticAuthorization implements AuthorizationHandler {
40
+ readonly id: string;
41
+ private settings;
42
+ private _options;
43
+ private _onSuccess?;
44
+ private _onFailure?;
45
+ /**
46
+ * Creates an instance of the AgenticAuthorization class.
47
+ * @param id The unique identifier for the authorization handler.
48
+ * @param options The options for configuring the authorization handler.
49
+ * @param settings The settings for the authorization handler.
50
+ */
51
+ constructor(id: string, options: AgenticAuthorizationOptions, settings: AgenticAuthorizationSettings);
52
+ /**
53
+ * Loads and validates the authorization handler options.
54
+ */
55
+ private loadOptions;
56
+ /**
57
+ * @inheritdoc
58
+ */
59
+ signin(): Promise<AuthorizationHandlerStatus>;
60
+ /**
61
+ * @inheritdoc
62
+ */
63
+ signout(): Promise<boolean>;
64
+ /**
65
+ * @inheritdoc
66
+ */
67
+ token(context: TurnContext, options?: AuthorizationHandlerTokenOptions): Promise<TokenResponse>;
68
+ /**
69
+ * @inheritdoc
70
+ */
71
+ onSuccess(callback: (context: TurnContext) => void): void;
72
+ /**
73
+ * @inheritdoc
74
+ */
75
+ onFailure(callback: (context: TurnContext, reason?: string) => void): void;
76
+ /**
77
+ * Prefixes a message with the handler ID.
78
+ */
79
+ private prefix;
80
+ private _key;
81
+ /**
82
+ * Sets the authorization context in the turn state.
83
+ */
84
+ private setContext;
85
+ /**
86
+ * Gets the authorization context from the turn state.
87
+ */
88
+ private getContext;
89
+ /**
90
+ * Loads the OAuth scopes from the environment variables.
91
+ */
92
+ private loadScopes;
93
+ }
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.AgenticAuthorization = void 0;
8
+ const agents_activity_1 = require("@microsoft/agents-activity");
9
+ const types_1 = require("../types");
10
+ const logger = (0, agents_activity_1.debug)('agents:authorization:agentic');
11
+ /**
12
+ * Authorization handler for Agentic authentication.
13
+ */
14
+ class AgenticAuthorization {
15
+ /**
16
+ * Creates an instance of the AgenticAuthorization class.
17
+ * @param id The unique identifier for the authorization handler.
18
+ * @param options The options for configuring the authorization handler.
19
+ * @param settings The settings for the authorization handler.
20
+ */
21
+ constructor(id, options, settings) {
22
+ this.id = id;
23
+ this.settings = settings;
24
+ this._key = `${AgenticAuthorization.name}/${this.id}`;
25
+ if (!this.settings.connections) {
26
+ throw new Error(this.prefix('The \'connections\' option is not available in the app options. Ensure that the app is properly configured.'));
27
+ }
28
+ this._options = this.loadOptions(options);
29
+ }
30
+ /**
31
+ * Loads and validates the authorization handler options.
32
+ */
33
+ loadOptions(settings) {
34
+ var _a, _b;
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;
44
+ }
45
+ /**
46
+ * @inheritdoc
47
+ */
48
+ signin() {
49
+ return Promise.resolve(types_1.AuthorizationHandlerStatus.IGNORED);
50
+ }
51
+ /**
52
+ * @inheritdoc
53
+ */
54
+ signout() {
55
+ return Promise.resolve(false);
56
+ }
57
+ /**
58
+ * @inheritdoc
59
+ */
60
+ async token(context, options) {
61
+ var _a, _b, _c, _d, _e, _f;
62
+ try {
63
+ const tokenResponse = this.getContext(context);
64
+ if (tokenResponse.token) {
65
+ logger.debug(this.prefix('Using cached Agentic user token'));
66
+ return tokenResponse;
67
+ }
68
+ let connection;
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.getAgenticInstanceId()) !== null && _c !== void 0 ? _c : '', (_d = context.activity.getAgenticUser()) !== null && _d !== void 0 ? _d : '', (options === null || options === void 0 ? void 0 : options.scopes) || this._options.scopes);
76
+ this.setContext(context, { token });
77
+ (_e = this._onSuccess) === null || _e === void 0 ? void 0 : _e.call(this, context);
78
+ return { token };
79
+ }
80
+ catch (error) {
81
+ const reason = 'Error retrieving Agentic user token';
82
+ logger.error(this.prefix(reason), error);
83
+ (_f = this._onFailure) === null || _f === void 0 ? void 0 : _f.call(this, context, `${reason}: ${error.message}`);
84
+ return { token: undefined };
85
+ }
86
+ }
87
+ /**
88
+ * @inheritdoc
89
+ */
90
+ onSuccess(callback) {
91
+ this._onSuccess = callback;
92
+ }
93
+ /**
94
+ * @inheritdoc
95
+ */
96
+ onFailure(callback) {
97
+ this._onFailure = callback;
98
+ }
99
+ /**
100
+ * Prefixes a message with the handler ID.
101
+ */
102
+ prefix(message) {
103
+ return `[handler:${this.id}] ${message}`;
104
+ }
105
+ /**
106
+ * Sets the authorization context in the turn state.
107
+ */
108
+ setContext(context, data) {
109
+ return context.turnState.set(this._key, () => data);
110
+ }
111
+ /**
112
+ * Gets the authorization context from the turn state.
113
+ */
114
+ getContext(context) {
115
+ var _a;
116
+ const result = context.turnState.get(this._key);
117
+ return (_a = result === null || result === void 0 ? void 0 : result()) !== null && _a !== void 0 ? _a : { token: undefined };
118
+ }
119
+ /**
120
+ * Loads the OAuth scopes from the environment variables.
121
+ */
122
+ loadScopes(value) {
123
+ var _a;
124
+ return (_a = value === null || value === void 0 ? void 0 : value.split(',').reduce((acc, scope) => {
125
+ const trimmed = scope.trim();
126
+ if (trimmed) {
127
+ acc.push(trimmed);
128
+ }
129
+ return acc;
130
+ }, [])) !== null && _a !== void 0 ? _a : [];
131
+ }
132
+ }
133
+ exports.AgenticAuthorization = AgenticAuthorization;
134
+ //# sourceMappingURL=agenticAuthorization.js.map
@@ -0,0 +1 @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AA;IAC3C,CAAC;IAED;;OAEG;IACK,UAAU,CAAE,KAAwB;;QAC1C,OAAO,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC,GAAG,EAAE,MAAM,CAAW,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACvD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;YAC5B,IAAI,OAAO,EAAE,CAAC;gBACZ,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACnB,CAAC;YACD,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAAE,CAAC,mCAAI,EAAE,CAAA;IACd,CAAC;CACF;AAxID,oDAwIC"}
@@ -0,0 +1,222 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { AuthorizationHandlerStatus, AuthorizationHandler, ActiveAuthorizationHandler, AuthorizationHandlerSettings, AuthorizationHandlerTokenOptions } from '../types';
6
+ import { TurnContext } from '../../../turnContext';
7
+ import { TokenResponse } from '../../../oauth';
8
+ declare enum Category {
9
+ SIGNIN = "signin",
10
+ UNKNOWN = "unknown"
11
+ }
12
+ /**
13
+ * Active handler manager information.
14
+ */
15
+ export interface AzureBotActiveHandler extends ActiveAuthorizationHandler {
16
+ /**
17
+ * The number of attempts left for the handler to process in case of failure.
18
+ */
19
+ attemptsLeft: number;
20
+ /**
21
+ * The current category of the handler.
22
+ */
23
+ category?: Category;
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
+ /**
62
+ * Interface defining an authorization handler configuration.
63
+ */
64
+ export interface AzureBotAuthorizationOptions {
65
+ /**
66
+ * The type of authorization handler.
67
+ * This property is optional and should not be set when configuring this handler.
68
+ * It is included here for completeness and type safety.
69
+ */
70
+ type?: undefined;
71
+ /**
72
+ * Connection name for the auth provider.
73
+ * @remarks
74
+ * When using environment variables, this can be set using the `${authHandlerId}_connectionName` variable.
75
+ */
76
+ name?: string;
77
+ /**
78
+ * Title to display on auth cards/UI.
79
+ * @remarks
80
+ * When using environment variables, this can be set using the `${authHandlerId}_connectionTitle` variable.
81
+ */
82
+ title?: string;
83
+ /**
84
+ * Text to display on auth cards/UI.
85
+ * @remarks
86
+ * When using environment variables, this can be set using the `${authHandlerId}_connectionText` variable.
87
+ */
88
+ text?: string;
89
+ /**
90
+ * 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
+ */
94
+ maxAttempts?: number;
95
+ /**
96
+ * Messages to display for various authentication scenarios.
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`
102
+ */
103
+ messages?: AzureBotAuthorizationOptionsMessages;
104
+ /**
105
+ * Settings for on-behalf-of token acquisition.
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`)
110
+ */
111
+ obo?: AzureBotAuthorizationOptionsOBO;
112
+ }
113
+ /**
114
+ * Settings for configuring the AzureBot authorization handler.
115
+ */
116
+ export interface AzureBotAuthorizationSettings extends AuthorizationHandlerSettings {
117
+ }
118
+ /**
119
+ * Default implementation of an authorization handler using Azure Bot Service.
120
+ */
121
+ export declare class AzureBotAuthorization implements AuthorizationHandler {
122
+ readonly id: string;
123
+ private settings;
124
+ private _options;
125
+ private _onSuccess?;
126
+ private _onFailure?;
127
+ /**
128
+ * Creates an instance of the AzureBotAuthorization.
129
+ * @param id The unique identifier for the handler.
130
+ * @param options The settings for the handler.
131
+ * @param app The agent application instance.
132
+ */
133
+ constructor(id: string, options: AzureBotAuthorizationOptions, settings: AzureBotAuthorizationSettings);
134
+ /**
135
+ * Loads and validates the authorization handler options.
136
+ */
137
+ private loadOptions;
138
+ /**
139
+ * Maximum number of attempts for magic code entry.
140
+ */
141
+ private get maxAttempts();
142
+ /**
143
+ * Sets a handler to be called when a user successfully signs in.
144
+ * @param callback The callback function to be invoked on successful sign-in.
145
+ */
146
+ onSuccess(callback: (context: TurnContext) => Promise<void> | void): void;
147
+ /**
148
+ * Sets a handler to be called when a user fails to sign in.
149
+ * @param callback The callback function to be invoked on sign-in failure.
150
+ */
151
+ onFailure(callback: (context: TurnContext, reason?: string) => Promise<void> | void): void;
152
+ /**
153
+ * Retrieves the token for the user, optionally using on-behalf-of flow for specified scopes.
154
+ * @param context The turn context.
155
+ * @param options Optional options for token acquisition, including connection and scopes for on-behalf-of flow.
156
+ * @returns The token response containing the token or undefined if not available.
157
+ */
158
+ token(context: TurnContext, options?: AuthorizationHandlerTokenOptions): Promise<TokenResponse>;
159
+ /**
160
+ * Signs out the user from the service.
161
+ * @param context The turn context.
162
+ * @returns True if the signout was successful, false otherwise.
163
+ */
164
+ signout(context: TurnContext): Promise<boolean>;
165
+ /**
166
+ * Initiates the sign-in process for the handler.
167
+ * @param context The turn context.
168
+ * @param active Optional active handler data.
169
+ * @returns The status of the sign-in attempt.
170
+ */
171
+ signin(context: TurnContext, active?: AzureBotActiveHandler): Promise<AuthorizationHandlerStatus>;
172
+ /**
173
+ * Handles on-behalf-of token acquisition.
174
+ */
175
+ private handleOBO;
176
+ /**
177
+ * Checks if a token is exchangeable for an on-behalf-of flow.
178
+ */
179
+ private isExchangeable;
180
+ /**
181
+ * Sets the token from the token response or initiates the sign-in flow.
182
+ */
183
+ private setToken;
184
+ /**
185
+ * Handles sign-in related activities.
186
+ */
187
+ private handleSignInActivities;
188
+ /**
189
+ * Verifies the magic code provided by the user.
190
+ */
191
+ private codeVerification;
192
+ private _key;
193
+ /**
194
+ * Sets the authorization context in the turn state.
195
+ */
196
+ private setContext;
197
+ /**
198
+ * Gets the authorization context from the turn state.
199
+ */
200
+ private getContext;
201
+ /**
202
+ * Gets the user token client from the turn context.
203
+ */
204
+ private getUserTokenClient;
205
+ /**
206
+ * Sends an InvokeResponse activity if the channel is Microsoft Teams.
207
+ */
208
+ private sendInvokeResponse;
209
+ /**
210
+ * Prefixes a message with the handler ID.
211
+ */
212
+ private prefix;
213
+ /**
214
+ * Predefined messages with dynamic placeholders.
215
+ */
216
+ private messages;
217
+ /**
218
+ * Loads the OAuth scopes from the environment variables.
219
+ */
220
+ private loadScopes;
221
+ }
222
+ export {};