Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return __awaiter(this, void 0, void 0, function* () {
// Ensure prompts have input hint set
const opt = Object.assign({}, options);
if (opt.prompt && typeof opt.prompt === 'object' && typeof opt.prompt.inputHint !== 'string') {
opt.prompt.inputHint = botbuilder_core_1.InputHints.ExpectingInput;
}
if (opt.retryPrompt && typeof opt.retryPrompt === 'object' && typeof opt.retryPrompt.inputHint !== 'string') {
opt.retryPrompt.inputHint = botbuilder_core_1.InputHints.ExpectingInput;
}
// Initialize prompt state
const state = dc.activeDialog.state;
state.options = opt;
state.state = {};
// Send initial prompt
yield this.onPrompt(dc.context, state.state, state.options, false);
return dialog_1.Dialog.EndOfTurn;
});
}
return __awaiter(this, void 0, void 0, function* () {
// Ensure prompts have input hint set
const o = Object.assign({}, options);
if (o.prompt && typeof o.prompt === 'object' && typeof o.prompt.inputHint !== 'string') {
o.prompt.inputHint = botbuilder_core_1.InputHints.ExpectingInput;
}
if (o.retryPrompt && typeof o.retryPrompt === 'object' && typeof o.retryPrompt.inputHint !== 'string') {
o.retryPrompt.inputHint = botbuilder_core_1.InputHints.ExpectingInput;
}
// Initialize prompt state
const timeout = typeof this.settings.timeout === 'number' ? this.settings.timeout : 54000000;
const state = dc.activeDialog.state;
state.state = {};
state.options = o;
state.expires = new Date().getTime() + timeout;
// Attempt to get the users token
const output = yield this.getUserToken(dc.context);
if (output !== undefined) {
// Return token
return yield dc.end(output);
}
else {
// Prompt user to login
yield this.sendOAuthCardAsync(dc.context, state.options.prompt);
return __awaiter(this, void 0, void 0, function* () {
// Ensure prompts have input hint set
const opt = Object.assign({}, options);
if (opt.prompt && typeof opt.prompt === 'object' && typeof opt.prompt.inputHint !== 'string') {
opt.prompt.inputHint = botbuilder_core_1.InputHints.ExpectingInput;
}
if (opt.retryPrompt && typeof opt.retryPrompt === 'object' && typeof opt.retryPrompt.inputHint !== 'string') {
opt.retryPrompt.inputHint = botbuilder_core_1.InputHints.ExpectingInput;
}
// Initialize prompt state
const state = dc.activeDialog.state;
state.options = opt;
state.state = {};
// Send initial prompt
yield this.onPrompt(dc.context, state.state, state.options);
return dialog_1.Dialog.EndOfTurn;
});
}
return __awaiter(this, void 0, void 0, function* () {
if (isRetry && options.retryPrompt) {
yield context.sendActivity(options.retryPrompt, undefined, botbuilder_core_1.InputHints.ExpectingInput);
}
else if (options.prompt) {
yield context.sendActivity(options.prompt, undefined, botbuilder_core_1.InputHints.ExpectingInput);
}
});
}
return __awaiter(this, void 0, void 0, function* () {
if (isRetry && options.retryPrompt) {
yield context.sendActivity(options.retryPrompt, undefined, botbuilder_core_1.InputHints.ExpectingInput);
}
else if (options.prompt) {
yield context.sendActivity(options.prompt, undefined, botbuilder_core_1.InputHints.ExpectingInput);
}
});
}
return __awaiter(this, void 0, void 0, function* () {
if (isRetry && options.retryPrompt) {
yield context.sendActivity(options.retryPrompt, undefined, botbuilder_core_1.InputHints.ExpectingInput);
}
else if (options.prompt) {
yield context.sendActivity(options.prompt, undefined, botbuilder_core_1.InputHints.ExpectingInput);
}
});
}
return __awaiter(this, void 0, void 0, function* () {
if (isRetry && options.retryPrompt) {
yield context.sendActivity(options.retryPrompt, undefined, botbuilder_core_1.InputHints.ExpectingInput);
}
else if (options.prompt) {
yield context.sendActivity(options.prompt, undefined, botbuilder_core_1.InputHints.ExpectingInput);
}
});
}