New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bespoken-tools

Package Overview
Dependencies
Maintainers
2
Versions
311
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bespoken-tools - npm Package Compare versions

Comparing version 0.8.2 to 0.8.4

coverage/lcov-report/lib/logless/index.html

45

docs/tutorials/tutorial_bst_emulator_nodejs.md

@@ -126,22 +126,27 @@ This tutorial shows you how to get started using our BST Alexa emulator with Node.js and Javascript.

```
it('Plays And Goes To Next', function (done) {
// Open the skill directly with a 'Play' intent
it('Plays To Completion', function (done) {
alexa.spoken('Play', function (error, payload) {
// Confirms the correct directive is returned when the Intent is spoken
assert.equal(payload.response.directives[0].type, 'AudioPlayer.Play');
// We want to make sure playback started
// This request comes from the Alexa service AFTER the AudioPlayer.Play directive is received
// Once gets triggered a single time when the specified event occurs
alexa.once('AudioPlayer.PlaybackStarted', function (audioItem) {
assert.equal(audioItem.stream.url, 'https://traffic.libsyn.com/bespoken/TIP103.mp3?dest-id=432208')
done();
});
// Emulate the user saying 'Next'
alexa.intended('AMAZON.NextIntent', null, function (error, response) {
// Emulates the track being played 'NearlyFinished'
// Alexa sends this event at some point during track playback
// Our skill uses the opportunity to queue up the next track to play
alexa.playbackNearlyFinished(function (error, payload) {
assert.equal(payload.response.directives[0].type, 'AudioPlayer.Play');
assert.equal(payload.response.directives[0].audioItem.stream.token, '1');
assert.equal(payload.response.directives[0].playBehavior, 'ENQUEUE');
assert.equal(payload.response.directives[0].audioItem.stream.url, 'https://traffic.libsyn.com/bespoken/TIP104.mp3?dest-id=432208');
});
// Emulates the track playing to completion
// The callback is invoked after the skill responds to the PlaybackFinished request
alexa.playbackFinished(function (error, payload) {
// Confirm there are no directives in the reply to the PlaybackFinished request
// They came on the PlaybackNearlyFinished call
assert(!payload.response.directives);
// Check that playback started on the next track
alexa.once('AudioPlayer.PlaybackStarted', function(audioItem) {
assert.equal(audioItem.stream.token, '1');
assert.equal(audioItem.stream.url, 'https://traffic.libsyn.com/bespoken/TIP104.mp3?dest-id=432208');
done();
});
});
});

@@ -154,10 +159,12 @@ });

The Alexa service first sends a 'AudioPlayer.PlaybackNearlyFinished' request to the skill.
This request is frequently used by skills to enqueue the next AudioItem in the queue for playback on the device.
The Alexa service first calls [BSTAlexa#playbackNearlyFinished()](http://docs.bespoken.tools/en/latest/api/classes/bstalexa.html#playbacknearlyfinished).
This request is triggered by the Alexa service when a track is almost done playing, and is frequently used by skills to enqueue the next AudioItem in the queue for playback on the device.
The Alexa service then sends a 'AudioPlayer.PlaybackFinished' request to the skill, which we expect to then trigger the playback of the next track in the queue.
We also use the [BSTAlexa#on() listener](http://docs.bespoken.tools/en/latest/api/classes/bstalexa.html#on) - this allows us to listen for specific events occurring within the Alexa emulator.
We also use the [BSTAlexa#once() listener](http://docs.bespoken.tools/en/latest/api/classes/bstalexa.html#once) - this allows us to listen for specific events occurring within the Alexa emulator.
In this case, we want to confirm that the next track was queued correctly and has begun playing.
We use the once call to indicate we only want to receive this event the first time it happens. This is useful for watching on events like PlaybackStarted, which are likely to happen many times in the course of an interaction.
The events that can be listened for are listed [here](../api/classes/bstalexaevents.html).

@@ -164,0 +171,0 @@

@@ -29,3 +29,3 @@ "use strict";

let chunked = this.hasHeader("Transfer-Encoding") && this.header("Transfer-Encoding").toLowerCase() === "chunked";
if (chunked) {
if (chunked && this._rawBody !== undefined) {
let chunks = this.parseChunks();

@@ -32,0 +32,0 @@ if (chunks !== null && chunks.length > 0 && chunks[chunks.length - 1].lastChunk()) {

@@ -54,3 +54,3 @@

let chunked = this.hasHeader("Transfer-Encoding") && this.header("Transfer-Encoding").toLowerCase() === "chunked";
if (chunked) {
if (chunked && this._rawBody !== undefined) {
let chunks = this.parseChunks();

@@ -57,0 +57,0 @@ // Only store the chunks if they are finalized

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

"private": false,
"version": "0.8.2",
"version": "0.8.4",
"bin": {

@@ -43,10 +43,11 @@ "bst": "./bin/bst.js",

"lint": "tslint lib/**/*.ts && tslint test/**/*.ts && tslint bin/*.ts",
"preversion": "npm run typedoc && git add docs/api && git commit -m 'Updated generated API docs'",
"postversion": "git push && git push --tags",
"pretest": "typings install && tsc && npm run lint",
"coverage": "typings install && tsc && istanbul cover _mocha test/**/*-test.js -- -R spec && remap-istanbul -i ./coverage/coverage.json -o ./coverage/ts-report -t html && ./node_modules/.bin/remap-istanbul -i coverage/coverage.json -t lcovonly > coverage/lcov-ts.info",
"test": "mocha test/**/*-test.js",
"precoverage": "typings install && tsc && npm run lint",
"coverage": "istanbul cover _mocha test/**/*-test.js -- -R spec && remap-istanbul -i ./coverage/coverage.json -o ./coverage/ts-report -t html && ./node_modules/.bin/remap-istanbul -i coverage/coverage.json -t lcovonly > coverage/lcov-ts.info",
"coveralls": "npm run coverage && coveralls < coverage/lcov-ts.info",
"test": "mocha test/**/*-test.js",
"typedoc": "typedoc --excludePrivate --excludeNotExported --excludeExternals --readme docs/api_readme.md --out docs/api --name 'Bespoken Tools' --mode file lib/client/bst-alexa.ts lib/client/lambda-server.ts lib/alexa/audio-item.ts"
"typedoc": "typedoc --excludePrivate --excludeNotExported --excludeExternals --readme docs/api_readme.md --out docs/api --name 'Bespoken Tools' --mode file lib/client/bst-alexa.ts lib/client/lambda-server.ts lib/alexa/audio-item.ts",
"preversion": "npm run typedoc && git add docs/api && git commit -m 'Updated generated API docs'",
"postversion": "git push && git push --tags"
}
}

@@ -8,3 +8,2 @@ /// <reference path="../../typings/index.d.ts" />

import * as sinon from "sinon";
import {AudioItem} from "../../lib/alexa/audio-item";

@@ -11,0 +10,0 @@ describe("BSTAlexa", function() {

@@ -38,2 +38,17 @@ "use strict";

});
it("Chunked payload, headers and body split", function (done) {
let headers = buffer_util_1.BufferUtil.fromString("POST /test?this=1 HTTP/1.1\r\nContent-Type: application/json; charset=utf-8\r\nTransfer-Encoding: chunked\r\n\r\n");
let body = buffer_util_1.BufferUtil.fromString("a\r\n1234567890\r\n0\r\n\r\n");
let httpBuffer = new http_buffer_1.HTTPBuffer();
httpBuffer.append(headers);
httpBuffer.complete();
httpBuffer.append(body);
assert(httpBuffer.complete());
assert(httpBuffer.hasHeader("Content-Type"));
assert.equal(httpBuffer.body(), "1234567890");
assert.equal(httpBuffer.statusCode(), undefined);
assert.equal(httpBuffer.method(), "POST");
assert.equal(httpBuffer.uri(), "/test?this=1");
done();
});
it("Advanced chunked payload", function (done) {

@@ -40,0 +55,0 @@ let data = buffer_util_1.BufferUtil.fromString("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nDate: Fri, 02 Sep 2016 18:09:26 GMT\r\nConnection: keep-alive\r\nTransfer-Encoding: chunked\r\n\r\n252\r\n{\"version\":\"1.0\",\"response\":{\"shouldEndSession\":true,\"card\":{\"type\":\"Simple\",\"title\":\"Playing Episode 140\",\"content\":\"Playing Episode 140\"},\"directives\":[{\"type\":\"AudioPlayer.Play\",\"playBehavior\":\"REPLACE_ALL\",\"audioItem\":{\"stream\":{\"url\":\"https://feeds.soundcloud.com/stream/275202399-amazon-web-services-306355661-amazon-web-services.mp3\",\"token\":\"0\",\"expectedPreviousToken\":null,\"offsetInMilliseconds\":0}}}]},\"sessionAttributes\":{\"playOrder\":[0,1,2,3,4,5],\"index\":0,\"offsetInMilliseconds\":0,\"loop\":true,\"shuffle\":false,\"playbackIndexChanged\":false,\"enqueuedToken\":null,\"STATE\":\"_PLAY_MODE\"}}\r\n0\r\n\r\n");

@@ -46,2 +46,22 @@ /// <reference path="../../typings/index.d.ts" />

it("Chunked payload, headers and body split", function (done) {
// I would not expect this test to be necessary, but this happened
// A payload came in two parts, exactly split between header and body
// In this case, the header is defined, but no body yet, and that ends up in an undefined error!
let headers = BufferUtil.fromString("POST /test?this=1 HTTP/1.1\r\nContent-Type: application/json; charset=utf-8\r\nTransfer-Encoding: chunked\r\n\r\n");
let body = BufferUtil.fromString("a\r\n1234567890\r\n0\r\n\r\n");
let httpBuffer = new HTTPBuffer();
httpBuffer.append(headers);
httpBuffer.complete();
httpBuffer.append(body);
assert(httpBuffer.complete());
assert(httpBuffer.hasHeader("Content-Type"));
assert.equal(httpBuffer.body(), "1234567890");
assert.equal(httpBuffer.statusCode(), undefined);
assert.equal(httpBuffer.method(), "POST");
assert.equal(httpBuffer.uri(), "/test?this=1");
done();
});
it("Advanced chunked payload", function (done) {

@@ -48,0 +68,0 @@ // Got this directly from actual sniffing of payloads

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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