Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

botbuilder

Package Overview
Dependencies
Maintainers
1
Versions
631
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

botbuilder - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

lib/logger.js

33

lib/bots/ChatConnector.js

@@ -5,2 +5,3 @@ var request = require('request');

var utils = require('../utils');
var logger = require('../logger');
var jwt = require('jsonwebtoken');

@@ -95,2 +96,8 @@ var getPem = require('rsa-pem-from-mod-exp');

};
ChatConnector.prototype.verifyEmulatorToken = function (decodedPayload) {
var now = new Date().getTime() / 1000;
return decodedPayload.appid == this.settings.appId &&
decodedPayload.iss == "https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/" &&
now < decodedPayload.exp && now > decodedPayload.nbf;
};
ChatConnector.prototype.verifyBotFramework = function (req, res) {

@@ -115,4 +122,10 @@ var _this = this;

now > decoded.payload.exp || now < decoded.payload.nbf) {
res.status(403);
res.end();
if (_this.verifyEmulatorToken(decoded.payload)) {
_this.dispatch(req.body, res);
}
else {
logger.error('ChatConnector: receive - invalid token. Check bots app ID & Password.');
res.status(403);
res.end();
}
}

@@ -127,2 +140,3 @@ else {

catch (err) {
logger.error('ChatConnector: receive - invalid token. Check bots app ID & Password.');
res.status(403);

@@ -134,2 +148,3 @@ res.end();

else {
logger.error('ChatConnector: receive - error loading openId config: %s', err.toString());
res.status(500);

@@ -141,2 +156,3 @@ res.end();

else if (isEmulator && !this.settings.appId && !this.settings.appPassword) {
logger.warn(req.body, 'ChatConnector: receive - emulator running without security enabled.');
req.body['useAuth'] = false;

@@ -146,2 +162,3 @@ this.dispatch(req.body, res);

else {
logger.error('ChatConnector: receive - no security token sent. Ensure emulator configured with bots app ID & Password.');
res.status(401);

@@ -162,2 +179,3 @@ res.end();

else {
logger.error('ChatConnector: send - message is missing address or serviceUrl.');
cb(new Error('Message missing address or serviceUrl.'));

@@ -202,5 +220,12 @@ }

}
if (err) {
logger.error('ChatConnector: startConversation - error starting conversation.');
}
done(err, adr);
});
}
else {
logger.error('ChatConnector: startConversation - address is invalid.');
done(new Error('Invalid address.'));
}
};

