@compassdigital/provider
Advanced tools
Comparing version 0.3.5 to 0.4.0
@@ -248,5 +248,5 @@ 'use strict'; | ||
{ | ||
return { | ||
return { | ||
context: jsonrpc && jsonrpc.id && | ||
( jsonrpc.id.toString().split(".").length === 3 || jsonrpc.id == "SECURITY_TOKEN" ) | ||
this.auth.is_access_token_valid_quick(jsonrpc.id) | ||
? this.context.bind(this, jsonrpc.id) : undefined | ||
@@ -253,0 +253,0 @@ } |
{ | ||
"name": "@compassdigital/provider", | ||
"version": "0.3.5", | ||
"version": "0.4.0", | ||
"description": "", | ||
@@ -12,3 +12,3 @@ "main": "index.js", | ||
"jayson": "^2.0.4", | ||
"jwt-kms": "^1.0.2", | ||
"jwt-kms": "^1.1.0", | ||
"should": "^11.2.1", | ||
@@ -28,3 +28,3 @@ "should-http": "^0.1.1" | ||
"dependencies": { | ||
"@compassdigital/auth": "^0.2.6", | ||
"@compassdigital/auth": "^0.3.0", | ||
"dynamodb-marshaler": "^2.0.0", | ||
@@ -31,0 +31,0 @@ "hapi": "^16.6.0", |
@@ -128,3 +128,3 @@ var assert = require("assert"), | ||
it("should call a method to be called that requires permissions if permissions are passed as an arrayn - HTTP version", function(done) | ||
it("should call a method to be called that requires permissions if permissions are passed as an array - HTTP version", function(done) | ||
{ | ||
@@ -258,3 +258,3 @@ provider.on("need_permissions", ["read:user"], function(data, next) | ||
it("should support the SECURITY_TOKEN token", function(done) | ||
it("should not support the SECURITY_TOKEN token", function(done) | ||
{ | ||
@@ -276,3 +276,3 @@ request | ||
res.body.should.have.property("result").eql("It worked!"); | ||
res.body.should.have.property("error"); | ||
@@ -396,2 +396,45 @@ done(); | ||
}); | ||
}); | ||
it("should call the rpc /helloWorld with an invalid JWT token", function(done) | ||
{ | ||
var jwt = new JWTKMS({ | ||
aws: { | ||
region: "us-east-1" | ||
} | ||
}); | ||
provider.on("/helloWorld", function(data, next) | ||
{ | ||
should.exist(data); | ||
data.should.eql({id: "Hello world"}); | ||
if(this.context) | ||
{ | ||
throw new Error("Context should not be set"); | ||
} | ||
next(null, "wassup"); | ||
}); | ||
jwt.sign({ | ||
sub: "user1234" | ||
}, | ||
{ | ||
expires: new Date(Date.now() - 25*60*60*1000) | ||
}, | ||
process.env.KEY_ARN).then(function(new_token) | ||
{ | ||
should.exist(new_token); | ||
client.request("/helloWorld", {id: "Hello world"}, new_token, function(err, res) | ||
{ | ||
should.not.exist(err); | ||
should.exist(res); | ||
res.should.have.property("result").eql("wassup"); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -398,0 +441,0 @@ |
34406
798
3
+ Addedcall-bind-apply-helpers@1.0.2(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
Updated@compassdigital/auth@^0.3.0