Skip to content

Commit f2c9341

Browse files
committed
Pushed 3.5.1
1 parent a7caca4 commit f2c9341

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

Node/core/lib/bots/ChatConnector.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,32 @@ var async = require('async');
88
var url = require('url');
99
var jwt = require('jsonwebtoken');
1010
var zlib = require('zlib');
11+
var pjson = require('../../package.json');
1112
var MAX_DATA_LENGTH = 65000;
13+
var USER_AGENT = "Microsoft-BotFramework/3.0 (BotBuilder Node.js/" + pjson.version + ")";
1214
var ChatConnector = (function () {
1315
function ChatConnector(settings) {
1416
if (settings === void 0) { settings = {}; }
1517
this.settings = settings;
1618
if (!this.settings.endpoint) {
1719
this.settings.endpoint = {
18-
refreshEndpoint: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
19-
refreshScope: 'https://graph.microsoft.com/.default',
20-
botConnectorOpenIdMetadata: this.settings.openIdMetadata || 'https://api.aps.skype.com/v1/.well-known/openidconfiguration',
20+
refreshEndpoint: 'https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token',
21+
refreshScope: 'https://api.botframework.com/.default',
22+
botConnectorOpenIdMetadata: this.settings.openIdMetadata || 'https://login.botframework.com/v1/.well-known/openidconfiguration',
2123
botConnectorIssuer: 'https://api.botframework.com',
2224
botConnectorAudience: this.settings.appId,
2325
msaOpenIdMetadata: 'https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration',
2426
msaIssuer: 'https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/',
2527
msaAudience: 'https://graph.microsoft.com',
28+
emulatorOpenIdMetadata: 'https://login.microsoftonline.com/botframework.com/v2.0/.well-known/openid-configuration',
29+
emulatorAudience: 'https://sts.windows.net/d6d49420-f39b-4df7-a1dc-d59a935871db/',
30+
emulatorIssuer: this.settings.appId,
2631
stateEndpoint: this.settings.stateEndpoint || 'https://state.botframework.com'
2732
};
2833
}
2934
this.botConnectorOpenIdMetadata = new OpenIdMetadata_1.OpenIdMetadata(this.settings.endpoint.botConnectorOpenIdMetadata);
3035
this.msaOpenIdMetadata = new OpenIdMetadata_1.OpenIdMetadata(this.settings.endpoint.msaOpenIdMetadata);
36+
this.emulatorOpenIdMetadata = new OpenIdMetadata_1.OpenIdMetadata(this.settings.endpoint.emulatorOpenIdMetadata);
3137
}
3238
ChatConnector.prototype.listen = function () {
3339
var _this = this;
@@ -71,6 +77,14 @@ var ChatConnector = (function () {
7177
clockTolerance: 300
7278
};
7379
}
80+
else if (isEmulator && decoded.payload.iss == this.settings.endpoint.emulatorIssuer) {
81+
openIdMetadata = this.emulatorOpenIdMetadata;
82+
verifyOptions = {
83+
issuer: this.settings.endpoint.emulatorIssuer,
84+
audience: this.settings.endpoint.emulatorAudience,
85+
clockTolerance: 300
86+
};
87+
}
7488
else {
7589
openIdMetadata = this.botConnectorOpenIdMetadata;
7690
verifyOptions = {
@@ -79,6 +93,12 @@ var ChatConnector = (function () {
7993
clockTolerance: 300
8094
};
8195
}
96+
if (isEmulator && decoded.payload.appid != this.settings.appId) {
97+
logger.error('ChatConnector: receive - invalid token. Requested by unexpected app ID.');
98+
res.status(403);
99+
res.end();
100+
return;
101+
}
82102
openIdMetadata.getKey(decoded.header.kid, function (key) {
83103
if (key) {
84104
try {
@@ -375,6 +395,7 @@ var ChatConnector = (function () {
375395
this.authenticatedRequest(options, function (err, response, body) { return cb(err); });
376396
}
377397
else {
398+
this.addUserAgent(options);
378399
request(options, function (err, response, body) {
379400
if (!err && response.statusCode >= 400) {
380401
var txt = "Request to '" + options.url + "' failed: [" + response.statusCode + "] " + response.statusMessage;
@@ -459,7 +480,14 @@ var ChatConnector = (function () {
459480
cb(null, this.accessToken);
460481
}
461482
};
483+
ChatConnector.prototype.addUserAgent = function (options) {
484+
if (options.headers == null) {
485+
options.headers = {};
486+
}
487+
options.headers['User-Agent'] = USER_AGENT;
488+
};
462489
ChatConnector.prototype.addAccessToken = function (options, cb) {
490+
this.addUserAgent(options);
463491
if (this.settings.appId && this.settings.appPassword) {
464492
this.getAccessToken(function (err, token) {
465493
if (!err && token) {

Node/core/lib/dialogs/EntityRecognizer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ var EntityRecognizer = (function () {
199199
}
200200
};
201201
EntityRecognizer.dateExp = /^\d{4}-\d{2}-\d{2}/i;
202-
EntityRecognizer.yesExp = /^(1|y|yes|yep|sure|ok|true)/i;
203-
EntityRecognizer.noExp = /^(2|n|no|nope|not|false)/i;
202+
EntityRecognizer.yesExp = /^(1|y|yes|yep|sure|ok|true)(\W|$)/i;
203+
EntityRecognizer.noExp = /^(2|n|no|nope|not|false)(\W|$)/i;
204204
EntityRecognizer.numberExp = /[+-]?(?:\d+\.?\d*|\d*\.?\d+)/;
205205
EntityRecognizer.ordinalWords = 'first|second|third|fourth|fifth|sixth|seventh|eigth|ninth|tenth';
206206
return EntityRecognizer;

Node/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "botbuilder",
33
"author": "Microsoft Corp.",
44
"description": "Bot Builder is a dialog system for building rich bots on virtually any platform.",
5-
"version": "3.5.0-rc9",
5+
"version": "3.5.1",
66
"license": "MIT",
77
"keywords": [
88
"botbuilder",

0 commit comments

Comments
 (0)