| (function() { | ||
| var bilby, convert, should; | ||
| bilby = require('bilby'); | ||
| convert = require('./convert'); | ||
| should = require('should'); | ||
| describe('convert', function() { | ||
| describe('toMap()', function() { | ||
| return it('should return a map', function() { | ||
| var map; | ||
| map = convert.toMap(bilby.environment().property('test', 'test')); | ||
| Object.keys(map).length.should.equal(1); | ||
| return map.hasOwnProperty('test').should.be["true"]; | ||
| }); | ||
| }); | ||
| return describe('toEnvironment()', function() { | ||
| return it('should return an environment', function() { | ||
| var environment; | ||
| environment = convert.toEnvironment({ | ||
| test: 'test' | ||
| }); | ||
| Object.keys(environment).length.should.be.above(1); | ||
| return environment.hasOwnProperty('test').should.be["true"]; | ||
| }); | ||
| }); | ||
| }); | ||
| }).call(this); |
| (function() { | ||
| var bilby, convert, truth, _; | ||
| bilby = require('bilby'); | ||
| truth = require('./truth'); | ||
| _ = require('underscore'); | ||
| convert = bilby.environment().method('toMap', (function(environment) { | ||
| return truth.environmenty(environment); | ||
| }), (function(environment) { | ||
| return _.omit(environment, _.chain(environment).map(function(v, k) { | ||
| if (truth.existy(v) && typeof v === 'function') { | ||
| return k; | ||
| } else { | ||
| return null; | ||
| } | ||
| }).filter(function(i) { | ||
| return truth.existy(i); | ||
| }).value()); | ||
| })).method('toEnvironment', (function(map) { | ||
| return truth.existy(map); | ||
| }), (function(map) { | ||
| var fn; | ||
| fn = function(m, e) { | ||
| var key, keys, value; | ||
| keys = Object.keys(m); | ||
| if (keys.length === 0) { | ||
| return e; | ||
| } else { | ||
| key = keys[0]; | ||
| value = m[key]; | ||
| delete m[key]; | ||
| return fn(m, e.property(key, value)); | ||
| } | ||
| }; | ||
| return fn(map, bilby.environment()); | ||
| })); | ||
| module.exports = convert; | ||
| }).call(this); |
| (function() { | ||
| var bilby, truth; | ||
| bilby = require('bilby'); | ||
| truth = bilby.environment().method('environmenty', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.existy(a) && a.hasOwnProperty('method') && a.hasOwnProperty('property'); | ||
| })).method('existy', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return a != null; | ||
| })).method('lengthy', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.truthy(a) && a.hasOwnProperty('length') && a.length > (0 != null); | ||
| })).method('signedOAuthy', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.unsignedOAuthy(a) && a.hasOwnProperty('oauth_signature'); | ||
| })).method('toolcontexty', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.environmenty(a) && a.hasOwnProperty('consumerKey') && a.hasOwnProperty('consumerSecret') && a.hasOwnProperty('utcOffset') && a.hasOwnProperty('host') && a.hasOwnProperty('path') && a.hasOwnProperty('port'); | ||
| })).method('toolparametery', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.environmenty(a) && a.hasOwnProperty('lti_message_type') && a.hasOwnProperty('lti_version') && a.hasOwnProperty('resource_link_id'); | ||
| })).method('toolquerystringy', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.environmenty(a); | ||
| })).method('truthy', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.existy(a) && (a !== false); | ||
| })).method('unsignedOAuthy', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.existy(a) && a.hasOwnProperty('oauth_callback') && a.hasOwnProperty('oauth_consumer_key') && a.hasOwnProperty('oauth_nonce') && a.hasOwnProperty('oauth_timestamp') && a.hasOwnProperty('oauth_signature_method') && a.hasOwnProperty('oauth_version'); | ||
| })); | ||
| module.exports = truth; | ||
| }).call(this); |
| bilby = require('bilby') | ||
| truth = require('./truth') | ||
| _ = require('underscore') | ||
| convert = bilby.environment() | ||
| .method('toMap', | ||
| ((environment) -> truth.environmenty(environment)), | ||
| ((environment) -> _.omit(environment, | ||
| _.chain(environment) | ||
| .map((v, k) -> if (truth.existy(v) and typeof v is 'function') then k else null) | ||
| .filter((i) -> truth.existy(i)) | ||
| .value() | ||
| )) | ||
| ) | ||
| .method('toEnvironment', | ||
| ((map) -> truth.existy(map)), | ||
| ((map) -> | ||
| fn = (m, e) -> | ||
| keys = Object.keys(m) | ||
| if keys.length is 0 then e | ||
| else | ||
| key = keys[0] | ||
| value = m[key] | ||
| delete m[key] | ||
| fn(m, e.property(key, value)) | ||
| fn(map, bilby.environment()) | ||
| ) | ||
| ) | ||
| module.exports = convert |
| bilby = require('bilby') | ||
| truth = bilby.environment() | ||
| .method('environmenty', | ||
| ((a) -> true), | ||
| ((a) -> @existy(a) and a.hasOwnProperty('method') and a.hasOwnProperty('property')) | ||
| ) | ||
| .method('existy', | ||
| ((a) -> true), | ||
| ((a) -> a?) | ||
| ) | ||
| .method('lengthy', | ||
| ((a) -> true), | ||
| ((a) -> @truthy(a) and a.hasOwnProperty('length') and a.length > 0?) | ||
| ) | ||
| .method('signedOAuthy', | ||
| ((a) -> true), | ||
| ((a) -> @unsignedOAuthy(a) and a.hasOwnProperty('oauth_signature')) | ||
| ) | ||
| .method('toolcontexty', | ||
| ((a) -> true), | ||
| ((a) -> | ||
| @environmenty(a) and | ||
| a.hasOwnProperty('consumerKey') and a.hasOwnProperty('consumerSecret') and | ||
| a.hasOwnProperty('utcOffset') and a.hasOwnProperty('host') and | ||
| a.hasOwnProperty('path') and a.hasOwnProperty('port') | ||
| ) | ||
| ) | ||
| .method('toolparametery', | ||
| ((a) -> true), | ||
| ((a) -> | ||
| @environmenty(a) and | ||
| a.hasOwnProperty('lti_message_type') and | ||
| a.hasOwnProperty('lti_version') and | ||
| a.hasOwnProperty('resource_link_id') | ||
| ) | ||
| ) | ||
| .method('toolquerystringy', | ||
| ((a) -> true), | ||
| ((a) -> @environmenty(a)) | ||
| ) | ||
| .method('truthy', | ||
| ((a) -> true), | ||
| ((a) -> @existy(a) and (a isnt false)) | ||
| ) | ||
| .method('unsignedOAuthy', | ||
| ((a) -> true), | ||
| ((a) -> | ||
| @existy(a) and | ||
| a.hasOwnProperty('oauth_callback') and a.hasOwnProperty('oauth_consumer_key') and | ||
| a.hasOwnProperty('oauth_nonce') and a.hasOwnProperty('oauth_timestamp') and | ||
| a.hasOwnProperty('oauth_signature_method') and a.hasOwnProperty('oauth_version') | ||
| ) | ||
| ) | ||
| module.exports = truth |
| bilby = require('bilby') | ||
| convert = require('./convert') | ||
| should = require('should') | ||
| describe('convert', -> | ||
| describe('toMap()', -> | ||
| it('should return a map', -> | ||
| map = convert.toMap(bilby.environment().property('test', 'test')) | ||
| Object.keys(map).length.should.equal(1) | ||
| map.hasOwnProperty('test').should.be.true | ||
| ) | ||
| ) | ||
| describe('toEnvironment()', -> | ||
| it('should return an environment', -> | ||
| environment = convert.toEnvironment(test: 'test') | ||
| Object.keys(environment).length.should.be.above(1) | ||
| environment.hasOwnProperty('test').should.be.true | ||
| ) | ||
| ) | ||
| ) |
@@ -11,10 +11,2 @@ (function() { | ||
| describe('encode', function() { | ||
| describe('defunc()', function() { | ||
| return it('should return a map with keys which had function values removed', function() { | ||
| return Object.keys(encode.defunc({ | ||
| nonfunc: 'nonfunc', | ||
| func: (function(test) {}) | ||
| })).length.should.equal(1); | ||
| }); | ||
| }); | ||
| describe('httpAuthorizationHeader()', function() { | ||
@@ -21,0 +13,0 @@ return it('should return a string representation of an authorization for use in an http header', function() { |
+10
-20
| (function() { | ||
| var bilby, encode, func, _; | ||
| var bilby, convert, encode, truth, _; | ||
| bilby = require('bilby'); | ||
| func = require('./func'); | ||
| convert = require('./convert'); | ||
| truth = require('./truth'); | ||
| _ = require('underscore'); | ||
| encode = bilby.environment().method('defunc', (function(map) { | ||
| return func.existy(map); | ||
| }), (function(map) { | ||
| return _.omit(map, _.chain(map).map(function(v, k) { | ||
| if (func.existy(v) && typeof v === 'function') { | ||
| return k; | ||
| } else { | ||
| return null; | ||
| } | ||
| }).filter(function(i) { | ||
| return func.existy(i); | ||
| }).value()); | ||
| })).method('httpAuthorizationHeader', (function(authorization) { | ||
| return func.signedOAuthy(authorization); | ||
| encode = bilby.environment().method('httpAuthorizationHeader', (function(authorization) { | ||
| return truth.signedOAuthy(authorization); | ||
| }), (function(authorization) { | ||
| var self; | ||
| self = this; | ||
| return _.map(self.defunc(authorization), function(v, k) { | ||
| return _.map((truth.environmenty(authorization) ? convert.toMap(authorization) : authorization), function(v, k) { | ||
| return k + '="' + self.rfc3986(v.toString()) + '"'; | ||
| }).join(','); | ||
| })).method('rfc3986', (function(string) { | ||
| return func.existy(string); | ||
| return truth.existy(string); | ||
| }), (function(string) { | ||
| return encodeURIComponent(string).replace(/!/g, '%21').replace(/\*/g, '%2A').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/'/g, '%27'); | ||
| })).method('url', (function(map) { | ||
| return func.existy(map); | ||
| return truth.existy(map); | ||
| }), (function(map) { | ||
| var self; | ||
| self = this; | ||
| return _.map(self.defunc(map), function(v, k) { | ||
| return _.map((truth.environmenty(map) ? convert.toMap(map) : map), function(v, k) { | ||
| return self.rfc3986(k) + '=' + self.rfc3986(v.toString()); | ||
@@ -41,0 +31,0 @@ }).join('&'); |
| (function() { | ||
| var bilby, encode, func, oauth, oauthsign, _; | ||
| var bilby, convert, oauth, oauthsign, truth, _; | ||
| bilby = require('bilby'); | ||
| encode = require('./encode'); | ||
| convert = require('./convert'); | ||
| func = require('./func'); | ||
| oauthsign = require('oauth-sign'); | ||
| truth = require('./truth'); | ||
| _ = require('underscore'); | ||
| oauth = bilby.environment().property('base64', '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz').property('utcOffset', 0).method('authorization', (function(url, parameters, consumerKey, consumerSecret) { | ||
| return func.existy(url) && func.existy(parameters) && func.existy(consumerKey) && func.existy(consumerSecret); | ||
| return truth.existy(url) && truth.existy(parameters) && truth.existy(consumerKey) && truth.existy(consumerSecret); | ||
| }), (function(url, parameters, consumerKey, consumerSecret) { | ||
@@ -26,3 +26,3 @@ var oauthParameters; | ||
| }; | ||
| return bilby.environment().property('oauth_callback', oauthParameters.oauth_callback).property('oauth_consumer_key', oauthParameters.oauth_consumer_key).property('oauth_nonce', oauthParameters.oauth_nonce).property('oauth_signature', this.sign(url, bilby.extend(parameters, oauthParameters), consumerSecret)).property('oauth_signature_method', oauthParameters.oauth_signature_method).property('oauth_timestamp', oauthParameters.oauth_timestamp).property('oauth_version', oauthParameters.oauth_version); | ||
| return bilby.environment().property('oauth_callback', oauthParameters.oauth_callback).property('oauth_consumer_key', oauthParameters.oauth_consumer_key).property('oauth_nonce', oauthParameters.oauth_nonce).property('oauth_signature', this.sign(url, bilby.extend((truth.environmenty(parameters) ? convert.toMap(parameters) : parameters), oauthParameters), consumerSecret)).property('oauth_signature_method', oauthParameters.oauth_signature_method).property('oauth_timestamp', oauthParameters.oauth_timestamp).property('oauth_version', oauthParameters.oauth_version); | ||
| })).method('nonce', (function() { | ||
@@ -41,7 +41,7 @@ return true; | ||
| })).method('sign', (function(url, parameters, consumerSecret) { | ||
| return func.existy(url) && func.existy(parameters) && func.existy(consumerSecret) && func.unsignedOAuthy(parameters); | ||
| return truth.existy(url) && truth.existy(parameters) && truth.existy(consumerSecret) && truth.unsignedOAuthy(parameters); | ||
| }), (function(url, parameters, consumerSecret) { | ||
| switch (parameters.oauth_signature_method) { | ||
| case 'HMAC-SHA1': | ||
| return oauthsign.hmacsign('POST', url, encode.defunc(parameters), consumerSecret); | ||
| return oauthsign.hmacsign('POST', url, (truth.environmenty(parameters) ? convert.toMap(parameters) : parameters), consumerSecret); | ||
| default: | ||
@@ -48,0 +48,0 @@ throw 'Expected supported signature method.'; |
| (function() { | ||
| var bilby, encode, func, http, oauth, q, toolconsumer, _; | ||
| var bilby, encode, http, oauth, q, toolconsumer, truth, _; | ||
@@ -8,4 +8,2 @@ bilby = require('bilby'); | ||
| func = require('./func'); | ||
| http = require('http'); | ||
@@ -17,6 +15,8 @@ | ||
| truth = require('./truth'); | ||
| _ = require('underscore'); | ||
| toolconsumer = bilby.environment().property('toolcontext', null).method('request', (function(toolparameters, toolquerystring) { | ||
| return func.toolparametery(toolparameters); | ||
| return truth.toolparametery(toolparameters) && (!truth.existy(toolquerystring) || truth.toolquerystringy(toolparameters)); | ||
| }), (function(toolparameters, toolquerystring) { | ||
@@ -26,3 +26,3 @@ var authorization, content, deferred, options, request, url; | ||
| url = (this.toolcontext.port === 443 ? 'https://' : 'http://') + this.toolcontext.host + this.toolcontext.path; | ||
| authorization = oauth.property('utcOffset', func.existy(this.toolcontext.utcOffset) ? this.toolcontext.utcOffset : 0).authorization(url, bilby.extend(toolparameters, (func.toolquerystringy(toolquerystring) ? toolquerystring : {})), this.toolcontext.consumerKey, this.toolcontext.consumerSecret); | ||
| authorization = oauth.property('utcOffset', truth.existy(this.toolcontext.utcOffset) ? this.toolcontext.utcOffset : 0).authorization(url, bilby.extend(toolparameters, (truth.existy(toolquerystring) ? toolquerystring : {})), this.toolcontext.consumerKey, this.toolcontext.consumerSecret); | ||
| content = encode.url(bilby.extend(toolparameters, authorization)); | ||
@@ -40,3 +40,3 @@ options = { | ||
| method: 'POST', | ||
| path: this.toolcontext.path + (func.toolquerystringy(toolquerystring) ? '?' + encode.url(toolquerystring) : ''), | ||
| path: this.toolcontext.path + (truth.toolquerystringy(toolquerystring) ? '?' + encode.url(toolquerystring) : ''), | ||
| port: this.toolcontext.port | ||
@@ -43,0 +43,0 @@ }; |
+1
-1
@@ -29,3 +29,3 @@ { | ||
| }, | ||
| "version": "0.3.2" | ||
| "version": "0.3.3" | ||
| } |
| bilby = require('bilby') | ||
| func = require('./func') | ||
| convert = require('./convert') | ||
| truth = require('./truth') | ||
| _ = require('underscore') | ||
| encode = bilby.environment() | ||
| .method('defunc', | ||
| ((map) -> func.existy(map)), | ||
| ((map) -> _.omit(map, | ||
| _.chain(map) | ||
| .map((v, k) -> if (func.existy(v) and typeof v is 'function') then k else null) | ||
| .filter((i) -> func.existy(i)) | ||
| .value() | ||
| )) | ||
| ) | ||
| .method('httpAuthorizationHeader', | ||
| ((authorization) -> func.signedOAuthy(authorization)), | ||
| ((authorization) -> truth.signedOAuthy(authorization)), | ||
| ((authorization) -> | ||
| self = @ | ||
| _.map(self.defunc(authorization), (v, k) -> k + '="' + self.rfc3986(v.toString()) + '"').join(',')) | ||
| _.map( | ||
| (if truth.environmenty(authorization) then convert.toMap(authorization) else authorization), | ||
| (v, k) -> k + '="' + self.rfc3986(v.toString()) + '"').join(',') | ||
| ) | ||
| ) | ||
| .method('rfc3986', | ||
| ((string) -> func.existy(string)), | ||
| ((string) -> truth.existy(string)), | ||
| ((string) -> encodeURIComponent(string) | ||
@@ -28,8 +23,11 @@ .replace(/!/g, '%21').replace(/\*/g, '%2A').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/'/g, '%27') | ||
| .method('url', | ||
| ((map) -> func.existy(map)), | ||
| ((map) -> truth.existy(map)), | ||
| ((map) -> | ||
| self = @ | ||
| _.map(self.defunc(map), (v, k) -> self.rfc3986(k) + '=' + self.rfc3986(v.toString())).join('&')) | ||
| _.map( | ||
| (if truth.environmenty(map) then convert.toMap(map) else map), | ||
| (v, k) -> self.rfc3986(k) + '=' + self.rfc3986(v.toString())).join('&') | ||
| ) | ||
| ) | ||
| module.exports = encode |
| bilby = require('bilby') | ||
| encode = require('./encode') | ||
| func = require('./func') | ||
| convert = require('./convert') | ||
| oauthsign = require('oauth-sign') | ||
| truth = require('./truth') | ||
| _ = require('underscore') | ||
@@ -12,4 +12,4 @@ | ||
| ((url, parameters, consumerKey, consumerSecret) -> | ||
| func.existy(url) and func.existy(parameters) and | ||
| func.existy(consumerKey) and func.existy(consumerSecret) | ||
| truth.existy(url) and truth.existy(parameters) and | ||
| truth.existy(consumerKey) and truth.existy(consumerSecret) | ||
| ), | ||
@@ -29,3 +29,10 @@ ((url, parameters, consumerKey, consumerSecret) -> | ||
| .property('oauth_nonce', oauthParameters.oauth_nonce) | ||
| .property('oauth_signature', @sign(url, bilby.extend(parameters, oauthParameters), consumerSecret)) | ||
| .property('oauth_signature', @sign( | ||
| url, | ||
| bilby.extend( | ||
| (if truth.environmenty(parameters) then convert.toMap(parameters) else parameters), | ||
| oauthParameters | ||
| ), | ||
| consumerSecret | ||
| )) | ||
| .property('oauth_signature_method', oauthParameters.oauth_signature_method) | ||
@@ -42,8 +49,13 @@ .property('oauth_timestamp', oauthParameters.oauth_timestamp) | ||
| ((url, parameters, consumerSecret) -> | ||
| func.existy(url) and func.existy(parameters) and | ||
| func.existy(consumerSecret) and func.unsignedOAuthy(parameters) | ||
| truth.existy(url) and truth.existy(parameters) and | ||
| truth.existy(consumerSecret) and truth.unsignedOAuthy(parameters) | ||
| ), | ||
| ((url, parameters, consumerSecret) -> switch parameters.oauth_signature_method | ||
| when 'HMAC-SHA1' | ||
| oauthsign.hmacsign('POST', url, encode.defunc(parameters), consumerSecret) | ||
| oauthsign.hmacsign( | ||
| 'POST', | ||
| url, | ||
| (if truth.environmenty(parameters) then convert.toMap(parameters) else parameters), | ||
| consumerSecret | ||
| ) | ||
| else throw 'Expected supported signature method.' | ||
@@ -50,0 +62,0 @@ ) |
| bilby = require('bilby') | ||
| encode = require('./encode') | ||
| func = require('./func') | ||
| http = require('http') | ||
| oauth = require('./oauth') | ||
| q = require('q') | ||
| truth = require('./truth') | ||
| _ = require('underscore') | ||
@@ -13,4 +13,7 @@ | ||
| .method('request', | ||
| ((toolparameters, toolquerystring) -> func.toolparametery(toolparameters)), | ||
| ((toolparameters, toolquerystring) -> | ||
| truth.toolparametery(toolparameters) and | ||
| (not truth.existy(toolquerystring) or truth.toolquerystringy(toolparameters)) | ||
| ), | ||
| ((toolparameters, toolquerystring) -> | ||
| deferred = q.defer() | ||
@@ -22,3 +25,3 @@ | ||
| 'utcOffset', | ||
| if func.existy(@toolcontext.utcOffset) then @toolcontext.utcOffset else 0 | ||
| if truth.existy(@toolcontext.utcOffset) then @toolcontext.utcOffset else 0 | ||
| ).authorization( | ||
@@ -28,3 +31,3 @@ url, | ||
| toolparameters, | ||
| (if func.toolquerystringy(toolquerystring) then toolquerystring else {}) | ||
| (if truth.existy(toolquerystring) then toolquerystring else {}) | ||
| ), | ||
@@ -48,3 +51,3 @@ @toolcontext.consumerKey, | ||
| path: @toolcontext.path + | ||
| if func.toolquerystringy(toolquerystring) then '?' + encode.url(toolquerystring) else '' | ||
| if truth.toolquerystringy(toolquerystring) then '?' + encode.url(toolquerystring) else '' | ||
| port: @toolcontext.port | ||
@@ -51,0 +54,0 @@ request = http.request(options, (response) -> |
@@ -6,7 +6,2 @@ should = require('should') | ||
| describe('encode', -> | ||
| describe('defunc()', -> | ||
| it('should return a map with keys which had function values removed', -> | ||
| Object.keys(encode.defunc(nonfunc: 'nonfunc', func: ((test) ->))).length.should.equal(1) | ||
| ) | ||
| ) | ||
| describe('httpAuthorizationHeader()', -> | ||
@@ -13,0 +8,0 @@ it('should return a string representation of an authorization for use in an http header', -> |
| (function() { | ||
| var bilby, func; | ||
| bilby = require('bilby'); | ||
| func = bilby.environment().method('environmenty', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.existy(a) && a.hasOwnProperty('method') && a.hasOwnProperty('property'); | ||
| })).method('existy', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return a != null; | ||
| })).method('lengthy', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.truthy(a) && a.hasOwnProperty('length') && a.length > (0 != null); | ||
| })).method('signedOAuthy', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.unsignedOAuthy(a) && a.hasOwnProperty('oauth_signature'); | ||
| })).method('toolcontexty', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.environmenty(a) && a.hasOwnProperty('consumerKey') && a.hasOwnProperty('consumerSecret') && a.hasOwnProperty('utcOffset') && a.hasOwnProperty('host') && a.hasOwnProperty('path') && a.hasOwnProperty('port'); | ||
| })).method('toolparametery', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.environmenty(a) && a.hasOwnProperty('lti_message_type') && a.hasOwnProperty('lti_version') && a.hasOwnProperty('resource_link_id'); | ||
| })).method('toolquerystringy', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.environmenty(a); | ||
| })).method('truthy', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.existy(a) && (a !== false); | ||
| })).method('unsignedOAuthy', (function(a) { | ||
| return true; | ||
| }), (function(a) { | ||
| return this.existy(a) && a.hasOwnProperty('oauth_callback') && a.hasOwnProperty('oauth_consumer_key') && a.hasOwnProperty('oauth_nonce') && a.hasOwnProperty('oauth_timestamp') && a.hasOwnProperty('oauth_signature_method') && a.hasOwnProperty('oauth_version'); | ||
| })); | ||
| module.exports = func; | ||
| }).call(this); |
| bilby = require('bilby') | ||
| func = bilby.environment() | ||
| .method('environmenty', | ||
| ((a) -> true), | ||
| ((a) -> @existy(a) and a.hasOwnProperty('method') and a.hasOwnProperty('property')) | ||
| ) | ||
| .method('existy', | ||
| ((a) -> true), | ||
| ((a) -> a?) | ||
| ) | ||
| .method('lengthy', | ||
| ((a) -> true), | ||
| ((a) -> @truthy(a) and a.hasOwnProperty('length') and a.length > 0?) | ||
| ) | ||
| .method('signedOAuthy', | ||
| ((a) -> true), | ||
| ((a) -> @unsignedOAuthy(a) and a.hasOwnProperty('oauth_signature')) | ||
| ) | ||
| .method('toolcontexty', | ||
| ((a) -> true), | ||
| ((a) -> | ||
| @environmenty(a) and | ||
| a.hasOwnProperty('consumerKey') and a.hasOwnProperty('consumerSecret') and | ||
| a.hasOwnProperty('utcOffset') and a.hasOwnProperty('host') and | ||
| a.hasOwnProperty('path') and a.hasOwnProperty('port') | ||
| ) | ||
| ) | ||
| .method('toolparametery', | ||
| ((a) -> true), | ||
| ((a) -> | ||
| @environmenty(a) and | ||
| a.hasOwnProperty('lti_message_type') and | ||
| a.hasOwnProperty('lti_version') and | ||
| a.hasOwnProperty('resource_link_id') | ||
| ) | ||
| ) | ||
| .method('toolquerystringy', | ||
| ((a) -> true), | ||
| ((a) -> @environmenty(a)) | ||
| ) | ||
| .method('truthy', | ||
| ((a) -> true), | ||
| ((a) -> @existy(a) and (a isnt false)) | ||
| ) | ||
| .method('unsignedOAuthy', | ||
| ((a) -> true), | ||
| ((a) -> | ||
| @existy(a) and | ||
| a.hasOwnProperty('oauth_callback') and a.hasOwnProperty('oauth_consumer_key') and | ||
| a.hasOwnProperty('oauth_nonce') and a.hasOwnProperty('oauth_timestamp') and | ||
| a.hasOwnProperty('oauth_signature_method') and a.hasOwnProperty('oauth_version') | ||
| ) | ||
| ) | ||
| module.exports = func |
39752
7.94%41
10.81%491
10.09%