New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.11.0 to 3.12.0

3

lib/bots/ChatConnector.js

@@ -15,2 +15,3 @@ "use strict";

var USER_AGENT = "Microsoft-BotFramework/3.1 (BotBuilder Node.js/" + pjson.version + ")";
var StateApiDreprecatedMessage = "The Bot State API is deprecated. Please refer to https://aka.ms/I6swrh for details on how to replace with your own storage.";
var ChatConnector = (function () {

@@ -268,2 +269,3 @@ function ChatConnector(settings) {

try {
console.warn(StateApiDreprecatedMessage);
var root = this.getStoragePath(context.address);

@@ -348,2 +350,3 @@ var list = [];

var _this = this;
console.warn(StateApiDreprecatedMessage);
var list = [];

@@ -350,0 +353,0 @@ function addWrite(field, botData, url) {

@@ -179,9 +179,31 @@ "use strict";

else {
var matched = '';
var matched = {};
tokens.forEach(function (token) {
if (value.indexOf(token) >= 0) {
matched += token;
if (!matched[token]) {
matched[token] = 1;
}
}
});
score = matched.length / value.length;
var tokenizedValue = value.split(' ');
var tokenScore = 0;
for (var token in matched) {
tokenizedValue.forEach(function (val) {
if (val.indexOf(token) >= 0 && token.length <= val.length / 2) {
matched[token]--;
}
else if (val.indexOf(token) == -1) {
}
else {
matched[token]++;
}
});
}
for (var token in matched) {
if (matched[token] > 0) {
tokenScore += token.length;
}
}
score = tokenScore / value.length;
score = score > 1 ? 1 : score;
}

@@ -188,0 +210,0 @@ if (score >= threshold) {

@@ -25,4 +25,12 @@ "use strict";

_this.onRecognize(function (context, cb) {
if (context.message.text && !_this.features.disableRecognizer) {
cb(null, _this.features.recognizeScore, context.message.text);
var text = context.message.text;
if (text && !_this.features.disableRecognizer) {
var options = context.dialogData.options;
if ((options.minLength && text.length < Number(options.minLength)) ||
(options.maxLength && text.length > Number(options.maxLength))) {
cb(null, 0.0);
}
else {
cb(null, _this.features.recognizeScore, text);
}
}

@@ -33,2 +41,28 @@ else {

});
_this.onFormatMessage(function (session, text, speak, callback) {
var context = session.dialogData;
var options = context.options;
var turnZero = context.turns === 0 || context.isReprompt;
var message = session.message.text;
if (!turnZero && (options.minLength || options.maxLength)) {
var errorPrompt;
if (options.minLength && message.length < Number(options.minLength)) {
errorPrompt = 'text_minLength_error';
}
else if (options.maxLength && message.length > Number(options.maxLength)) {
errorPrompt = 'text_maxLength_error';
}
if (errorPrompt) {
var text_1 = Prompt_1.Prompt.gettext(session, errorPrompt, consts.Library.system);
var msg = { text: session.gettext(text_1, options) };
callback(null, msg);
}
else {
callback(null, null);
}
}
else {
callback(null, null);
}
});
_this.matches(consts.Intents.Repeat, function (session) {

@@ -35,0 +69,0 @@ session.dialogData.turns = 0;

4

lib/locale/en/BotBuilder.json

@@ -22,4 +22,6 @@ {

"number_integer_error": "The number you entered was not an integer. Please enter a number without a decimal mark.",
"text_minLength_error": "The text you entered was below the minimum allowed length of %(minLength)d. Please enter a valid text.",
"text_maxLength_error": "The text you entered was above the maximum allowed length of %(maxLength)d. Please enter a valid text.",
"yesExp": "^(1|y|yes|yep|sure|ok|true)(\\W|$)",
"noExp": "^(2|n|no|nope|not|false)(\\W|$)"
}
}

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

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

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

@@ -107,5 +107,64 @@ var assert = require('assert');

});
connector.processMessage("test");
})
});
it('should process a waterfall of text prompts with maxLength and minLength requirements', function (done) {
var step = 0;
var connector = new builder.ConsoleConnector();
var bot = new builder.UniversalBot(connector);
bot.dialog('/', [
function (session, results) {
assert(session.message.text == 'start');
builder.Prompts.text(session, 'enter at least 3 characters', { minLength: 3 });
},
function (session, results) {
assert(session.message.text == 'three');
builder.Prompts.text(session, 'enter at less than 7 characters', { maxLength: 7 });
},
function (session, results) {
assert(session.message.text == 'seven');
builder.Prompts.text(session, 'do not enter more than 7 characters', { maxLength: 7 });
},
function (session, results) {
assert(session.message.text == 'seven');
builder.Prompts.text(session, 'do not enter less than 3 characters', { minLength: 3 });
},
function (session, results) {
assert(session.message.text == 'two');
session.send('done');
}
]);
bot.on('send', function (message) {
switch (++step) {
case 1:
assert(message.text == 'enter at least 3 characters');
connector.processMessage('three');
break;
case 2:
connector.processMessage('seven');
break;
case 3:
connector.processMessage('seven characters');
break;
case 4:
var re = /The text you entered was above the maximum allowed length of 7\. Please enter a valid text\./
assert(re.test(message.text))
connector.processMessage('seven');
break;
case 5:
connector.processMessage('2');
break;
case 6:
var re = /The text you entered was below the minimum allowed length of 3\. Please enter a valid text\./
assert(re.test(message.text))
connector.processMessage('two');
break;
case 7:
assert(message.text == 'done');
done();
break;
}
});
connector.processMessage('start');
});
});

Sorry, the diff of this file is too big to display

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