botbuilder
Advanced tools
Comparing version 3.5.0-rc9 to 3.5.0
@@ -11,3 +11,5 @@ "use strict"; | ||
var zlib = require('zlib'); | ||
var pjson = require('../../package.json'); | ||
var MAX_DATA_LENGTH = 65000; | ||
var USER_AGENT = "Microsoft-BotFramework/3.0 (BotBuilder Node.js/" + pjson.version + ")"; | ||
var ChatConnector = (function () { | ||
@@ -19,5 +21,5 @@ function ChatConnector(settings) { | ||
this.settings.endpoint = { | ||
refreshEndpoint: 'https://login.microsoftonline.com/common/oauth2/v2.0/token', | ||
refreshScope: 'https://graph.microsoft.com/.default', | ||
botConnectorOpenIdMetadata: this.settings.openIdMetadata || 'https://api.aps.skype.com/v1/.well-known/openidconfiguration', | ||
refreshEndpoint: 'https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token', | ||
refreshScope: 'https://api.botframework.com/.default', | ||
botConnectorOpenIdMetadata: this.settings.openIdMetadata || 'https://login.botframework.com/v1/.well-known/openidconfiguration', | ||
botConnectorIssuer: 'https://api.botframework.com', | ||
@@ -28,2 +30,5 @@ botConnectorAudience: this.settings.appId, | ||
msaAudience: 'https://graph.microsoft.com', | ||
emulatorOpenIdMetadata: 'https://login.microsoftonline.com/botframework.com/v2.0/.well-known/openid-configuration', | ||
emulatorAudience: 'https://sts.windows.net/d6d49420-f39b-4df7-a1dc-d59a935871db/', | ||
emulatorIssuer: this.settings.appId, | ||
stateEndpoint: this.settings.stateEndpoint || 'https://state.botframework.com' | ||
@@ -34,2 +39,3 @@ }; | ||
this.msaOpenIdMetadata = new OpenIdMetadata_1.OpenIdMetadata(this.settings.endpoint.msaOpenIdMetadata); | ||
this.emulatorOpenIdMetadata = new OpenIdMetadata_1.OpenIdMetadata(this.settings.endpoint.emulatorOpenIdMetadata); | ||
} | ||
@@ -78,2 +84,10 @@ ChatConnector.prototype.listen = function () { | ||
} | ||
else if (isEmulator && decoded.payload.iss == this.settings.endpoint.emulatorIssuer) { | ||
openIdMetadata = this.emulatorOpenIdMetadata; | ||
verifyOptions = { | ||
issuer: this.settings.endpoint.emulatorIssuer, | ||
audience: this.settings.endpoint.emulatorAudience, | ||
clockTolerance: 300 | ||
}; | ||
} | ||
else { | ||
@@ -87,2 +101,8 @@ openIdMetadata = this.botConnectorOpenIdMetadata; | ||
} | ||
if (isEmulator && decoded.payload.appid != this.settings.appId) { | ||
logger.error('ChatConnector: receive - invalid token. Requested by unexpected app ID.'); | ||
res.status(403); | ||
res.end(); | ||
return; | ||
} | ||
openIdMetadata.getKey(decoded.header.kid, function (key) { | ||
@@ -384,2 +404,3 @@ if (key) { | ||
else { | ||
this.addUserAgent(options); | ||
request(options, function (err, response, body) { | ||
@@ -469,3 +490,10 @@ if (!err && response.statusCode >= 400) { | ||
}; | ||
ChatConnector.prototype.addUserAgent = function (options) { | ||
if (options.headers == null) { | ||
options.headers = {}; | ||
} | ||
options.headers['User-Agent'] = USER_AGENT; | ||
}; | ||
ChatConnector.prototype.addAccessToken = function (options, cb) { | ||
this.addUserAgent(options); | ||
if (this.settings.appId && this.settings.appPassword) { | ||
@@ -472,0 +500,0 @@ this.getAccessToken(function (err, token) { |
@@ -5,2 +5,3 @@ "use strict"; | ||
skype: 'skype', | ||
msteams: 'msteams', | ||
telegram: 'telegram', | ||
@@ -14,2 +15,3 @@ kik: 'kik', | ||
directline: 'directline', | ||
webchat: 'webchat', | ||
console: 'console' | ||
@@ -26,3 +28,2 @@ }; | ||
case exports.channels.telegram: | ||
case exports.channels.emulator: | ||
return (buttonCnt <= 100); | ||
@@ -39,4 +40,8 @@ default: | ||
case exports.channels.skype: | ||
case exports.channels.msteams: | ||
return (buttonCnt <= 3); | ||
case exports.channels.slack: | ||
case exports.channels.emulator: | ||
case exports.channels.directline: | ||
case exports.channels.webchat: | ||
return (buttonCnt <= 100); | ||
@@ -43,0 +48,0 @@ default: |
@@ -26,3 +26,3 @@ "use strict"; | ||
if (typeof entities == 'string') { | ||
entities = EntityRecognizer.recognizeTime(entities); | ||
entities = [EntityRecognizer.recognizeTime(entities)]; | ||
} | ||
@@ -203,4 +203,4 @@ return EntityRecognizer.resolveTime(entities); | ||
EntityRecognizer.dateExp = /^\d{4}-\d{2}-\d{2}/i; | ||
EntityRecognizer.yesExp = /^(1|y|yes|yep|sure|ok|true)/i; | ||
EntityRecognizer.noExp = /^(2|n|no|nope|not|false)/i; | ||
EntityRecognizer.yesExp = /^(1|y|yes|yep|sure|ok|true)(\W|$)/i; | ||
EntityRecognizer.noExp = /^(2|n|no|nope|not|false)(\W|$)/i; | ||
EntityRecognizer.numberExp = /[+-]?(?:\d+\.?\d*|\d*\.?\d+)/; | ||
@@ -207,0 +207,0 @@ EntityRecognizer.ordinalWords = 'first|second|third|fourth|fifth|sixth|seventh|eigth|ninth|tenth'; |
@@ -27,3 +27,8 @@ "use strict"; | ||
this.recognizers = new IntentRecognizerSet_1.IntentRecognizerSet(options); | ||
this.recognizeMode = options.recognizeMode || RecognizeMode.onBeginIfRoot; | ||
if (typeof options.recognizeMode !== "undefined") { | ||
this.recognizeMode = options.recognizeMode; | ||
} | ||
else { | ||
this.recognizeMode = RecognizeMode.onBeginIfRoot; | ||
} | ||
} | ||
@@ -30,0 +35,0 @@ IntentDialog.prototype.begin = function (session, args) { |
@@ -5,3 +5,3 @@ { | ||
"description": "Bot Builder is a dialog system for building rich bots on virtually any platform.", | ||
"version": "3.5.0-rc9", | ||
"version": "3.5.0", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "keywords": [ |
@@ -44,3 +44,3 @@ # Bot Builder for Node.js | ||
## Test your bot (Windows Only) | ||
## Test your bot | ||
Use the [Bot Framework Emulator](http://docs.botframework.com/connector/tools/bot-framework-emulator/) to test your bot on localhost. | ||
@@ -47,0 +47,0 @@ |
var assert = require('assert'); | ||
var builder = require('../'); | ||
describe('dialogs', function() { | ||
describe('dialogs', function () { | ||
this.timeout(5000); | ||
it('should redirect to another dialog with arguments', function (done) { | ||
var connector = new builder.ConsoleConnector(); | ||
var bot = new builder.UniversalBot(connector); | ||
it('should redirect to another dialog with arguments', function (done) { | ||
var connector = new builder.ConsoleConnector(); | ||
var bot = new builder.UniversalBot(connector); | ||
bot.dialog('/', [ | ||
function (session) { | ||
session.beginDialog('/child', { foo: 'bar' }) | ||
session.beginDialog('/child', { foo: 'bar' }) | ||
}, | ||
@@ -20,3 +20,3 @@ function (session, results) { | ||
assert(args.foo === 'bar'); | ||
session.endDialog({ response: { bar: 'foo' }}); | ||
session.endDialog({ response: { bar: 'foo' } }); | ||
}); | ||
@@ -32,4 +32,4 @@ bot.on('send', function (message) { | ||
var step = 0; | ||
var connector = new builder.ConsoleConnector(); | ||
var bot = new builder.UniversalBot(connector); | ||
var connector = new builder.ConsoleConnector(); | ||
var bot = new builder.UniversalBot(connector); | ||
bot.dialog('/', [ | ||
@@ -89,2 +89,25 @@ function (session) { | ||
}); | ||
it("should process default action for intentDialog onBegin", function (done) { | ||
var connector = new builder.ConsoleConnector(); | ||
var bot = new builder.UniversalBot(connector); | ||
var intentDialog = new builder.IntentDialog({ recognizeMode: builder.RecognizeMode.onBegin }) | ||
.onBegin((session, args, next) => { | ||
session.dialogData.begin = true; | ||
next(); | ||
}) | ||
.onDefault((session) => { | ||
assert(session.dialogData.begin == true); | ||
done(); | ||
}); | ||
bot.dialog('/intentDialog', intentDialog); | ||
bot.dialog('/', function (session) { | ||
session.beginDialog("/intentDialog"); | ||
}); | ||
connector.processMessage("test"); | ||
}) | ||
}); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
439296
9607
1