@microsoft/agents-hosting 0.2.14 → 0.3.5

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 (76) hide show
  1. package/README.md +17 -1
  2. package/dist/src/app/agentApplication.d.ts +16 -4
  3. package/dist/src/app/agentApplication.js +22 -12
  4. package/dist/src/app/agentApplication.js.map +1 -1
  5. package/dist/src/app/agentApplicationBuilder.d.ts +3 -4
  6. package/dist/src/app/agentApplicationBuilder.js +7 -7
  7. package/dist/src/app/agentApplicationBuilder.js.map +1 -1
  8. package/dist/src/app/agentApplicationOptions.d.ts +26 -2
  9. package/dist/src/app/appRoute.d.ts +6 -0
  10. package/dist/src/app/attachmentDownloader.d.ts +18 -0
  11. package/dist/src/app/attachmentDownloader.js +18 -0
  12. package/dist/src/app/attachmentDownloader.js.map +1 -1
  13. package/dist/src/app/conversationUpdateEvents.d.ts +6 -0
  14. package/dist/src/app/index.d.ts +1 -1
  15. package/dist/src/app/index.js +1 -1
  16. package/dist/src/app/index.js.map +1 -1
  17. package/dist/src/app/inputFileDownloader.d.ts +22 -0
  18. package/dist/src/app/oauth/authorization.d.ts +87 -0
  19. package/dist/src/app/oauth/authorization.js +135 -0
  20. package/dist/src/app/oauth/authorization.js.map +1 -0
  21. package/dist/src/app/routeHandler.d.ts +8 -0
  22. package/dist/src/app/routeSelector.d.ts +9 -0
  23. package/dist/src/app/turnState.d.ts +150 -0
  24. package/dist/src/app/turnState.js +125 -0
  25. package/dist/src/app/turnState.js.map +1 -1
  26. package/dist/src/auth/authConfiguration.d.ts +24 -0
  27. package/dist/src/auth/authConfiguration.js.map +1 -1
  28. package/dist/src/auth/request.d.ts +12 -0
  29. package/dist/src/baseAdapter.d.ts +17 -0
  30. package/dist/src/baseAdapter.js +17 -0
  31. package/dist/src/baseAdapter.js.map +1 -1
  32. package/dist/src/cards/cardFactory.d.ts +3 -0
  33. package/dist/src/cards/cardFactory.js +3 -0
  34. package/dist/src/cards/cardFactory.js.map +1 -1
  35. package/dist/src/cards/o365ConnectorCardActionBase.d.ts +8 -0
  36. package/dist/src/oauth/oAuthFlow.d.ts +32 -3
  37. package/dist/src/oauth/oAuthFlow.js +38 -14
  38. package/dist/src/oauth/oAuthFlow.js.map +1 -1
  39. package/dist/src/oauth/userTokenClient.d.ts +2 -2
  40. package/dist/src/oauth/userTokenClient.js +3 -3
  41. package/dist/src/oauth/userTokenClient.js.map +1 -1
  42. package/dist/src/state/agentStatePropertyAccesor.d.ts +1 -1
  43. package/dist/src/state/agentStatePropertyAccesor.js +1 -1
  44. package/dist/src/statusCodes.d.ts +39 -0
  45. package/dist/src/statusCodes.js +39 -0
  46. package/dist/src/statusCodes.js.map +1 -1
  47. package/dist/src/tokenResponseEventName.d.ts +3 -0
  48. package/dist/src/tokenResponseEventName.js +3 -0
  49. package/dist/src/tokenResponseEventName.js.map +1 -1
  50. package/package.json +4 -4
  51. package/src/app/agentApplication.ts +24 -13
  52. package/src/app/agentApplicationBuilder.ts +8 -8
  53. package/src/app/agentApplicationOptions.ts +33 -2
  54. package/src/app/appRoute.ts +7 -0
  55. package/src/app/attachmentDownloader.ts +18 -0
  56. package/src/app/conversationUpdateEvents.ts +6 -0
  57. package/src/app/index.ts +1 -1
  58. package/src/app/inputFileDownloader.ts +24 -0
  59. package/src/app/oauth/authorization.ts +162 -0
  60. package/src/app/routeHandler.ts +8 -0
  61. package/src/app/routeSelector.ts +9 -0
  62. package/src/app/turnState.ts +151 -1
  63. package/src/auth/authConfiguration.ts +32 -1
  64. package/src/auth/request.ts +15 -0
  65. package/src/baseAdapter.ts +18 -0
  66. package/src/cards/cardFactory.ts +3 -0
  67. package/src/cards/o365ConnectorCardActionBase.ts +8 -0
  68. package/src/oauth/oAuthFlow.ts +59 -18
  69. package/src/oauth/userTokenClient.ts +4 -4
  70. package/src/state/agentStatePropertyAccesor.ts +1 -1
  71. package/src/statusCodes.ts +51 -0
  72. package/src/tokenResponseEventName.ts +3 -0
  73. package/dist/src/app/oauth/userIdentity.d.ts +0 -43
  74. package/dist/src/app/oauth/userIdentity.js +0 -54
  75. package/dist/src/app/oauth/userIdentity.js.map +0 -1
  76. package/src/app/oauth/userIdentity.ts +0 -78
