@microsoft/agents-hosting 1.1.0-alpha.9.g154c2c8a32 → 1.1.4-g8d884129e7

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 (152) 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 +26 -11
  10. package/dist/src/app/agentApplication.js +90 -79
  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} +41 -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 +226 -0
  29. package/dist/src/app/auth/handlers/azureBotAuthorization.js +429 -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 +3 -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 +26 -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 +38 -0
  70. package/dist/src/auth/msalTokenProvider.js +189 -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/cards/cardFactory.d.ts +2 -1
  76. package/dist/src/cards/cardFactory.js +3 -2
  77. package/dist/src/cards/cardFactory.js.map +1 -1
  78. package/dist/src/cloudAdapter.d.ts +40 -23
  79. package/dist/src/cloudAdapter.js +143 -63
  80. package/dist/src/cloudAdapter.js.map +1 -1
  81. package/dist/src/connector-client/connectorClient.d.ts +15 -0
  82. package/dist/src/connector-client/connectorClient.js +49 -15
  83. package/dist/src/connector-client/connectorClient.js.map +1 -1
  84. package/dist/src/index.d.ts +0 -1
  85. package/dist/src/index.js +0 -1
  86. package/dist/src/index.js.map +1 -1
  87. package/dist/src/oauth/customUserTokenAPI.d.ts +1 -0
  88. package/dist/src/oauth/customUserTokenAPI.js +11 -0
  89. package/dist/src/oauth/customUserTokenAPI.js.map +1 -0
  90. package/dist/src/oauth/index.d.ts +0 -1
  91. package/dist/src/oauth/index.js +0 -1
  92. package/dist/src/oauth/index.js.map +1 -1
  93. package/dist/src/oauth/userTokenClient.d.ts +30 -13
  94. package/dist/src/oauth/userTokenClient.js +62 -26
  95. package/dist/src/oauth/userTokenClient.js.map +1 -1
  96. package/dist/src/oauth/userTokenClient.types.d.ts +19 -6
  97. package/dist/src/transcript/fileTranscriptLogger.d.ts +109 -0
  98. package/dist/src/transcript/fileTranscriptLogger.js +398 -0
  99. package/dist/src/transcript/fileTranscriptLogger.js.map +1 -0
  100. package/dist/src/turnContext.d.ts +7 -1
  101. package/dist/src/turnContext.js +11 -4
  102. package/dist/src/turnContext.js.map +1 -1
  103. package/package.json +10 -6
  104. package/src/activityWireCompat.ts +12 -4
  105. package/src/agent-client/agentClient.ts +9 -3
  106. package/src/agent-client/agentResponseHandler.ts +5 -2
  107. package/src/app/agentApplication.ts +95 -74
  108. package/src/app/agentApplicationBuilder.ts +2 -2
  109. package/src/app/agentApplicationOptions.ts +10 -2
  110. package/src/app/appRoute.ts +8 -0
  111. package/src/app/auth/authorization.ts +261 -0
  112. package/src/app/auth/authorizationManager.ts +213 -0
  113. package/src/app/auth/handlerStorage.ts +61 -0
  114. package/src/app/auth/handlers/agenticAuthorization.ts +183 -0
  115. package/src/app/auth/handlers/azureBotAuthorization.ts +606 -0
  116. package/src/app/auth/handlers/index.ts +2 -0
  117. package/src/app/auth/index.ts +2 -0
  118. package/src/app/auth/types.ts +111 -0
  119. package/src/app/index.ts +3 -3
  120. package/src/app/routeList.ts +24 -5
  121. package/src/app/streaming/streamingResponse.ts +2 -1
  122. package/src/auth/MemoryCache.ts +59 -0
  123. package/src/auth/authConfiguration.ts +245 -52
  124. package/src/auth/authConstants.ts +11 -0
  125. package/src/auth/authProvider.ts +34 -0
  126. package/src/auth/connections.ts +47 -0
  127. package/src/auth/index.ts +2 -0
  128. package/src/auth/jwt-middleware.ts +38 -21
  129. package/src/auth/msalConnectionManager.ts +175 -0
  130. package/src/auth/msalTokenProvider.ts +231 -9
  131. package/src/baseAdapter.ts +10 -29
  132. package/src/cards/cardFactory.ts +3 -2
  133. package/src/cloudAdapter.ts +207 -72
  134. package/src/connector-client/connectorClient.ts +59 -15
  135. package/src/index.ts +0 -1
  136. package/src/oauth/customUserTokenAPI.ts +5 -0
  137. package/src/oauth/index.ts +0 -1
  138. package/src/oauth/userTokenClient.ts +76 -22
  139. package/src/oauth/userTokenClient.types.ts +20 -8
  140. package/src/transcript/fileTranscriptLogger.ts +409 -0
  141. package/src/turnContext.ts +16 -5
  142. package/dist/src/app/authorization.js +0 -387
  143. package/dist/src/app/authorization.js.map +0 -1
  144. package/dist/src/claimsIdentity.d.ts +0 -35
  145. package/dist/src/claimsIdentity.js +0 -43
  146. package/dist/src/claimsIdentity.js.map +0 -1
  147. package/dist/src/oauth/oAuthFlow.d.ts +0 -119
  148. package/dist/src/oauth/oAuthFlow.js +0 -316
  149. package/dist/src/oauth/oAuthFlow.js.map +0 -1
  150. package/src/app/authorization.ts +0 -432
  151. package/src/claimsIdentity.ts +0 -47
  152. package/src/oauth/oAuthFlow.ts +0 -378
