atlassian-oauth2
Advanced tools
Comparing version 0.4.2 to 0.5.0
@@ -1,2 +0,2 @@ | ||
var request = require('request'), | ||
var fetch = require('node-fetch'), | ||
RSVP = require('rsvp'), | ||
@@ -86,18 +86,18 @@ jwt = require('atlassian-jwt'); | ||
request({ | ||
var url = (opts.authorizationServerBaseUrl || AUTHORIZATION_SERVER_URL) + (opts.authorizationPath || '/oauth2/token'); | ||
fetch(url, { | ||
method: 'POST', | ||
url: (opts.authorizationServerBaseUrl || AUTHORIZATION_SERVER_URL) + (opts.authorizationPath || '/oauth2/token'), | ||
form: formData, | ||
json: true, | ||
body: JSON.stringify(formData), | ||
headers: { | ||
"accept": "application/json" | ||
"Accept": "application/json", | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
} | ||
}, function(err, response, body) { | ||
if (err) { | ||
reject(err); | ||
} else if (response.statusCode < 200 || response.statusCode > 299) { | ||
reject(body); | ||
} else { | ||
resolve(body); | ||
}).then(function(res) { | ||
if (res.status < 200 || res.status > 299) { | ||
reject(res.body); | ||
} | ||
resolve(res.body); | ||
}).catch(function(err){ | ||
reject(err); | ||
}); | ||
@@ -104,0 +104,0 @@ }); |
{ | ||
"name": "atlassian-oauth2", | ||
"description": "Atlassian Connect OAuth2 library", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"author": "Seb Ruiz <sruiz@atlassian.com>", | ||
@@ -12,3 +12,3 @@ "repository": { | ||
"atlassian-jwt": "^1.0.2", | ||
"request": "^2.88.0", | ||
"node-fetch": "^2.6.7", | ||
"rsvp": "^4.8.4" | ||
@@ -25,3 +25,4 @@ }, | ||
"scripts": { | ||
"test": "mocha test/*.js" | ||
"test": "mocha test/*.js", | ||
"test:watch": "mocha --watch test/*.js" | ||
}, | ||
@@ -28,0 +29,0 @@ "license": "MIT", |
@@ -137,3 +137,3 @@ var should = require('should'), | ||
interceptRequest(done, function () { | ||
this.req.headers.accept.should.be.eql("application/json"); | ||
this.req.headers.accept[0].should.be.eql("application/json"); | ||
}); | ||
@@ -144,3 +144,3 @@ }); | ||
interceptRequest(done, function () { | ||
this.req.headers['content-type'].should.be.eql("application/x-www-form-urlencoded"); | ||
this.req.headers['content-type'][0].should.be.eql("application/x-www-form-urlencoded"); | ||
}); | ||
@@ -151,10 +151,10 @@ }); | ||
interceptRequest(done, function (uri, requestBody) { | ||
var body = qs.parse(requestBody); | ||
var body = qs.parse(JSON.parse(requestBody)); | ||
body.grant_type.should.be.eql('urn:ietf:params:oauth:grant-type:jwt-bearer'); | ||
}); | ||
}); | ||
it('Request assertion exists', function (done) { | ||
interceptRequest(done, function (uri, requestBody) { | ||
var body = qs.parse(requestBody); | ||
var body = qs.parse(JSON.parse(requestBody)); | ||
should.exist(body.assertion); | ||
@@ -166,3 +166,3 @@ }); | ||
interceptRequest(done, function (uri, requestBody) { | ||
var body = qs.parse(requestBody); | ||
var body = qs.parse(JSON.parse(requestBody)); | ||
should.exist(jwt.decode(body.assertion, sharedSecret).iss); | ||
@@ -175,3 +175,3 @@ }); | ||
interceptRequest(done, function (uri, requestBody) { | ||
var body = qs.parse(requestBody); | ||
var body = qs.parse(JSON.parse(requestBody)); | ||
jwt.decode(body.assertion, sharedSecret).aud.should.be.eql([customAuthUrl]); | ||
@@ -199,3 +199,3 @@ }, { authorizationServerBaseUrl: customAuthUrl }); | ||
interceptRequest(done, function (uri, requestBody) { | ||
var body = qs.parse(requestBody); | ||
var body = qs.parse(JSON.parse(requestBody)); | ||
should.not.exist(body.scope); | ||
@@ -207,3 +207,3 @@ }, { scopes: false }); | ||
interceptRequest(done, function (uri, requestBody) { | ||
var body = qs.parse(requestBody); | ||
var body = qs.parse(JSON.parse(requestBody)); | ||
body.scope.should.be.eql('READ'); | ||
@@ -215,3 +215,3 @@ }, { scopes: ['READ'] }); | ||
interceptRequest(done, function (uri, requestBody) { | ||
var body = qs.parse(requestBody); | ||
var body = qs.parse(JSON.parse(requestBody)); | ||
body.scope.should.be.eql('READ WRITE'); | ||
@@ -223,3 +223,3 @@ }, { scopes: ['READ', 'WRITE'] }); | ||
interceptRequest(done, function (uri, requestBody) { | ||
var body = qs.parse(requestBody); | ||
var body = qs.parse(JSON.parse(requestBody)); | ||
body.scope.should.be.eql('WRITE READ'); | ||
@@ -231,3 +231,3 @@ }, { scopes: ['WRITE', 'READ'] }); | ||
interceptRequest(done, function (uri, requestBody) { | ||
var body = qs.parse(requestBody); | ||
var body = qs.parse(JSON.parse(requestBody)); | ||
body.scope.should.be.eql('READ WRITE'); | ||
@@ -239,3 +239,3 @@ }, { scopes: ['READ WRITE'] }); | ||
interceptRequest(done, function (uri, requestBody) { | ||
var body = qs.parse(requestBody); | ||
var body = qs.parse(JSON.parse(requestBody)); | ||
body.scope.should.be.eql('READ WRITE'); | ||
@@ -242,0 +242,0 @@ }, { scopes: ['read', 'WriTe'] }); |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
17107
295
2
+ Addednode-fetch@^2.6.7
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedrequest@^2.88.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.15.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)