botbuilder-dialogs
Advanced tools
Comparing version
@@ -37,2 +37,11 @@ /** | ||
timeout?: number; | ||
/** | ||
* (Optional) value indicating whether the OAuthPrompt should end upon | ||
* receiving an invalid message. Generally the OAuthPrompt will ignore | ||
* incoming messages from the user during the auth flow, if they are not related to the | ||
* auth flow. This flag enables ending the OAuthPrompt rather than | ||
* ignoring the user's message. Typically, this flag will be set to 'true', but is 'false' | ||
* by default for backwards compatibility. | ||
*/ | ||
endOnInvalidMessage?: boolean; | ||
} | ||
@@ -39,0 +48,0 @@ /** |
@@ -142,8 +142,12 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// Recognize token | ||
const recognized = yield this.recognizeToken(dc); | ||
// Check for timeout | ||
const state = dc.activeDialog.state; | ||
const isMessage = dc.context.activity.type === botbuilder_core_1.ActivityTypes.Message; | ||
const hasTimedOut = isMessage && (new Date().getTime() > state.expires); | ||
const isTimeoutActivityType = isMessage | ||
|| this.isTokenResponseEvent(dc.context) | ||
|| this.isTeamsVerificationInvoke(dc.context) | ||
|| this.isTokenExchangeRequestInvoke(dc.context); | ||
// If the incoming Activity is a message, or an Activity Type normally handled by OAuthPrompt, | ||
// check to see if this OAuthPrompt Expiration has elapsed, and end the dialog if so. | ||
const hasTimedOut = isTimeoutActivityType && (new Date().getTime() > state.expires); | ||
if (hasTimedOut) { | ||
@@ -153,2 +157,4 @@ return yield dc.endDialog(undefined); | ||
else { | ||
// Recognize token | ||
const recognized = yield this.recognizeToken(dc); | ||
if (state.state['attemptCount'] === undefined) { | ||
@@ -175,9 +181,10 @@ state.state['attemptCount'] = 0; | ||
} | ||
else { | ||
// Send retry prompt | ||
if (!dc.context.responded && isMessage && state.options.retryPrompt) { | ||
yield dc.context.sendActivity(state.options.retryPrompt); | ||
} | ||
return dialog_1.Dialog.EndOfTurn; | ||
if (isMessage && this.settings.endOnInvalidMessage) { | ||
return yield dc.endDialog(undefined); | ||
} | ||
// Send retry prompt | ||
if (!dc.context.responded && isMessage && state.options.retryPrompt) { | ||
yield dc.context.sendActivity(state.options.retryPrompt); | ||
} | ||
return dialog_1.Dialog.EndOfTurn; | ||
} | ||
@@ -184,0 +191,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"description": "A dialog stack based conversation manager for Microsoft BotBuilder.", | ||
"version": "4.10.0-dev.20200808.17e26d0", | ||
"version": "4.10.0-rc0", | ||
"license": "MIT", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
"@types/node": "^10.17.27", | ||
"botbuilder-core": "4.10.0-dev.20200808.17e26d0", | ||
"botbuilder-core": "4.10.0-rc0", | ||
"globalize": "^1.4.2" | ||
@@ -48,3 +48,3 @@ }, | ||
"clean": "erase /q /s .\\lib", | ||
"set-version": "npm version --allow-same-version 4.10.0-dev.20200808.17e26d0", | ||
"set-version": "npm version --allow-same-version 4.10.0-rc0", | ||
"test": "tsc && nyc mocha tests/", | ||
@@ -51,0 +51,0 @@ "test:compat": "api-extractor run --verbose" |
@@ -58,2 +58,12 @@ /** | ||
timeout?: number; | ||
/** | ||
* (Optional) value indicating whether the OAuthPrompt should end upon | ||
* receiving an invalid message. Generally the OAuthPrompt will ignore | ||
* incoming messages from the user during the auth flow, if they are not related to the | ||
* auth flow. This flag enables ending the OAuthPrompt rather than | ||
* ignoring the user's message. Typically, this flag will be set to 'true', but is 'false' | ||
* by default for backwards compatibility. | ||
*/ | ||
endOnInvalidMessage?: boolean; | ||
} | ||
@@ -171,12 +181,18 @@ | ||
public async continueDialog(dc: DialogContext): Promise<DialogTurnResult> { | ||
// Recognize token | ||
const recognized: PromptRecognizerResult<TokenResponse> = await this.recognizeToken(dc); | ||
// Check for timeout | ||
const state: OAuthPromptState = dc.activeDialog.state as OAuthPromptState; | ||
const isMessage: boolean = dc.context.activity.type === ActivityTypes.Message; | ||
const hasTimedOut: boolean = isMessage && (new Date().getTime() > state.expires); | ||
const isTimeoutActivityType: boolean = isMessage | ||
|| this.isTokenResponseEvent(dc.context) | ||
|| this.isTeamsVerificationInvoke(dc.context) | ||
|| this.isTokenExchangeRequestInvoke(dc.context); | ||
// If the incoming Activity is a message, or an Activity Type normally handled by OAuthPrompt, | ||
// check to see if this OAuthPrompt Expiration has elapsed, and end the dialog if so. | ||
const hasTimedOut: boolean = isTimeoutActivityType && (new Date().getTime() > state.expires); | ||
if (hasTimedOut) { | ||
return await dc.endDialog(undefined); | ||
} else { | ||
// Recognize token | ||
const recognized: PromptRecognizerResult<TokenResponse> = await this.recognizeToken(dc); | ||
@@ -204,10 +220,14 @@ if (state.state['attemptCount'] === undefined) { | ||
return await dc.endDialog(recognized.value); | ||
} else { | ||
// Send retry prompt | ||
if (!dc.context.responded && isMessage && state.options.retryPrompt) { | ||
await dc.context.sendActivity(state.options.retryPrompt); | ||
} | ||
} | ||
return Dialog.EndOfTurn; | ||
if (isMessage && this.settings.endOnInvalidMessage) { | ||
return await dc.endDialog(undefined); | ||
} | ||
// Send retry prompt | ||
if (!dc.context.responded && isMessage && state.options.retryPrompt) { | ||
await dc.context.sendActivity(state.options.retryPrompt); | ||
} | ||
return Dialog.EndOfTurn; | ||
} | ||
@@ -534,2 +554,2 @@ } | ||
scope: string; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
962951
0.26%19571
0.17%+ Added
+ Added
- Removed
- Removed
Updated