@@ -1,119 +0,0 @@
1
- import { Activity } from '@microsoft/agents-activity';
2
- import { TurnContext, Storage } from '../';
3
- import { UserTokenClient } from './userTokenClient';
4
- import { TokenResponse } from './userTokenClient.types';
5
- /**
6
- * Represents the state of the OAuth flow.
7
- * @interface FlowState
8
- */
9
- export interface FlowState {
10
- /** Indicates whether the OAuth flow has been started */
11
- flowStarted: boolean | undefined;
12
- /** Timestamp when the OAuth flow expires (in milliseconds since epoch) */
13
- flowExpires: number | undefined;
14
- /** The absolute OAuth connection name used for the flow, null if not set */
15
- absOauthConnectionName: string;
16
- /** Optional activity to continue the flow with, used for multi-turn scenarios */
17
- continuationActivity?: Activity | null;
18
- eTag?: string;
19
- }
20
- /**
21
- * Manages the OAuth flow
22
- */
23
- export declare class OAuthFlow {
24
- private storage;
25
- /**
26
- * The user token client used for managing user tokens.
27
- */
28
- userTokenClient: UserTokenClient;
29
- /**
30
- * The current state of the OAuth flow.
31
- */
32
- state: FlowState;
33
- /**
34
- * The ID of the token exchange request, used to deduplicate requests.
35
- */
36
- tokenExchangeId: string | null;
37
- /**
38
- * In-memory cache for tokens with expiration.
39
- */
40
- private tokenCache;
41
- /**
42
- * The name of the OAuth connection.
43
- */
44
- absOauthConnectionName: string;
45
- /**
46
- * The title of the OAuth card.
47
- */
48
- cardTitle: string;
49
- /**
50
- * The text of the OAuth card.
51
- */
52
- cardText: string;
53
- /**
54
- * Creates a new instance of OAuthFlow.
55
- * @param storage The storage provider for persisting flow state.
56
- * @param absOauthConnectionName The absolute OAuth connection name.
57
- * @param tokenClient Optional user token client. If not provided, will be initialized automatically.
58
- * @param cardTitle Optional title for the OAuth card. Defaults to 'Sign in'.
59
- * @param cardText Optional text for the OAuth card. Defaults to 'login'.
60
- */
61
- constructor(storage: Storage, absOauthConnectionName: string, tokenClient: UserTokenClient, cardTitle?: string, cardText?: string);
62
- /**
63
- * Retrieves the user token from the user token service with in-memory caching for 10 minutes.
64
- * @param context The turn context containing the activity information.
65
- * @returns A promise that resolves to the user token response.
66
- * @throws Will throw an error if the channelId or from properties are not set in the activity.
67
- */
68
- getUserToken(context: TurnContext): Promise<TokenResponse>;
69
- /**
70
- * Begins the OAuth flow.
71
- * @param context The turn context.
72
- * @returns A promise that resolves to the user token if available, or undefined if OAuth flow needs to be started.
73
- */
74
- beginFlow(context: TurnContext): Promise<TokenResponse | undefined>;
75
- /**
76
- * Continues the OAuth flow.
77
- * @param context The turn context.
78
- * @returns A promise that resolves to the user token response.
79
- */
80
- continueFlow(context: TurnContext): Promise<TokenResponse>;
81
- /**
82
- * Signs the user out.
83
- * @param context The turn context.
84
- * @returns A promise that resolves when the sign-out operation is complete.
85
- */
86
- signOut(context: TurnContext): Promise<void>;
87
- /**
88
- * Gets the user state for the OAuth flow.
89
- * @param context The turn context.
90
- * @returns A promise that resolves to the flow state.
91
- */
92
- getFlowState(context: TurnContext): Promise<FlowState>;
93
- /**
94
- * Sets the flow state for the OAuth flow.
95
- * @param context The turn context.
96
- * @param flowState The flow state to set.
97
- * @returns A promise that resolves when the flow state is set.
98
- */
99
- setFlowState(context: TurnContext, flowState: FlowState): Promise<void>;
100
- /**
101
- * Initializes the user token client if not already initialized.
102
- * @param context The turn context used to get authentication credentials.
103
- */
104
- private refreshToken;
105
- /**
106
- * Generates a cache key for storing user tokens.
107
- * @param context The turn context containing activity information.
108
- * @returns The cache key string in format: channelId_userId_connectionName.
109
- * @throws Will throw an error if required activity properties are missing.
110
- */
111
- private getCacheKey;
112
- /**
113
- * Generates a storage key for persisting OAuth flow state.
114
- * @param context The turn context containing activity information.
115
- * @returns The storage key string in format: oauth/channelId/conversationId/userId/flowState.
116
- * @throws Will throw an error if required activity properties are missing.
117
- */
118
- private getFlowStateKey;
119
- }
@@ -1,316 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.OAuthFlow = void 0;
7
- // Copyright (c) Microsoft Corporation. All rights reserved.
8
- // Licensed under the MIT License.
9
- const logger_1 = require("@microsoft/agents-activity/logger");
10
- const agents_activity_1 = require("@microsoft/agents-activity");
11
- const __1 = require("../");
12
- const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
13
- const logger = (0, logger_1.debug)('agents:oauth-flow');
14
- /**
15
- * Manages the OAuth flow
16
- */
17
- class OAuthFlow {
18
- /**
19
- * Creates a new instance of OAuthFlow.
20
- * @param storage The storage provider for persisting flow state.
21
- * @param absOauthConnectionName The absolute OAuth connection name.
22
- * @param tokenClient Optional user token client. If not provided, will be initialized automatically.
23
- * @param cardTitle Optional title for the OAuth card. Defaults to 'Sign in'.
24
- * @param cardText Optional text for the OAuth card. Defaults to 'login'.
25
- */
26
- constructor(storage, absOauthConnectionName, tokenClient, cardTitle, cardText) {
27
- this.storage = storage;
28
- /**
29
- * The ID of the token exchange request, used to deduplicate requests.
30
- */
31
- this.tokenExchangeId = null;
32
- /**
33
- * In-memory cache for tokens with expiration.
34
- */
35
- this.tokenCache = new Map();
36
- /**
37
- * The title of the OAuth card.
38
- */
39
- this.cardTitle = 'Sign in';
40
- /**
41
- * The text of the OAuth card.
42
- */
43
- this.cardText = 'login';
44
- this.state = { flowStarted: undefined, flowExpires: undefined, absOauthConnectionName };
45
- this.absOauthConnectionName = absOauthConnectionName;
46
- this.userTokenClient = tokenClient;
47
- this.cardTitle = cardTitle !== null && cardTitle !== void 0 ? cardTitle : this.cardTitle;
48
- this.cardText = cardText !== null && cardText !== void 0 ? cardText : this.cardText;
49
- }
50
- /**
51
- * Retrieves the user token from the user token service with in-memory caching for 10 minutes.
52
- * @param context The turn context containing the activity information.
53
- * @returns A promise that resolves to the user token response.
54
- * @throws Will throw an error if the channelId or from properties are not set in the activity.
55
- */
56
- async getUserToken(context) {
57
- const activity = context.activity;
58
- if (!activity.channelId || !activity.from || !activity.from.id) {
59
- throw new Error('UserTokenService requires channelId and from to be set');
60
- }
61
- const cacheKey = this.getCacheKey(context);
62
- const cachedEntry = this.tokenCache.get(cacheKey);
63
- if (cachedEntry && Date.now() < cachedEntry.expiresAt) {
64
- logger.info(`Returning cached token for user with cache key: ${cacheKey}`);
65
- return cachedEntry.token;
66
- }
67
- logger.info('Get token from user token service');
68
- await this.refreshToken(context);
69
- const tokenResponse = await this.userTokenClient.getUserToken(this.absOauthConnectionName, activity.channelId, activity.from.id);
70
- // Cache the token if it's valid (has a token value)
71
- if (tokenResponse && tokenResponse.token) {
72
- const cacheExpiry = Date.now() + (10 * 60 * 1000); // 10 minutes from now
73
- this.tokenCache.set(cacheKey, {
74
- token: tokenResponse,
75
- expiresAt: cacheExpiry
76
- });
77
- logger.info('Token cached for 10 minutes');
78
- }
79
- return tokenResponse;
80
- }
81
- /**
82
- * Begins the OAuth flow.
83
- * @param context The turn context.
84
- * @returns A promise that resolves to the user token if available, or undefined if OAuth flow needs to be started.
85
- */
86
- async beginFlow(context) {
87
- var _a;
88
- this.state = await this.getFlowState(context);
89
- if (this.absOauthConnectionName === '') {
90
- throw new Error('connectionName is not set');
91
- }
92
- logger.info('Starting OAuth flow for connectionName:', this.absOauthConnectionName);
93
- await this.refreshToken(context);
94
- const act = context.activity;
95
- // Check cache first before starting OAuth flow
96
- if (act.channelId && act.from && act.from.id) {
97
- const cacheKey = this.getCacheKey(context);
98
- const cachedEntry = this.tokenCache.get(cacheKey);
99
- if (cachedEntry && Date.now() < cachedEntry.expiresAt) {
100
- logger.info(`Returning cached token for user in beginFlow with cache key: ${cacheKey}`);
101
- return cachedEntry.token;
102
- }
103
- }
104
- const output = await this.userTokenClient.getTokenOrSignInResource((_a = act.from) === null || _a === void 0 ? void 0 : _a.id, this.absOauthConnectionName, act.channelId, act.getConversationReference(), act.relatesTo, undefined);
105
- if (output && output.tokenResponse) {
106
- // Cache the token if it's valid
107
- if (act.channelId && act.from && act.from.id) {
108
- const cacheKey = this.getCacheKey(context);
109
- const cacheExpiry = Date.now() + (10 * 60 * 1000); // 10 minutes from now
110
- this.tokenCache.set(cacheKey, {
111
- token: output.tokenResponse,
112
- expiresAt: cacheExpiry
113
- });
114
- logger.info('Token cached for 10 minutes in beginFlow');
115
- this.state = { flowStarted: false, flowExpires: 0, absOauthConnectionName: this.absOauthConnectionName };
116
- }
117
- logger.info('Token retrieved successfully');
118
- return output.tokenResponse;
119
- }
120
- const oCard = __1.CardFactory.oauthCard(this.absOauthConnectionName, this.cardTitle, this.cardText, output.signInResource);
121
- await context.sendActivity(__1.MessageFactory.attachment(oCard));
122
- this.state = { flowStarted: true, flowExpires: Date.now() + 60 * 5 * 1000, absOauthConnectionName: this.absOauthConnectionName };
123
- await this.storage.write({ [this.getFlowStateKey(context)]: this.state });
124
- logger.info('OAuth card sent, flow started');
125
- return undefined;
126
- }
127
- /**
128
- * Continues the OAuth flow.
129
- * @param context The turn context.
130
- * @returns A promise that resolves to the user token response.
131
- */
132
- async continueFlow(context) {
133
- var _a, _b, _c, _d, _e, _f, _g, _h;
134
- this.state = await this.getFlowState(context);
135
- await this.refreshToken(context);
136
- if (((_a = this.state) === null || _a === void 0 ? void 0 : _a.flowExpires) !== 0 && Date.now() > ((_b = this.state) === null || _b === void 0 ? void 0 : _b.flowExpires)) {
137
- logger.warn('Flow expired');
138
- await context.sendActivity(__1.MessageFactory.text('Sign-in session expired. Please try again.'));
139
- this.state.flowStarted = false;
140
- return { token: undefined };
141
- }
142
- const contFlowActivity = context.activity;
143
- if (contFlowActivity.type === agents_activity_1.ActivityTypes.Message) {
144
- const magicCode = contFlowActivity.text;
145
- if (magicCode.match(/^\d{6}$/)) {
146
- const result = await ((_c = this.userTokenClient) === null || _c === void 0 ? void 0 : _c.getUserToken(this.absOauthConnectionName, contFlowActivity.channelId, (_d = contFlowActivity.from) === null || _d === void 0 ? void 0 : _d.id, magicCode));
147
- if (result && result.token) {
148
- // Cache the token if it's valid
149
- if (contFlowActivity.channelId && contFlowActivity.from && contFlowActivity.from.id) {
150
- const cacheKey = this.getCacheKey(context);
151
- const cacheExpiry = Date.now() + (10 * 60 * 1000); // 10 minutes from now
152
- this.tokenCache.set(cacheKey, {
153
- token: result,
154
- expiresAt: cacheExpiry
155
- });
156
- logger.info('Token cached for 10 minutes in continueFlow (magic code)');
157
- }
158
- await this.storage.delete([this.getFlowStateKey(context)]);
159
- logger.info('Token retrieved successfully');
160
- return result;
161
- }
162
- else {
163
- // await context.sendActivity(MessageFactory.text('Invalid code. Please try again.'))
164
- logger.warn('Invalid magic code provided');
165
- this.state = { flowStarted: true, flowExpires: Date.now() + 30000, absOauthConnectionName: this.absOauthConnectionName };
166
- await this.storage.write({ [this.getFlowStateKey(context)]: this.state });
167
- return { token: undefined };
168
- }
169
- }
170
- else {
171
- logger.warn('Invalid magic code format');
172
- await context.sendActivity(__1.MessageFactory.text('Invalid code format. Please enter a 6-digit code.'));
173
- return { token: undefined };
174
- }
175
- }
176
- if (contFlowActivity.type === agents_activity_1.ActivityTypes.Invoke && contFlowActivity.name === 'signin/verifyState') {
177
- logger.info('Continuing OAuth flow with verifyState');
178
- const tokenVerifyState = contFlowActivity.value;
179
- const magicCode = tokenVerifyState.state;
180
- const result = await ((_e = this.userTokenClient) === null || _e === void 0 ? void 0 : _e.getUserToken(this.absOauthConnectionName, contFlowActivity.channelId, (_f = contFlowActivity.from) === null || _f === void 0 ? void 0 : _f.id, magicCode));
181
- // Cache the token if it's valid
182
- if (result && result.token && contFlowActivity.channelId && contFlowActivity.from && contFlowActivity.from.id) {
183
- const cacheKey = this.getCacheKey(context);
184
- const cacheExpiry = Date.now() + (10 * 60 * 1000); // 10 minutes from now
185
- this.tokenCache.set(cacheKey, {
186
- token: result,
187
- expiresAt: cacheExpiry
188
- });
189
- logger.info('Token cached for 10 minutes in continueFlow (verifyState)');
190
- }
191
- return result;
192
- }
193
- if (contFlowActivity.type === agents_activity_1.ActivityTypes.Invoke && contFlowActivity.name === 'signin/tokenExchange') {
194
- logger.info('Continuing OAuth flow with tokenExchange');
195
- const tokenExchangeRequest = contFlowActivity.value;
196
- if (this.tokenExchangeId === tokenExchangeRequest.id) { // dedupe
197
- logger.debug('Token exchange request already processed, skipping');
198
- return { token: undefined };
199
- }
200
- this.tokenExchangeId = tokenExchangeRequest.id;
201
- const userTokenResp = await ((_g = this.userTokenClient) === null || _g === void 0 ? void 0 : _g.exchangeTokenAsync((_h = contFlowActivity.from) === null || _h === void 0 ? void 0 : _h.id, this.absOauthConnectionName, contFlowActivity.channelId, tokenExchangeRequest));
202
- if (userTokenResp && userTokenResp.token) {
203
- // Cache the token if it's valid
204
- if (contFlowActivity.channelId && contFlowActivity.from && contFlowActivity.from.id) {
205
- const cacheKey = this.getCacheKey(context);
206
- const cacheExpiry = Date.now() + (10 * 60 * 1000); // 10 minutes from now
207
- this.tokenCache.set(cacheKey, {
208
- token: userTokenResp,
209
- expiresAt: cacheExpiry
210
- });
211
- logger.info('Token cached for 10 minutes in continueFlow (tokenExchange)');
212
- }
213
- logger.info('Token exchanged');
214
- this.state.flowStarted = false;
215
- await this.storage.write({ [this.getFlowStateKey(context)]: this.state });
216
- return userTokenResp;
217
- }
218
- else {
219
- logger.warn('Token exchange failed');
220
- this.state.flowStarted = true;
221
- return { token: undefined };
222
- }
223
- }
224
- return { token: undefined };
225
- }
226
- /**
227
- * Signs the user out.
228
- * @param context The turn context.
229
- * @returns A promise that resolves when the sign-out operation is complete.
230
- */
231
- async signOut(context) {
232
- var _a, _b;
233
- await this.refreshToken(context);
234
- // Clear cached token for this user
235
- const activity = context.activity;
236
- if (activity.channelId && activity.from && activity.from.id) {
237
- const cacheKey = this.getCacheKey(context);
238
- this.tokenCache.delete(cacheKey);
239
- logger.info('Cached token cleared for user');
240
- }
241
- await ((_a = this.userTokenClient) === null || _a === void 0 ? void 0 : _a.signOut((_b = context.activity.from) === null || _b === void 0 ? void 0 : _b.id, this.absOauthConnectionName, context.activity.channelId));
242
- this.state = { flowStarted: false, flowExpires: 0, absOauthConnectionName: this.absOauthConnectionName };
243
- await this.storage.delete([this.getFlowStateKey(context)]);
244
- logger.info('User signed out successfully from connection:', this.absOauthConnectionName);
245
- }
246
- /**
247
- * Gets the user state for the OAuth flow.
248
- * @param context The turn context.
249
- * @returns A promise that resolves to the flow state.
250
- */
251
- async getFlowState(context) {
252
- const key = this.getFlowStateKey(context);
253
- const data = await this.storage.read([key]);
254
- const flowState = data[key]; // ?? { flowStarted: false, flowExpires: 0 }
255
- return flowState;
256
- }
257
- /**
258
- * Sets the flow state for the OAuth flow.
259
- * @param context The turn context.
260
- * @param flowState The flow state to set.
261
- * @returns A promise that resolves when the flow state is set.
262
- */
263
- async setFlowState(context, flowState) {
264
- const key = this.getFlowStateKey(context);
265
- await this.storage.write({ [key]: flowState });
266
- this.state = flowState;
267
- logger.debug(`Flow state set: ${JSON.stringify(flowState)}`);
268
- }
269
- /**
270
- * Initializes the user token client if not already initialized.
271
- * @param context The turn context used to get authentication credentials.
272
- */
273
- async refreshToken(context) {
274
- const cachedToken = this.tokenCache.get('__access_token__');
275
- if (!cachedToken || Date.now() > cachedToken.expiresAt) {
276
- const accessToken = await context.adapter.authProvider.getAccessToken(context.adapter.authConfig, 'https://api.botframework.com');
277
- const decodedToken = jsonwebtoken_1.default.decode(accessToken);
278
- this.tokenCache.set('__access_token__', {
279
- token: { token: accessToken },
280
- expiresAt: (decodedToken === null || decodedToken === void 0 ? void 0 : decodedToken.exp) ? decodedToken.exp * 1000 - 1000 : Date.now() + 10 * 60 * 1000
281
- });
282
- this.userTokenClient.updateAuthToken(accessToken);
283
- }
284
- }
285
- /**
286
- * Generates a cache key for storing user tokens.
287
- * @param context The turn context containing activity information.
288
- * @returns The cache key string in format: channelId_userId_connectionName.
289
- * @throws Will throw an error if required activity properties are missing.
290
- */
291
- getCacheKey(context) {
292
- const activity = context.activity;
293
- if (!activity.channelId || !activity.from || !activity.from.id) {
294
- throw new Error('ChannelId and from.id must be set in the activity for cache key generation');
295
- }
296
- return `${activity.channelId}_${activity.from.id}_${this.absOauthConnectionName}`;
297
- }
298
- /**
299
- * Generates a storage key for persisting OAuth flow state.
300
- * @param context The turn context containing activity information.
301
- * @returns The storage key string in format: oauth/channelId/conversationId/userId/flowState.
302
- * @throws Will throw an error if required activity properties are missing.
303
- */
304
- getFlowStateKey(context) {
305
- var _a, _b;
306
- const channelId = context.activity.channelId;
307
- const conversationId = (_a = context.activity.conversation) === null || _a === void 0 ? void 0 : _a.id;
308
- const userId = (_b = context.activity.from) === null || _b === void 0 ? void 0 : _b.id;
309
- if (!channelId || !conversationId || !userId) {
310
- throw new Error('ChannelId, conversationId, and userId must be set in the activity');
311
- }
312
- return `oauth/${channelId}/${userId}/${this.absOauthConnectionName}/flowState`;
313
- }
314
- }
315
- exports.OAuthFlow = OAuthFlow;
316
- //# sourceMappingURL=oAuthFlow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oAuthFlow.js","sourceRoot":"","sources":["../../../src/oauth/oAuthFlow.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4D;AAC5D,kCAAkC;AAClC,8DAAyD;AACzD,gEAAgF;AAChF,2BAKY;AAGZ,gEAA8C;AAE9C,MAAM,MAAM,GAAG,IAAA,cAAK,EAAC,mBAAmB,CAAC,CAAA;AA4BzC;;GAEG;AACH,MAAa,SAAS;IAoCpB;;;;;;;OAOG;IACH,YAAqB,OAAgB,EAAE,sBAA8B,EAAE,WAA4B,EAAE,SAAkB,EAAE,QAAiB;QAArH,YAAO,GAAP,OAAO,CAAS;QAjCrC;;WAEG;QACH,oBAAe,GAAkB,IAAI,CAAA;QAErC;;WAEG;QACK,eAAU,GAA6B,IAAI,GAAG,EAAE,CAAA;QAOxD;;WAEG;QACH,cAAS,GAAW,SAAS,CAAA;Q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