@@ -3,4 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ /**
7
+ * The event name used for token response activities.
8
+ */
6
9
  export const tokenResponseEventName = 'tokens/response'
@@ -1,43 +0,0 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { TurnContext } from '../../turnContext';
6
- import { TurnState } from '../turnState';
7
- import { Storage } from '../../storage';
8
- import { OAuthFlow, TokenResponse } from '../../oauth';
9
- /**
10
- * Options for configuring user identity.
11
- * Contains settings related to Single Sign-On (SSO) authentication.
12
- */
13
- export interface UserIdentityOptions {
14
- /**
15
- * Determines whether Single Sign-On (SSO) is enabled for user authentication.
16
- */
17
- enableSSO: boolean;
18
- /**
19
- * The name of the SSO connection to use when SSO is enabled.
20
- * Only applicable when enableSSO is set to true.
21
- */
22
- ssoConnectionName?: string;
23
- }
24
- export declare class UserIdentity {
25
- oAuthFlow: OAuthFlow;
26
- /**
27
- * Creates a new instance of UserAuthorization.
28
- * @param {Storage} storage - The storage system to use for state management.
29
- */
30
- constructor(storage: Storage, connectionName: string);
31
- getToken(context: TurnContext): Promise<TokenResponse>;
32
- authenticate(context: TurnContext, state: TurnState): Promise<TokenResponse>;
33
- /**
34
- * Signs out the current user.
35
- * This method clears the user's token and resets the SSO state.
36
- *
37
- * @param {TurnContext} context - The context object for the current turn.
38
- * @param {TurnState} state - The state object for the current turn.
39
- */
40
- signOut(context: TurnContext, state: TurnState): Promise<void>;
41
- _signInHandler: ((context: TurnContext, state: TurnState) => void) | null;
42
- onSignInSuccess(handler: (context: TurnContext, state: TurnState) => void): void;
43
- }
@@ -1,54 +0,0 @@
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.UserIdentity = void 0;
8
- const oauth_1 = require("../../oauth");
9
- const state_1 = require("../../state");
10
- class UserIdentity {
11
- /**
12
- * Creates a new instance of UserAuthorization.
13
- * @param {Storage} storage - The storage system to use for state management.
14
- */
15
- constructor(storage, connectionName) {
16
- this._signInHandler = null;
17
- const userState = new state_1.UserState(storage);
18
- this.oAuthFlow = new oauth_1.OAuthFlow(userState, connectionName);
19
- }
20
- async getToken(context) {
21
- return await this.oAuthFlow.getUserToken(context);
22
- }
23
- async authenticate(context, state) {
24
- var _a;
25
- let tokenResponse;
26
- if (((_a = this.oAuthFlow.state) === null || _a === void 0 ? void 0 : _a.flowStarted) === false) {
27
- tokenResponse = await this.oAuthFlow.beginFlow(context);
28
- }
29
- else {
30
- tokenResponse = await this.oAuthFlow.continueFlow(context);
31
- if (tokenResponse.status === oauth_1.TokenRequestStatus.Success) {
32
- if (this._signInHandler) {
33
- await this._signInHandler(context, state);
34
- }
35
- }
36
- }
37
- return tokenResponse;
38
- }
39
- /**
40
- * Signs out the current user.
41
- * This method clears the user's token and resets the SSO state.
42
- *
43
- * @param {TurnContext} context - The context object for the current turn.
44
- * @param {TurnState} state - The state object for the current turn.
45
- */
46
- async signOut(context, state) {
47
- await this.oAuthFlow.signOut(context);
48
- }
49
- onSignInSuccess(handler) {
50
- this._signInHandler = handler;
51
- }
52
- }
53
- exports.UserIdentity = UserIdentity;
54
- //# sourceMappingURL=userIdentity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"userIdentity.js","sourceRoot":"","sources":["../../../../src/app/oauth/userIdentity.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,uCAA0E;AAC1E,uCAAuC;AAqBvC,MAAa,YAAY;IAGvB;;;OAGG;IACH,YAAa,OAAgB,EAAE,cAAsB;QAmCrD,mBAAc,GAA8D,IAAI,CAAA;QAlC9E,MAAM,SAAS,GAAG,IAAI,iBAAS,CAAC,OAAO,CAAC,CAAA;QACxC,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAS,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IAC3D,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAE,OAAoB;QACzC,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;IACnD,CAAC;IAEM,KAAK,CAAC,YAAY,CAAE,OAAoB,EAAE,KAAgB;;QAC/D,IAAI,aAA4B,CAAA;QAChC,IAAI,CAAA,MAAA,IAAI,CAAC,SAAS,CAAC,KAAK,0CAAE,WAAW,MAAK,KAAK,EAAE,CAAC;YAChD,aAAa,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QACzD,CAAC;aAAM,CAAC;YACN,aAAa,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;YAC1D,IAAI,aAAa,CAAC,MAAM,KAAK,0BAAkB,CAAC,OAAO,EAAE,CAAC;gBACxD,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;oBACxB,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;gBAC3C,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,aAAa,CAAA;IACtB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CAAE,OAAoB,EAAE,KAAgB;QACnD,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACvC,CAAC;IAGM,eAAe,CAAE,OAAyD;QAC/E,IAAI,CAAC,cAAc,GAAG,OAAO,CAAA;IAC/B,CAAC;CACF;AA9CD,oCA8CC"}
@@ -1,78 +0,0 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- import { TurnContext } from '../../turnContext'
7
- // import { debug } from '../../logger'
8
- import { TurnState } from '../turnState'
9
- import { Storage } from '../../storage'
10
- import { OAuthFlow, TokenRequestStatus, TokenResponse } from '../../oauth'
11
- import { UserState } from '../../state'
12
-
13
- // const logger = debug('agents:user-identity')
14
-
15
- /**
16
- * Options for configuring user identity.
17
- * Contains settings related to Single Sign-On (SSO) authentication.
18
- */
19
- export interface UserIdentityOptions {
20
- /**
21
- * Determines whether Single Sign-On (SSO) is enabled for user authentication.
22
- */
23
- enableSSO: boolean;
24
-
25
- /**
26
- * The name of the SSO connection to use when SSO is enabled.
27
- * Only applicable when enableSSO is set to true.
28
- */
29
- ssoConnectionName?: string;
30
- }
31
-
32
- export class UserIdentity {
33
- oAuthFlow: OAuthFlow
34
-
35
- /**
36
- * Creates a new instance of UserAuthorization.
37
- * @param {Storage} storage - The storage system to use for state management.
38
- */
39
- constructor (storage: Storage, connectionName: string) {
40
- const userState = new UserState(storage)
41
- this.oAuthFlow = new OAuthFlow(userState, connectionName)
42
- }
43
-
44
- public async getToken (context: TurnContext): Promise<TokenResponse> {
45
- return await this.oAuthFlow.getUserToken(context)
46
- }
47
-
48
- public async authenticate (context: TurnContext, state: TurnState) : Promise<TokenResponse> {
49
- let tokenResponse: TokenResponse
50
- if (this.oAuthFlow.state?.flowStarted === false) {
51
- tokenResponse = await this.oAuthFlow.beginFlow(context)
52
- } else {
53
- tokenResponse = await this.oAuthFlow.continueFlow(context)
54
- if (tokenResponse.status === TokenRequestStatus.Success) {
55
- if (this._signInHandler) {
56
- await this._signInHandler(context, state)
57
- }
58
- }
59
- }
60
- return tokenResponse
61
- }
62
-
63
- /**
64
- * Signs out the current user.
65
- * This method clears the user's token and resets the SSO state.
66
- *
67
- * @param {TurnContext} context - The context object for the current turn.
68
- * @param {TurnState} state - The state object for the current turn.
69
- */
70
- async signOut (context: TurnContext, state: TurnState) {
71
- await this.oAuthFlow.signOut(context)
72
- }
73
-
74
- _signInHandler: ((context: TurnContext, state: TurnState) => void) | null = null
75
- public onSignInSuccess (handler: (context: TurnContext, state: TurnState) => void) {
76
- this._signInHandler = handler
77
- }
78
- }