@@ -328,2 +353,3 @@ ChatConnector.prototype.getData = function (context, callback) {

msg.source = address.channelId;
logger.info(address, 'ChatConnector: message received.');
if (address.serviceUrl) {

@@ -363,2 +389,4 @@ try {

});
delete msg.agent;
delete msg.source;
var path = '/v3/conversations/' + encodeURIComponent(address.conversation.id) + '/activities';

@@ -368,2 +396,3 @@ if (address.id && address.channelId !== 'skype') {

}
logger.info(address, 'ChatConnector: sending message.');
var options = {

@@ -370,0 +399,0 @@ method: 'POST',

2

lib/bots/UniversalBot.js

@@ -374,3 +374,3 @@ var __extends = (this && this.__extends) || function (d, b) {

if (err) {
_this.emitError;
_this.emitError(err);
}

@@ -377,0 +377,0 @@ if (done) {

@@ -0,9 +1,20 @@

exports.channels = {
facebook: 'facebook',
skype: 'skype',
telegram: 'telegram',
kik: 'kik',
email: 'email',
slack: 'slack',
groupme: 'groupme',
sms: 'sms',
emulator: 'emulator'
};
function preferButtons(session, choiceCnt, rePrompt) {
switch (getChannelId(session)) {
case 'facebook':
case 'skype':
case exports.channels.facebook:
case exports.channels.skype:
return (choiceCnt <= 3);
case 'telegram':
case 'kik':
case 'emulator':
case exports.channels.telegram:
case exports.channels.kik:
case exports.channels.emulator:
return true;

@@ -15,5 +26,17 @@ default:

exports.preferButtons = preferButtons;
function getChannelId(session) {
return session.message.address.channelId.toLowerCase();
function getChannelId(addressable) {
var channelId;
if (addressable) {
if (addressable.hasOwnProperty('message')) {
channelId = addressable.message.address.channelId;
}
else if (addressable.hasOwnProperty('address')) {
channelId = addressable.address.channelId;
}
else if (addressable.hasOwnProperty('channelId')) {
channelId = addressable.channelId;
}
}
return channelId ? channelId.toLowerCase() : '';
}
exports.getChannelId = getChannelId;
exports.agent = 'botbuilder';
exports.messageType = 'message';
exports.defaultConnector = '*';
exports.emulatorChannel = 'emulator';
exports.Library = {

@@ -5,0 +6,0 @@ system: 'BotBuilder',

@@ -6,2 +6,3 @@ var ses = require('../Session');

var simple = require('./SimpleDialog');
var logger = require('../logger');
var DialogAction = (function () {

@@ -114,2 +115,3 @@ function DialogAction() {

try {
logger.info(s, 'waterfall() step %d of %d', step, steps.length);
s.dialogData[consts.Data.WaterfallStep] = step;

@@ -128,2 +130,3 @@ steps[step](s, r, skip);

try {
logger.info(s, 'waterfall() step %d of %d', 0, steps.length);
s.dialogData[consts.Data.WaterfallStep] = 0;

@@ -137,2 +140,3 @@ steps[0](s, r, skip);

else {
logger.warn(s, 'waterfall() empty waterfall detected');
s.endDialogWithResult({ resumed: dialog.ResumeReason.notCompleted });

@@ -139,0 +143,0 @@ }

@@ -9,2 +9,3 @@ var __extends = (this && this.__extends) || function (d, b) {

var consts = require('../consts');
var logger = require('../logger');
var async = require('async');

@@ -41,2 +42,3 @@ (function (RecognizeOrder) {

try {
logger.info(session, 'IntentDialog.begin()');
this.beginDialog(session, args, function () {

@@ -234,5 +236,7 @@ _super.prototype.begin.call(_this, session, args);

if (recognizeResult.intent && this.handlers.hasOwnProperty(recognizeResult.intent)) {
logger.info(session, 'IntentDialog.matches(%s)', recognizeResult.intent);
activeIntent = recognizeResult.intent;
}
else if (this.handlers.hasOwnProperty(consts.Intents.Default)) {
logger.info(session, 'IntentDialog.onDefault()');
activeIntent = consts.Intents.Default;

@@ -249,2 +253,5 @@ }

}
else {
logger.warn(session, 'IntentDialog - no intent handler found for %s', recognizeResult.intent);
}
};

@@ -251,0 +258,0 @@ IntentDialog.prototype.emitError = function (session, err) {

@@ -22,3 +22,2 @@ var sprintf = require('sprintf-js');

this.data.agent = consts.agent;
this.data.sourceEvent = {};
if (this.session) {

@@ -25,0 +24,0 @@ var m = this.session.message;

@@ -11,2 +11,3 @@ var __extends = (this && this.__extends) || function (d, b) {

var msg = require('./Message');
var logger = require('./logger');
var Session = (function (_super) {

@@ -58,2 +59,3 @@ __extends(Session, _super);

err = err instanceof Error ? err : new Error(err.toString());
logger.info(this, 'session.error()');
this.endConversation(this.options.dialogErrorMessage || 'Oops. Something went wrong and we need to start over.');

@@ -84,2 +86,3 @@ this.emit('error', err);

Session.prototype.save = function () {
logger.info(this, 'session.save()');
this.startBatch();

@@ -107,2 +110,3 @@ return this;

this.batch.push(m);
logger.info(this, 'session.send()');
}

@@ -116,2 +120,3 @@ this.startBatch();

Session.prototype.beginDialog = function (id, args) {
logger.info(this, 'session.beginDialog(%s)', id);
var id = this.resolveDialogId(id);

@@ -128,2 +133,3 @@ var dialog = this.findDialog(id);

Session.prototype.replaceDialog = function (id, args) {
logger.info(this, 'session.replaceDialog(%s)', id);
var id = this.resolveDialogId(id);

@@ -161,2 +167,3 @@ var dialog = this.findDialog(id);

this.privateConversationData = {};
logger.info(this, 'session.endConversation()');
var ss = this.sessionState;

@@ -196,2 +203,3 @@ ss.callstack = [];

}
logger.info(this, 'session.endDialog()');
var childId = cur.id;

@@ -222,2 +230,3 @@ cur = this.popDialog();

result.childId = cur.id;
logger.info(this, 'session.endDialogWithResult()');
cur = this.popDialog();

@@ -237,2 +246,3 @@ this.startBatch();

Session.prototype.reset = function (dialogId, dialogArgs) {
logger.info(this, 'session.reset()');
this._isReset = true;

@@ -252,2 +262,3 @@ this.sessionState.callstack = [];

var _this = this;
logger.info(this, 'session.sendBatch() sending %d messages', this.batch.length);
if (this.sendingBatch) {

@@ -254,0 +265,0 @@ return;

@@ -5,3 +5,3 @@ {

"description": "Bot Builder is a dialog system for building rich bots on virtually any platform.",
"version": "3.0.0",
"version": "3.0.1",
"license": "MIT",

@@ -8,0 +8,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc