oauth-request
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -5,9 +5,13 @@ var OAuthRequest = require('./'); | ||
consumer: { | ||
public: process.env.TWITTER_CONSUMER_PUBLIC, | ||
key: process.env.TWITTER_CONSUMER_PUBLIC, | ||
secret: process.env.TWITTER_CONSUMER_SECRET | ||
} | ||
}, | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
}, | ||
}); | ||
twitter.setToken({ | ||
public: process.env.TWITTER_TOKEN_PUBLIC, | ||
key: process.env.TWITTER_TOKEN_PUBLIC, | ||
secret: process.env.TWITTER_TOKEN_SECRET | ||
@@ -14,0 +18,0 @@ }); |
@@ -36,3 +36,3 @@ var qs = require('querystring'); | ||
if(typeof token === 'string') { | ||
return this.token.public = token; | ||
return this.token.key = token; | ||
} | ||
@@ -39,0 +39,0 @@ |
{ | ||
"name": "oauth-request", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "OAuth 1.0a via request", | ||
@@ -31,3 +31,3 @@ "main": "index.js", | ||
"debug": "^0.8.1", | ||
"oauth-1.0a": "^0.1.0", | ||
"oauth-1.0a": "^2.0.0", | ||
"request": "^2.36.0" | ||
@@ -34,0 +34,0 @@ }, |
@@ -21,2 +21,3 @@ oauth-request [![Build Status](https://travis-ci.org/ddo/oauth-request.svg)](https://travis-ci.org/ddo/oauth-request) | ||
```js | ||
var crypto = require('crypto'); | ||
var OAuth = require('oauth-request'); | ||
@@ -26,4 +27,8 @@ | ||
consumer: { | ||
public: 'xxxxx', | ||
key: 'xxxxx', | ||
secret: 'xxxxx' | ||
}, | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
} | ||
@@ -33,3 +38,3 @@ }); | ||
twitter.setToken({ | ||
public: 'xxxxx', | ||
key: 'xxxxx', | ||
secret: 'xxxxx' | ||
@@ -57,2 +62,6 @@ }); | ||
## Options | ||
check [oauth-1.0a](https://github.com/ddo/oauth-1.0a#options) options | ||
## API | ||
@@ -64,2 +73,3 @@ | ||
* .get([request options](https://github.com/mikeal/request#requestoptions-callback), callback) | ||
* .get(url or request options) (no callback) return request object | ||
@@ -70,5 +80,23 @@ ### ``.post()`` | ||
* .post([request options](https://github.com/mikeal/request#requestoptions-callback), callback) | ||
* .get(url or request options) (no callback) return request object | ||
### ``.setToken(oauth_token)`` | ||
* ``oauth_token``: ``String`` token key | ||
```js | ||
twitter.setToken('xxxxx'); | ||
``` | ||
* ``oauth_token``: ``Object`` | ||
```js | ||
twitter.setToken({ | ||
key: 'xxxxx', | ||
secret: 'xxxxx' | ||
}); | ||
``` | ||
## TODO | ||
* [ ] ``.stream`` |
35
test.js
var expect = require('chai').expect; | ||
var crypto = require('crypto'); | ||
var OAuthRequest = require('./'); | ||
@@ -8,7 +9,11 @@ | ||
consumer: { | ||
public: process.env.TWITTER_CONSUMER_PUBLIC, | ||
key: process.env.TWITTER_CONSUMER_PUBLIC, | ||
secret: process.env.TWITTER_CONSUMER_SECRET | ||
}, | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
}, | ||
token: { | ||
public: process.env.TWITTER_TOKEN_PUBLIC, | ||
key: process.env.TWITTER_TOKEN_PUBLIC, | ||
secret: process.env.TWITTER_TOKEN_SECRET | ||
@@ -34,8 +39,12 @@ } | ||
describe("#setToken token public", function() { | ||
describe("#setToken token key", function() { | ||
twitter = OAuthRequest({ | ||
consumer: { | ||
public: process.env.TWITTER_CONSUMER_PUBLIC, | ||
key: process.env.TWITTER_CONSUMER_PUBLIC, | ||
secret: process.env.TWITTER_CONSUMER_SECRET | ||
} | ||
}, | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
}, | ||
}); | ||
@@ -45,4 +54,4 @@ | ||
it("token public should be set", function() { | ||
expect(twitter.token).to.have.property('public', process.env.TWITTER_TOKEN_PUBLIC); | ||
it("token key should be set", function() { | ||
expect(twitter.token).to.have.property('key', process.env.TWITTER_TOKEN_PUBLIC); | ||
}); | ||
@@ -54,9 +63,13 @@ }); | ||
consumer: { | ||
public: process.env.TWITTER_CONSUMER_PUBLIC, | ||
key: process.env.TWITTER_CONSUMER_PUBLIC, | ||
secret: process.env.TWITTER_CONSUMER_SECRET | ||
} | ||
}, | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
}, | ||
}); | ||
twitter.setToken({ | ||
public: process.env.TWITTER_TOKEN_PUBLIC, | ||
key: process.env.TWITTER_TOKEN_PUBLIC, | ||
secret: process.env.TWITTER_TOKEN_SECRET | ||
@@ -66,3 +79,3 @@ }); | ||
it("token should be set", function() { | ||
expect(twitter.token).to.have.property('public', process.env.TWITTER_TOKEN_PUBLIC); | ||
expect(twitter.token).to.have.property('key', process.env.TWITTER_TOKEN_PUBLIC); | ||
expect(twitter.token).to.have.property('secret', process.env.TWITTER_TOKEN_SECRET); | ||
@@ -69,0 +82,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14001
256
96
+ Addedoauth-1.0a@2.2.6(transitive)
- Removedcrypto-js@3.1.8(transitive)
- Removedoauth-1.0a@0.1.1(transitive)
Updatedoauth-1.0a@^2.0.0