@microsoft/agents-hosting 0.5.1-g2e246ff274 → 0.5.12-g2d752e9b13
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/src/app/adaptiveCards/adaptiveCardsActions.js +4 -4
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js.map +1 -1
- package/dist/src/app/agentApplication.js +1 -1
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/oauth/authorization.d.ts +1 -0
- package/dist/src/app/oauth/authorization.js +3 -4
- package/dist/src/app/oauth/authorization.js.map +1 -1
- package/dist/src/app/streaming/citation.d.ts +25 -0
- package/dist/src/app/streaming/citation.js +7 -0
- package/dist/src/app/streaming/citation.js.map +1 -0
- package/dist/src/app/streaming/citationUtil.d.ts +31 -0
- package/dist/src/app/streaming/citationUtil.js +70 -0
- package/dist/src/app/streaming/citationUtil.js.map +1 -0
- package/dist/src/app/streaming/streamingResponse.d.ts +140 -0
- package/dist/src/app/streaming/streamingResponse.js +333 -0
- package/dist/src/app/streaming/streamingResponse.js.map +1 -0
- package/dist/src/cards/cardFactory.d.ts +2 -2
- package/dist/src/cards/cardFactory.js.map +1 -1
- package/dist/src/oauth/index.d.ts +1 -4
- package/dist/src/oauth/index.js +1 -4
- package/dist/src/oauth/index.js.map +1 -1
- package/dist/src/oauth/oAuthFlow.d.ts +9 -10
- package/dist/src/oauth/oAuthFlow.js +35 -38
- package/dist/src/oauth/oAuthFlow.js.map +1 -1
- package/dist/src/oauth/userTokenClient.d.ts +37 -7
- package/dist/src/oauth/userTokenClient.js +56 -15
- package/dist/src/oauth/userTokenClient.js.map +1 -1
- package/dist/src/oauth/userTokenClient.types.d.ts +147 -0
- package/dist/src/oauth/{signingResource.js → userTokenClient.types.js} +1 -1
- package/dist/src/oauth/userTokenClient.types.js.map +1 -0
- package/dist/src/turnContext.d.ts +3 -0
- package/dist/src/turnContext.js +5 -0
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +3 -3
- package/src/app/adaptiveCards/adaptiveCardsActions.ts +4 -4
- package/src/app/agentApplication.ts +1 -1
- package/src/app/oauth/authorization.ts +6 -8
- package/src/app/streaming/citation.ts +29 -0
- package/src/app/streaming/citationUtil.ts +76 -0
- package/src/app/streaming/streamingResponse.ts +407 -0
- package/src/cards/cardFactory.ts +2 -3
- package/src/oauth/index.ts +1 -4
- package/src/oauth/oAuthFlow.ts +39 -45
- package/src/oauth/userTokenClient.ts +62 -19
- package/src/oauth/userTokenClient.types.ts +173 -0
- package/src/turnContext.ts +7 -1
- package/dist/src/oauth/oAuthCard.d.ts +0 -27
- package/dist/src/oauth/oAuthCard.js +0 -5
- package/dist/src/oauth/oAuthCard.js.map +0 -1
- package/dist/src/oauth/signingResource.d.ts +0 -43
- package/dist/src/oauth/signingResource.js.map +0 -1
- package/dist/src/oauth/tokenExchangeRequest.d.ts +0 -17
- package/dist/src/oauth/tokenExchangeRequest.js +0 -5
- package/dist/src/oauth/tokenExchangeRequest.js.map +0 -1
- package/dist/src/oauth/tokenResponse.d.ts +0 -29
- package/dist/src/oauth/tokenResponse.js +0 -25
- package/dist/src/oauth/tokenResponse.js.map +0 -1
- package/src/oauth/oAuthCard.ts +0 -30
- package/src/oauth/signingResource.ts +0 -48
- package/src/oauth/tokenExchangeRequest.ts +0 -20
- package/src/oauth/tokenResponse.ts +0 -43
|
@@ -0,0 +1,333 @@
|
|
|
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.StreamingResponse = void 0;
|
|
8
|
+
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
9
|
+
const citationUtil_1 = require("./citationUtil");
|
|
10
|
+
const logger_1 = require("../../logger");
|
|
11
|
+
const logger = (0, logger_1.debug)('agents:streamingResponse');
|
|
12
|
+
/**
|
|
13
|
+
* A helper class for streaming responses to the client.
|
|
14
|
+
* @remarks
|
|
15
|
+
* This class is used to send a series of updates to the client in a single response. The expected
|
|
16
|
+
* sequence of calls is:
|
|
17
|
+
*
|
|
18
|
+
* `queueInformativeUpdate()`, `queueTextChunk()`, `queueTextChunk()`, ..., `endStream()`.
|
|
19
|
+
*
|
|
20
|
+
* Once `endStream()` is called, the stream is considered ended and no further updates can be sent.
|
|
21
|
+
*/
|
|
22
|
+
class StreamingResponse {
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new StreamingResponse instance.
|
|
25
|
+
* @param {TurnContext} context - Context for the current turn of conversation with the user.
|
|
26
|
+
* @returns {TurnContext} - The context for the current turn of conversation with the user.
|
|
27
|
+
*/
|
|
28
|
+
constructor(context) {
|
|
29
|
+
this._nextSequence = 1;
|
|
30
|
+
this._message = '';
|
|
31
|
+
this._ended = false;
|
|
32
|
+
// Queue for outgoing activities
|
|
33
|
+
this._queue = [];
|
|
34
|
+
this._chunkQueued = false;
|
|
35
|
+
// Powered by AI feature flags
|
|
36
|
+
this._enableFeedbackLoop = false;
|
|
37
|
+
this._enableGeneratedByAILabel = false;
|
|
38
|
+
this._citations = [];
|
|
39
|
+
this._context = context;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Gets the stream ID of the current response.
|
|
43
|
+
* @returns {string | undefined} - The stream ID of the current response.
|
|
44
|
+
* @remarks
|
|
45
|
+
* Assigned after the initial update is sent.
|
|
46
|
+
*/
|
|
47
|
+
get streamId() {
|
|
48
|
+
return this._streamId;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Gets the citations of the current response.
|
|
52
|
+
*/
|
|
53
|
+
get citations() {
|
|
54
|
+
return this._citations;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Gets the number of updates sent for the stream.
|
|
58
|
+
* @returns {number} - The number of updates sent for the stream.
|
|
59
|
+
*/
|
|
60
|
+
get updatesSent() {
|
|
61
|
+
return this._nextSequence - 1;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Queues an informative update to be sent to the client.
|
|
65
|
+
* @param {string} text Text of the update to send.
|
|
66
|
+
*/
|
|
67
|
+
queueInformativeUpdate(text) {
|
|
68
|
+
if (this._ended) {
|
|
69
|
+
throw new Error('The stream has already ended.');
|
|
70
|
+
}
|
|
71
|
+
// Queue a typing activity
|
|
72
|
+
this.queueActivity(() => agents_activity_1.Activity.fromObject({
|
|
73
|
+
type: 'typing',
|
|
74
|
+
text,
|
|
75
|
+
channelData: {
|
|
76
|
+
streamType: 'informative',
|
|
77
|
+
streamSequence: this._nextSequence++
|
|
78
|
+
}
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Queues a chunk of partial message text to be sent to the client
|
|
83
|
+
* @remarks
|
|
84
|
+
* The text we be sent as quickly as possible to the client. Chunks may be combined before
|
|
85
|
+
* delivery to the client.
|
|
86
|
+
* @param {string} text Partial text of the message to send.
|
|
87
|
+
* @param {Citation[]} citations Citations to be included in the message.
|
|
88
|
+
*/
|
|
89
|
+
queueTextChunk(text, citations) {
|
|
90
|
+
if (this._ended) {
|
|
91
|
+
throw new Error('The stream has already ended.');
|
|
92
|
+
}
|
|
93
|
+
// Update full message text
|
|
94
|
+
this._message += text;
|
|
95
|
+
// If there are citations, modify the content so that the sources are numbers instead of [doc1], [doc2], etc.
|
|
96
|
+
this._message = citationUtil_1.CitationUtil.formatCitationsResponse(this._message);
|
|
97
|
+
// Queue the next chunk
|
|
98
|
+
this.queueNextChunk();
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Ends the stream by sending the final message to the client.
|
|
102
|
+
* @returns {Promise<void>} - A promise representing the async operation
|
|
103
|
+
*/
|
|
104
|
+
endStream() {
|
|
105
|
+
if (this._ended) {
|
|
106
|
+
throw new Error('The stream has already ended.');
|
|
107
|
+
}
|
|
108
|
+
// Queue final message
|
|
109
|
+
this._ended = true;
|
|
110
|
+
this.queueNextChunk();
|
|
111
|
+
// Wait for the queue to drain
|
|
112
|
+
return this.waitForQueue();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Sets the attachments to attach to the final chunk.
|
|
116
|
+
* @param attachments List of attachments.
|
|
117
|
+
*/
|
|
118
|
+
setAttachments(attachments) {
|
|
119
|
+
this._attachments = attachments;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Sets the sensitivity label to attach to the final chunk.
|
|
123
|
+
* @param sensitivityLabel The sensitivty label.
|
|
124
|
+
*/
|
|
125
|
+
setSensitivityLabel(sensitivityLabel) {
|
|
126
|
+
this._sensitivityLabel = sensitivityLabel;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Sets the citations for the full message.
|
|
130
|
+
* @param {Citation[]} citations Citations to be included in the message.
|
|
131
|
+
*/
|
|
132
|
+
setCitations(citations) {
|
|
133
|
+
if (citations.length > 0) {
|
|
134
|
+
if (!this._citations) {
|
|
135
|
+
this._citations = [];
|
|
136
|
+
}
|
|
137
|
+
let currPos = this._citations.length;
|
|
138
|
+
for (const citation of citations) {
|
|
139
|
+
const clientCitation = {
|
|
140
|
+
'@type': 'Claim',
|
|
141
|
+
position: currPos + 1,
|
|
142
|
+
appearance: {
|
|
143
|
+
'@type': 'DigitalDocument',
|
|
144
|
+
name: citation.title || `Document #${currPos + 1}`,
|
|
145
|
+
abstract: citationUtil_1.CitationUtil.snippet(citation.content, 477)
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
currPos++;
|
|
149
|
+
this._citations.push(clientCitation);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Sets the Feedback Loop in Teams that allows a user to
|
|
155
|
+
* give thumbs up or down to a response.
|
|
156
|
+
* Default is `false`.
|
|
157
|
+
* @param enableFeedbackLoop If true, the feedback loop is enabled.
|
|
158
|
+
*/
|
|
159
|
+
setFeedbackLoop(enableFeedbackLoop) {
|
|
160
|
+
this._enableFeedbackLoop = enableFeedbackLoop;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Sets the type of UI to use for the feedback loop.
|
|
164
|
+
* @param feedbackLoopType The type of the feedback loop.
|
|
165
|
+
*/
|
|
166
|
+
setFeedbackLoopType(feedbackLoopType) {
|
|
167
|
+
this._feedbackLoopType = feedbackLoopType;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Sets the the Generated by AI label in Teams
|
|
171
|
+
* Default is `false`.
|
|
172
|
+
* @param enableGeneratedByAILabel If true, the label is added.
|
|
173
|
+
*/
|
|
174
|
+
setGeneratedByAILabel(enableGeneratedByAILabel) {
|
|
175
|
+
this._enableGeneratedByAILabel = enableGeneratedByAILabel;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Returns the most recently streamed message.
|
|
179
|
+
* @returns The streamed message.
|
|
180
|
+
*/
|
|
181
|
+
getMessage() {
|
|
182
|
+
return this._message;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Waits for the outgoing activity queue to be empty.
|
|
186
|
+
* @returns {Promise<void>} - A promise representing the async operation.
|
|
187
|
+
*/
|
|
188
|
+
waitForQueue() {
|
|
189
|
+
return this._queueSync || Promise.resolve();
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Queues the next chunk of text to be sent to the client.
|
|
193
|
+
* @private
|
|
194
|
+
*/
|
|
195
|
+
queueNextChunk() {
|
|
196
|
+
// Are we already waiting to send a chunk?
|
|
197
|
+
if (this._chunkQueued) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
// Queue a chunk of text to be sent
|
|
201
|
+
this._chunkQueued = true;
|
|
202
|
+
this.queueActivity(() => {
|
|
203
|
+
this._chunkQueued = false;
|
|
204
|
+
if (this._ended) {
|
|
205
|
+
// Send final message
|
|
206
|
+
return agents_activity_1.Activity.fromObject({
|
|
207
|
+
type: 'message',
|
|
208
|
+
text: this._message || 'end strean response',
|
|
209
|
+
attachments: this._attachments,
|
|
210
|
+
channelData: {
|
|
211
|
+
streamType: 'final',
|
|
212
|
+
streamSequence: this._nextSequence++
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
// Send typing activity
|
|
218
|
+
return agents_activity_1.Activity.fromObject({
|
|
219
|
+
type: 'typing',
|
|
220
|
+
text: this._message,
|
|
221
|
+
channelData: {
|
|
222
|
+
streamType: 'streaming',
|
|
223
|
+
streamSequence: this._nextSequence++
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Queues an activity to be sent to the client.
|
|
231
|
+
*/
|
|
232
|
+
queueActivity(factory) {
|
|
233
|
+
this._queue.push(factory);
|
|
234
|
+
// If there's no sync in progress, start one
|
|
235
|
+
if (!this._queueSync) {
|
|
236
|
+
this._queueSync = this.drainQueue().catch((err) => {
|
|
237
|
+
logger.error(`Error occured when sending activity while streaming: "${err}".`);
|
|
238
|
+
// throw err
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Sends any queued activities to the client until the queue is empty.
|
|
244
|
+
* @returns {Promise<void>} - A promise that will be resolved once the queue is empty.
|
|
245
|
+
* @private
|
|
246
|
+
*/
|
|
247
|
+
async drainQueue() {
|
|
248
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
249
|
+
return new Promise(async (resolve, reject) => {
|
|
250
|
+
try {
|
|
251
|
+
logger.debug(`Draining queue with ${this._queue.length} activities.`);
|
|
252
|
+
while (this._queue.length > 0) {
|
|
253
|
+
const factory = this._queue.shift();
|
|
254
|
+
const activity = factory();
|
|
255
|
+
await this.sendActivity(activity);
|
|
256
|
+
}
|
|
257
|
+
resolve();
|
|
258
|
+
}
|
|
259
|
+
catch (err) {
|
|
260
|
+
reject(err);
|
|
261
|
+
}
|
|
262
|
+
finally {
|
|
263
|
+
this._queueSync = undefined;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Sends an activity to the client and saves the stream ID returned.
|
|
269
|
+
* @param {Activity} activity - The activity to send.
|
|
270
|
+
* @returns {Promise<void>} - A promise representing the async operation.
|
|
271
|
+
* @private
|
|
272
|
+
*/
|
|
273
|
+
async sendActivity(activity) {
|
|
274
|
+
var _a;
|
|
275
|
+
// Set activity ID to the assigned stream ID
|
|
276
|
+
if (this._streamId) {
|
|
277
|
+
activity.id = this._streamId;
|
|
278
|
+
activity.channelData = Object.assign({}, activity.channelData, { streamId: this._streamId });
|
|
279
|
+
}
|
|
280
|
+
activity.entities = [
|
|
281
|
+
{
|
|
282
|
+
type: 'streaminfo',
|
|
283
|
+
...activity.channelData
|
|
284
|
+
}
|
|
285
|
+
];
|
|
286
|
+
if (this._citations && this._citations.length > 0 && !this._ended) {
|
|
287
|
+
// Filter out the citations unused in content.
|
|
288
|
+
const currCitations = (_a = citationUtil_1.CitationUtil.getUsedCitations(this._message, this._citations)) !== null && _a !== void 0 ? _a : undefined;
|
|
289
|
+
activity.entities.push({
|
|
290
|
+
type: 'https://schema.org/Message',
|
|
291
|
+
'@type': 'Message',
|
|
292
|
+
'@context': 'https://schema.org',
|
|
293
|
+
'@id': '',
|
|
294
|
+
citation: currCitations
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
// Add in Powered by AI feature flags
|
|
298
|
+
if (this._ended) {
|
|
299
|
+
if (this._enableFeedbackLoop && this._feedbackLoopType) {
|
|
300
|
+
activity.channelData = Object.assign({}, activity.channelData, {
|
|
301
|
+
feedbackLoop: { type: this._feedbackLoopType }
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
activity.channelData = Object.assign({}, activity.channelData, {
|
|
306
|
+
feedbackLoopEnabled: this._enableFeedbackLoop
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
// Add in Generated by AI
|
|
310
|
+
if (this._enableGeneratedByAILabel) {
|
|
311
|
+
(0, agents_activity_1.addAIToActivity)(activity, this._citations, this._sensitivityLabel);
|
|
312
|
+
// activity.entities.push({
|
|
313
|
+
// type: 'https://schema.org/Message',
|
|
314
|
+
// '@type': 'Message',
|
|
315
|
+
// '@context': 'https://schema.org',
|
|
316
|
+
// '@id': '',
|
|
317
|
+
// additionalType: ['AIGeneratedContent'],
|
|
318
|
+
// citation: this._citations && this._citations.length > 0 ? this._citations : [],
|
|
319
|
+
// usageInfo: this._sensitivityLabel
|
|
320
|
+
// } as unknown as Entity)
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
// Send activity
|
|
324
|
+
const response = await this._context.sendActivity(activity);
|
|
325
|
+
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
326
|
+
// Save assigned stream ID
|
|
327
|
+
if (!this._streamId) {
|
|
328
|
+
this._streamId = response === null || response === void 0 ? void 0 : response.id;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
exports.StreamingResponse = StreamingResponse;
|
|
333
|
+
//# sourceMappingURL=streamingResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamingResponse.js","sourceRoot":"","sources":["../../../../src/app/streaming/streamingResponse.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAA0F;AAG1F,iDAA6C;AAC7C,yCAAoC;AAGpC,MAAM,MAAM,GAAG,IAAA,cAAK,EAAC,0BAA0B,CAAC,CAAA;AAEhD;;;;;;;;;GASG;AACH,MAAa,iBAAiB;IAoB5B;;;;SAIK;IACL,YAAoB,OAAoB;QAvBhC,kBAAa,GAAW,CAAC,CAAA;QAEzB,aAAQ,GAAW,EAAE,CAAA;QAErB,WAAM,GAAG,KAAK,CAAA;QAEtB,gCAAgC;QACxB,WAAM,GAA0B,EAAE,CAAA;QAElC,iBAAY,GAAG,KAAK,CAAA;QAE5B,8B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C,WAAW,EAAE;oBAC7D,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;iBAC9C,CAAC,CAAA;YACJ,CAAC;YAED,yBAAyB;YACzB,IAAI,IAAI,CAAC,yBAAyB,EAAE,CAAC;gBACnC,IAAA,iCAAe,EAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAA;gBAClE,2BAA2B;gBAC3B,wCAAwC;gBACxC,wBAAwB;gBACxB,sCAAsC;gBACtC,eAAe;gBACf,4CAA4C;gBAC5C,oFAAoF;gBACpF,sCAAsC;gBACtC,0BAA0B;YAC5B,CAAC;QACH,CAAC;QAED,gBAAgB;QAChB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;QAC3D,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;QAEzD,0BAA0B;QAC1B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,EAAE,CAAA;QAC/B,CAAC;IACH,CAAC;CACF;AA3VD,8CA2VC"}
|
|
@@ -12,7 +12,7 @@ import { O365ConnectorCard } from './o365ConnectorCard';
|
|
|
12
12
|
import { ThumbnailCard } from './thumbnailCard';
|
|
13
13
|
import { VideoCard } from './videoCard';
|
|
14
14
|
import { CardImage } from './cardImage';
|
|
15
|
-
import {
|
|
15
|
+
import { SignInResource } from '../oauth/userTokenClient.types';
|
|
16
16
|
/**
|
|
17
17
|
* Factory class for creating various types of cards.
|
|
18
18
|
*/
|
|
@@ -106,7 +106,7 @@ export declare class CardFactory {
|
|
|
106
106
|
* @param signingResource The signing resource.
|
|
107
107
|
* @returns The OAuth card attachment.
|
|
108
108
|
*/
|
|
109
|
-
static oauthCard(connectionName: string, title: string, text: string, signingResource:
|
|
109
|
+
static oauthCard(connectionName: string, title: string, text: string, signingResource: SignInResource): Attachment;
|
|
110
110
|
/**
|
|
111
111
|
* Creates a sign-in card attachment.
|
|
112
112
|
* @param title The title of the card.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cardFactory.js","sourceRoot":"","sources":["../../../src/cards/cardFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAAgF;
|
|
1
|
+
{"version":3,"file":"cardFactory.js","sourceRoot":"","sources":["../../../src/cards/cardFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAAgF;AAahF;;GAEG;AACH,MAAa,WAAW;IAiBtB;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAE,IAAS;QAC5B,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAC9E,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,aAAa,CAClB,KAAa,EACb,KAA4B,EAC5B,OAAiC,EACjC,KAA8B;QAE9B,OAAO,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IACpG,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,SAAS,CACd,KAAa,EACb,KAA4B,EAC5B,OAAiC,EACjC,KAA0B;QAE1B,OAAO,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IAChG,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAE,KAAa,EAAE,IAAU,EAAE,MAAY,EAAE,OAAa,EAAE,KAAyB;QAChG,MAAM,CAAC,GAAe,WAAW,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,EAA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E,EAAE;YAC/C,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC5B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAChB,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA;YACzB,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;;;;;OAQG;IACK,MAAM,CAAC,SAAS,CACtB,WAAmB,EACnB,KAAa,EACb,KAA4B,EAC5B,OAAiC,EACjC,KAAW;QAEX,MAAM,IAAI,GAAc,EAAE,GAAG,KAAK,EAAE,CAAA;QACpC,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACrC,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC7C,CAAC;QAED,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IACvC,CAAC;;AAvRH,kCAwRC;AAvRC;;GAEG;AACI,wBAAY,GAAQ;IACzB,YAAY,EAAE,yCAAyC;IACvD,aAAa,EAAE,0CAA0C;IACzD,SAAS,EAAE,sCAAsC;IACjD,QAAQ,EAAE,qCAAqC;IAC/C,WAAW,EAAE,wCAAwC;IACrD,iBAAiB,EAAE,oDAAoD;IACvE,aAAa,EAAE,0CAA0C;IACzD,SAAS,EAAE,sCAAsC;IACjD,SAAS,EAAE,sCAAsC;IACjD,UAAU,EAAE,uCAAuC;CACpD,CAAA"}
|
package/dist/src/oauth/index.js
CHANGED
|
@@ -14,10 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./oAuthCard"), exports);
|
|
18
|
-
__exportStar(require("./signingResource"), exports);
|
|
19
17
|
__exportStar(require("./userTokenClient"), exports);
|
|
20
|
-
__exportStar(require("./tokenExchangeRequest"), exports);
|
|
21
18
|
__exportStar(require("./oAuthFlow"), exports);
|
|
22
|
-
__exportStar(require("./
|
|
19
|
+
__exportStar(require("./userTokenClient.types"), exports);
|
|
23
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/oauth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/oauth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,8CAA2B;AAC3B,0DAAuC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { TurnContext, Storage } from '../';
|
|
2
|
+
import { UserTokenClient } from './userTokenClient';
|
|
3
|
+
import { TokenResponse } from './userTokenClient.types';
|
|
4
|
+
export interface FlowState {
|
|
4
5
|
flowStarted: boolean;
|
|
5
6
|
flowExpires: number;
|
|
6
7
|
}
|
|
@@ -8,6 +9,7 @@ export declare class FlowState {
|
|
|
8
9
|
* Manages the OAuth flow
|
|
9
10
|
*/
|
|
10
11
|
export declare class OAuthFlow {
|
|
12
|
+
private storage;
|
|
11
13
|
/**
|
|
12
14
|
* The user token client used for managing user tokens.
|
|
13
15
|
*/
|
|
@@ -15,11 +17,7 @@ export declare class OAuthFlow {
|
|
|
15
17
|
/**
|
|
16
18
|
* The current state of the OAuth flow.
|
|
17
19
|
*/
|
|
18
|
-
state: FlowState
|
|
19
|
-
/**
|
|
20
|
-
* The accessor for managing the flow state in user state.
|
|
21
|
-
*/
|
|
22
|
-
flowStateAccessor: AgentStatePropertyAccessor<FlowState | null>;
|
|
20
|
+
state: FlowState;
|
|
23
21
|
/**
|
|
24
22
|
* The ID of the token exchange request, used to deduplicate requests.
|
|
25
23
|
*/
|
|
@@ -40,7 +38,7 @@ export declare class OAuthFlow {
|
|
|
40
38
|
* Creates a new instance of OAuthFlow.
|
|
41
39
|
* @param userState The user state.
|
|
42
40
|
*/
|
|
43
|
-
constructor(
|
|
41
|
+
constructor(storage: Storage, absOauthConnectionName: string, tokenClient?: UserTokenClient, cardTitle?: string, cardText?: string);
|
|
44
42
|
/**
|
|
45
43
|
* Retrieves the user token from the user token service.
|
|
46
44
|
* @param context The turn context containing the activity information.
|
|
@@ -53,7 +51,7 @@ export declare class OAuthFlow {
|
|
|
53
51
|
* @param context The turn context.
|
|
54
52
|
* @returns A promise that resolves to the user token.
|
|
55
53
|
*/
|
|
56
|
-
beginFlow(context: TurnContext): Promise<TokenResponse>;
|
|
54
|
+
beginFlow(context: TurnContext): Promise<TokenResponse | undefined>;
|
|
57
55
|
/**
|
|
58
56
|
* Continues the OAuth flow.
|
|
59
57
|
* @param context The turn context.
|
|
@@ -73,4 +71,5 @@ export declare class OAuthFlow {
|
|
|
73
71
|
*/
|
|
74
72
|
private getUserState;
|
|
75
73
|
private initializeTokenClient;
|
|
74
|
+
private getFlowStateKey;
|
|
76
75
|
}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OAuthFlow =
|
|
3
|
+
exports.OAuthFlow = void 0;
|
|
4
4
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
5
|
// Licensed under the MIT License.
|
|
6
6
|
const logger_1 = require("./../logger");
|
|
7
7
|
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
8
8
|
const __1 = require("../");
|
|
9
|
-
const
|
|
9
|
+
const userTokenClient_1 = require("./userTokenClient");
|
|
10
10
|
const logger = (0, logger_1.debug)('agents:oauth-flow');
|
|
11
|
-
class FlowState {
|
|
12
|
-
constructor() {
|
|
13
|
-
this.flowStarted = false;
|
|
14
|
-
this.flowExpires = 0;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.FlowState = FlowState;
|
|
18
11
|
/**
|
|
19
12
|
* Manages the OAuth flow
|
|
20
13
|
*/
|
|
@@ -23,7 +16,8 @@ class OAuthFlow {
|
|
|
23
16
|
* Creates a new instance of OAuthFlow.
|
|
24
17
|
* @param userState The user state.
|
|
25
18
|
*/
|
|
26
|
-
constructor(
|
|
19
|
+
constructor(storage, absOauthConnectionName, tokenClient, cardTitle, cardText) {
|
|
20
|
+
this.storage = storage;
|
|
27
21
|
/**
|
|
28
22
|
* The ID of the token exchange request, used to deduplicate requests.
|
|
29
23
|
*/
|
|
@@ -36,8 +30,7 @@ class OAuthFlow {
|
|
|
36
30
|
* The text of the OAuth card.
|
|
37
31
|
*/
|
|
38
32
|
this.cardText = 'login';
|
|
39
|
-
this.state =
|
|
40
|
-
this.flowStateAccessor = userState.createProperty('flowState');
|
|
33
|
+
this.state = { flowExpires: 0, flowStarted: false };
|
|
41
34
|
this.absOauthConnectionName = absOauthConnectionName;
|
|
42
35
|
this.userTokenClient = tokenClient !== null && tokenClient !== void 0 ? tokenClient : null;
|
|
43
36
|
this.cardTitle = cardTitle !== null && cardTitle !== void 0 ? cardTitle : this.cardTitle;
|
|
@@ -73,26 +66,20 @@ class OAuthFlow {
|
|
|
73
66
|
}
|
|
74
67
|
logger.info('Starting OAuth flow for connectionName:', this.absOauthConnectionName);
|
|
75
68
|
await this.initializeTokenClient(context);
|
|
76
|
-
const
|
|
77
|
-
|
|
69
|
+
const act = context.activity;
|
|
70
|
+
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);
|
|
71
|
+
if (output && output.tokenResponse) {
|
|
78
72
|
this.state.flowStarted = false;
|
|
79
73
|
this.state.flowExpires = 0;
|
|
80
|
-
await this.
|
|
81
|
-
|
|
82
|
-
return tokenResponse;
|
|
74
|
+
await this.storage.write({ [this.getFlowStateKey(context)]: this.state });
|
|
75
|
+
return output.tokenResponse;
|
|
83
76
|
}
|
|
84
|
-
const
|
|
85
|
-
const signingResource = await this.userTokenClient.getSignInResource(authConfig.clientId, this.absOauthConnectionName, context.activity.getConversationReference(), context.activity.relatesTo);
|
|
86
|
-
const oCard = __1.CardFactory.oauthCard(this.absOauthConnectionName, this.cardTitle, this.cardText, signingResource);
|
|
77
|
+
const oCard = __1.CardFactory.oauthCard(this.absOauthConnectionName, this.cardTitle, this.cardText, output.signInResource);
|
|
87
78
|
await context.sendActivity(__1.MessageFactory.attachment(oCard));
|
|
88
79
|
this.state.flowStarted = true;
|
|
89
80
|
this.state.flowExpires = Date.now() + 30000;
|
|
90
|
-
await this.
|
|
91
|
-
|
|
92
|
-
return {
|
|
93
|
-
token: undefined,
|
|
94
|
-
status: tokenResponse_1.TokenRequestStatus.InProgress
|
|
95
|
-
};
|
|
81
|
+
await this.storage.write({ [this.getFlowStateKey(context)]: this.state });
|
|
82
|
+
return undefined;
|
|
96
83
|
}
|
|
97
84
|
/**
|
|
98
85
|
* Continues the OAuth flow.
|
|
@@ -107,7 +94,7 @@ class OAuthFlow {
|
|
|
107
94
|
logger.warn('Flow expired');
|
|
108
95
|
this.state.flowStarted = false;
|
|
109
96
|
await context.sendActivity(__1.MessageFactory.text('Sign-in session expired. Please try again.'));
|
|
110
|
-
return {
|
|
97
|
+
return { token: undefined };
|
|
111
98
|
}
|
|
112
99
|
const contFlowActivity = context.activity;
|
|
113
100
|
if (contFlowActivity.type === agents_activity_1.ActivityTypes.Message) {
|
|
@@ -126,23 +113,23 @@ class OAuthFlow {
|
|
|
126
113
|
logger.info('Continuing OAuth flow with tokenExchange');
|
|
127
114
|
const tokenExchangeRequest = contFlowActivity.value;
|
|
128
115
|
if (this.tokenExchangeId === tokenExchangeRequest.id) { // dedupe
|
|
129
|
-
return {
|
|
116
|
+
return { token: undefined };
|
|
130
117
|
}
|
|
131
118
|
this.tokenExchangeId = tokenExchangeRequest.id;
|
|
132
119
|
const userTokenResp = await ((_f = this.userTokenClient) === null || _f === void 0 ? void 0 : _f.exchangeTokenAsync((_g = contFlowActivity.from) === null || _g === void 0 ? void 0 : _g.id, this.absOauthConnectionName, contFlowActivity.channelId, tokenExchangeRequest));
|
|
133
|
-
if (
|
|
120
|
+
if (userTokenResp && userTokenResp.token) {
|
|
134
121
|
logger.info('Token exchanged');
|
|
135
122
|
this.state.flowStarted = false;
|
|
136
|
-
await this.
|
|
123
|
+
await this.storage.write({ [this.getFlowStateKey(context)]: this.state });
|
|
137
124
|
return userTokenResp;
|
|
138
125
|
}
|
|
139
126
|
else {
|
|
140
127
|
logger.warn('Token exchange failed');
|
|
141
128
|
this.state.flowStarted = true;
|
|
142
|
-
return {
|
|
129
|
+
return { token: undefined };
|
|
143
130
|
}
|
|
144
131
|
}
|
|
145
|
-
return {
|
|
132
|
+
return { token: undefined };
|
|
146
133
|
}
|
|
147
134
|
/**
|
|
148
135
|
* Signs the user out.
|
|
@@ -155,7 +142,7 @@ class OAuthFlow {
|
|
|
155
142
|
await this.initializeTokenClient(context);
|
|
156
143
|
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));
|
|
157
144
|
this.state.flowExpires = 0;
|
|
158
|
-
|
|
145
|
+
this.storage.write({ [this.getFlowStateKey(context)]: this.state });
|
|
159
146
|
logger.info('User signed out successfully');
|
|
160
147
|
}
|
|
161
148
|
/**
|
|
@@ -164,18 +151,28 @@ class OAuthFlow {
|
|
|
164
151
|
* @returns A promise that resolves to the user state.
|
|
165
152
|
*/
|
|
166
153
|
async getUserState(context) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
154
|
+
var _a;
|
|
155
|
+
const key = this.getFlowStateKey(context);
|
|
156
|
+
const data = await this.storage.read([key]);
|
|
157
|
+
const userProfile = (_a = data[key]) !== null && _a !== void 0 ? _a : { flowStarted: false, flowExpires: 0 };
|
|
171
158
|
return userProfile;
|
|
172
159
|
}
|
|
173
160
|
async initializeTokenClient(context) {
|
|
174
161
|
if (this.userTokenClient === undefined || this.userTokenClient === null) {
|
|
175
162
|
const scope = 'https://api.botframework.com';
|
|
176
163
|
const accessToken = await context.adapter.authProvider.getAccessToken(context.adapter.authConfig, scope);
|
|
177
|
-
this.userTokenClient = new
|
|
164
|
+
this.userTokenClient = new userTokenClient_1.UserTokenClient(accessToken, context.adapter.authConfig.clientId);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
getFlowStateKey(context) {
|
|
168
|
+
var _a, _b;
|
|
169
|
+
const channelId = context.activity.channelId;
|
|
170
|
+
const conversationId = (_a = context.activity.conversation) === null || _a === void 0 ? void 0 : _a.id;
|
|
171
|
+
const userId = (_b = context.activity.from) === null || _b === void 0 ? void 0 : _b.id;
|
|
172
|
+
if (!channelId || !conversationId || !userId) {
|
|
173
|
+
throw new Error('ChannelId, conversationId, and userId must be set in the activity');
|
|
178
174
|
}
|
|
175
|
+
return `oauth/${channelId}/${conversationId}/${userId}/flowState`;
|
|
179
176
|
}
|
|
180
177
|
}
|
|
181
178
|
exports.OAuthFlow = OAuthFlow;
|