Sign In

lti

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lti - npm Package Compare versions

Comparing version
0.3.3
to
0.3.4
+15
-2
build/lib/toolconsumer-test.js

@@ -13,4 +13,4 @@ (function() {

describe('toolconsumer', function() {
return describe('request(), a multimethod, without toolcontext', function() {
return it('should return an option monad holding the response', function(done) {
return describe('request()', function() {
it('should return an option monad holding the response when passed bilby environment(s)', function(done) {
var context, params;

@@ -25,2 +25,15 @@ params = require('./toolparameters').property('resource_link_id', '0');

});
return it('should return an option monad holding the response when passed map(s)', function(done) {
var context;
context = require('./toolcontext').property('consumerKey', config.consumerKey).property('consumerSecret', config.consumerSecret).property('host', config.host).property('path', config.path).property('port', config.port);
return (toolconsumer.property('toolcontext', context)).request({
lti_version: 'LTI-1p0',
lti_message_type: 'basic-lti-launch-request',
resource_link_id: '0'
}).then(function(response) {
response.isSome.should.be["true"];
response.getOrElse('').indexOf('Context Information:').should.be.above(-1);
return done();
});
});
});

@@ -27,0 +40,0 @@ });

(function() {
var bilby, encode, http, oauth, q, toolconsumer, truth, _;
var bilby, convert, encode, friendlytoolconsumer, http, oauth, q, toolconsumer, truth, _;
bilby = require('bilby');
convert = require('./convert');
encode = require('./encode');

@@ -58,4 +60,14 @@

module.exports = toolconsumer;
friendlytoolconsumer = toolconsumer.method('request', (function(toolparameters, toolquerystring) {
return !truth.toolparametery(toolparameters) && (!truth.existy(toolquerystring) || !truth.toolquerystringy(toolparameters));
}), (function(toolparameters, toolquerystring) {
if (truth.existy(toolquerystring)) {
return bilby.bind(toolconsumer.request)(this, convert.toEnvironment(toolparameters), convert.toEnvironment(toolquerystring))();
} else {
return bilby.bind(toolconsumer.request)(this, convert.toEnvironment(toolparameters))();
}
}));
module.exports = friendlytoolconsumer;
}).call(this);
+14
-18

@@ -5,20 +5,16 @@ module.exports = (grunt) ->

coffee:
core: files: [
{
expand: true
cwd: 'source/core/coffeescript/'
src: ['**/*.coffee']
dest: 'build/'
ext: '.js'
}
]
test: files: [
{
expand: true
cwd: 'source/test/coffeescript/'
src: ['**/*.coffee']
dest: 'build/'
ext: '.js'
}
]
core: files: [{
expand: true
cwd: 'source/core/coffeescript/'
src: ['**/*.coffee']
dest: 'build/'
ext: '.js'
}]
test: files: [{
expand: true
cwd: 'source/test/coffeescript/'
src: ['**/*.coffee']
dest: 'build/'
ext: '.js'
}]
copy: test: files: ['build/etc/toolconsumer-test.config.json': 'resource/test/json/etc/toolconsumer-test.config.json']

@@ -25,0 +21,0 @@ cafemocha:

@@ -29,3 +29,3 @@ {

},
"version": "0.3.3"
"version": "0.3.4"
}

@@ -21,3 +21,2 @@ #lti.js [![Build Status](https://travis-ci.org/rockymadden/lti.js.png?branch=master)](http://travis-ci.org/rockymadden/lti.js)

* __Tool Contexts:__ Tool contexts are immutable structures made up of the consumer key, consumer/shared secret, host, path, port (default: 443), and UTC offset (default: 0). It is unusual for contexts to change per request, but it is possible depending upon the tool provider. If new contexts are needed, create a base context. This will provide lens-like behavior in which new contexts only need to specify what is different. See [bilby.js](http://bilby.brianmckenna.org/#environment) for more information.
* __Tool Parameters:__ Tool parameters are immutable structures made up of, at minimum, lti\_message\_type (default: basic-lti-launch-request), lti\_version (default: LTI-1p0), and resource\_link\_id. It is very likely for parameters to change per request. If numerous parameters are needed, create a stable base. This will provide lens-like behavior in which new parameters only need to specify what is different. See [bilby.js](http://bilby.brianmckenna.org/#environment) for more information.
* __Tool Consumers:__ Tool consumers allow you to issue one or more asynchronous requests and handle the response(s). Responses return Q based promises. Each contains an option monad. See [Q](https://github.com/kriskowal/q) and [bilby.js](http://bilby.brianmckenna.org/#option) for more information.

@@ -36,5 +35,10 @@

context.withSession((consumer) ->
parameters =
lti_version: 'LTI-1p0'
lti_message_type: 'basic-lti-launch-request'
resource_link_id: '0'
# Simple one-off request, we could also make a large array of promises and asynchronously
# execute all of them. Check out: https://github.com/kriskowal/q/wiki/API-Reference#promiseall
consumer.request(lti.ToolParameters.property('resource_link_id', '1234567890'))
consumer.request(parameters)
.then((response) -> response.map((r) -> console.dir(r)))

@@ -41,0 +45,0 @@ .catch((error) -> console.log(error))

@@ -41,6 +41,9 @@ bilby = require('bilby')

)
.method('nonce', (-> true), (->
self = @
_.map([0..31], -> self.base64[Math.floor(Math.random() * self.base64.length)]).join('')
))
.method('nonce',
(-> true),
(->
self = @
_.map([0..31], -> self.base64[Math.floor(Math.random() * self.base64.length)]).join('')
)
)
.method('sign',

@@ -47,0 +50,0 @@ ((url, parameters, consumerSecret) ->

bilby = require('bilby')
convert = require('./convert')
encode = require('./encode')

@@ -64,2 +65,20 @@ http = require('http')

module.exports = toolconsumer
friendlytoolconsumer = toolconsumer
.method('request',
((toolparameters, toolquerystring) ->
not truth.toolparametery(toolparameters) and
(not truth.existy(toolquerystring) or not truth.toolquerystringy(toolparameters))
),
((toolparameters, toolquerystring) ->
if truth.existy(toolquerystring)
bilby.bind(toolconsumer.request)(
@,
convert.toEnvironment(toolparameters),
convert.toEnvironment(toolquerystring)
)()
else
bilby.bind(toolconsumer.request)(@, convert.toEnvironment(toolparameters))()
)
)
module.exports = friendlytoolconsumer

@@ -7,4 +7,3 @@ bilby = require('bilby')

.property('consumerSecret', null)
# In hours, positive or negative.
.property('utcOffset', 0)
.property('utcOffset', 0) # In hours, positive or negative.
.property('host', null)

@@ -11,0 +10,0 @@ .property('path', null)

@@ -7,4 +7,4 @@ config = require('../etc/toolconsumer-test.config')

describe('toolconsumer', ->
describe('request(), a multimethod, without toolcontext', ->
it('should return an option monad holding the response', (done) ->
describe('request()', ->
it('should return an option monad holding the response when passed bilby environment(s)', (done) ->
params = require('./toolparameters').property('resource_link_id', '0')

@@ -24,3 +24,22 @@ context = require('./toolcontext')

)
it('should return an option monad holding the response when passed map(s)', (done) ->
context = require('./toolcontext')
.property('consumerKey', config.consumerKey)
.property('consumerSecret', config.consumerSecret)
.property('host', config.host)
.property('path', config.path)
.property('port', config.port)
(toolconsumer.property('toolcontext', context))
.request(
lti_version: 'LTI-1p0'
lti_message_type: 'basic-lti-launch-request'
resource_link_id: '0'
).then((response) ->
response.isSome.should.be.true
response.getOrElse('').indexOf('Context Information:').should.be.above(-1)
done()
)
)
)
)

Sorry, the diff of this file is not supported yet