oauth-1.0a
Advanced tools
Comparing version 1.0.1 to 2.0.0
if (typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') { | ||
module.exports = OAuth; | ||
var CryptoJS = require("crypto-js"); | ||
} | ||
@@ -24,3 +23,2 @@ | ||
this.consumer = opts.consumer; | ||
this.signature_method = opts.signature_method || 'HMAC-SHA1'; | ||
this.nonce_length = opts.nonce_length || 32; | ||
@@ -36,26 +34,16 @@ this.version = opts.version || '1.0'; | ||
switch (this.signature_method) { | ||
case 'HMAC-SHA1': | ||
this.hash = function(base_string, key) { | ||
return CryptoJS.HmacSHA1(base_string, key).toString(CryptoJS.enc.Base64); | ||
}; | ||
break; | ||
// default signature_method is 'PLAINTEXT' | ||
this.signature_method = opts.signature_method || 'PLAINTEXT'; | ||
case 'HMAC-SHA256': | ||
this.hash = function(base_string, key) { | ||
return CryptoJS.HmacSHA256(base_string, key).toString(CryptoJS.enc.Base64); | ||
}; | ||
break; | ||
if(this.signature_method == 'PLAINTEXT' && !opts.hash_function) { | ||
opts.hash_function = function(base_string, key) { | ||
return key; | ||
} | ||
} | ||
case 'PLAINTEXT': | ||
this.hash = function(base_string, key) { | ||
return key; | ||
}; | ||
break; | ||
if(!opts.hash_function) { | ||
throw new Error('hash_function option is required'); | ||
} | ||
case 'RSA-SHA1': | ||
throw new Error('oauth-1.0a does not support this signature method right now. Coming Soon...'); | ||
default: | ||
throw new Error('The OAuth 1.0a protocol defines three signature methods: HMAC-SHA1, RSA-SHA1, and PLAINTEXT only'); | ||
} | ||
this.hash_function = opts.hash_function; | ||
} | ||
@@ -71,3 +59,3 @@ | ||
* } | ||
* @param {Object} public and secret token | ||
* @param {Object} key and secret token | ||
* @return {Object} OAuth Authorized data | ||
@@ -77,3 +65,3 @@ */ | ||
var oauth_data = { | ||
oauth_consumer_key: this.consumer.public, | ||
oauth_consumer_key: this.consumer.key, | ||
oauth_nonce: this.getNonce(), | ||
@@ -89,4 +77,4 @@ oauth_signature_method: this.signature_method, | ||
if(token.public) { | ||
oauth_data.oauth_token = token.public; | ||
if(token.key) { | ||
oauth_data.oauth_token = token.key; | ||
} | ||
@@ -106,3 +94,3 @@ | ||
* @param {Object} request data | ||
* @param {Object} token_secret public and secret token | ||
* @param {Object} token_secret key and secret token | ||
* @param {Object} oauth_data OAuth data | ||
@@ -112,3 +100,3 @@ * @return {String} Signature | ||
OAuth.prototype.getSignature = function(request, token_secret, oauth_data) { | ||
return this.hash(this.getBaseString(request, oauth_data), this.getSigningKey(token_secret)); | ||
return this.hash_function(this.getBaseString(request, oauth_data), this.getSigningKey(token_secret)); | ||
}; | ||
@@ -204,4 +192,9 @@ | ||
var item = arr[i].split('='); | ||
// '' value | ||
item[1] = item[1] || ''; | ||
data[item[0]] = decodeURIComponent(item[1]); | ||
} | ||
return data; | ||
@@ -318,2 +311,5 @@ }; | ||
OAuth.prototype.mergeObject = function(obj1, obj2) { | ||
obj1 = obj1 || {}; | ||
obj2 = obj2 || {}; | ||
var merged_obj = obj1; | ||
@@ -320,0 +316,0 @@ for(var key in obj2) { |
{ | ||
"name": "oauth-1.0a", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "OAuth 1.0a Request Authorization for Node and Browser.", | ||
@@ -27,6 +27,3 @@ "scripts": { | ||
"coveralls": "^2.10.0" | ||
}, | ||
"dependencies": { | ||
"crypto-js": "~3.1.2-2" | ||
} | ||
} |
@@ -1,4 +0,6 @@ | ||
oauth-1.0a ![codeship][codeship-img] | ||
oauth-1.0a ![semaphore][semaphore-img] | ||
========== | ||
[![Join the chat at https://gitter.im/ddo/oauth-1.0a](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ddo/oauth-1.0a?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
[![version][version-img]][version-url] | ||
@@ -12,4 +14,4 @@ [![download][download-img]][download-url] | ||
[codeship-img]: https://www.codeship.io/projects/4388a200-ac85-0131-b0cb-7e8dce60f53f/status | ||
[codeship-url]: https://www.codeship.io/projects/4388a200-ac85-0131-b0cb-7e8dce60f53f/status | ||
[semaphore-img]: https://semaphoreci.com/api/v1/ddo/oauth-1-0a/branches/master/badge.svg | ||
[semaphore-url]: https://semaphoreci.com/ddo/oauth-1-0a) | ||
@@ -48,6 +50,13 @@ [download-img]: https://img.shields.io/npm/dm/oauth-1.0a.svg?style=flat-square | ||
```js | ||
var crypto = require('crypto'); | ||
... | ||
var oauth = OAuth({ | ||
consumer: { | ||
public: '<your consumer key>', | ||
key: '<your consumer key>', | ||
secret: '<your consumer secret>' | ||
}, | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
} | ||
@@ -67,11 +76,57 @@ }); | ||
## Crypto | ||
From version ``2.0.0``, crypto/hash stuff is separated. | ||
``oauth-1.0a`` will use your ``hash_function`` to sign. | ||
### Example | ||
#### Node.js | ||
```js | ||
var crypto = require('crypto'); | ||
function hash_function_sha1(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
} | ||
var oauth = OAuth({ | ||
consumer: { | ||
key: '<your consumer key>', | ||
secret: '<your consumer secret>' | ||
}, | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: hash_function_sha1 | ||
}); | ||
``` | ||
* sha1: ``crypto.createHmac('sha1', key).update(base_string).digest('base64');`` | ||
* sha256: ``crypto.createHmac('sha256', key).update(base_string).digest('base64');`` | ||
* ... | ||
#### Browser | ||
*using google CryptoJS* | ||
* sha1: ``CryptoJS.HmacSHA1(base_string, key).toString(CryptoJS.enc.Base64);`` | ||
* sha256: ``CryptoJS.HmacSHA256(base_string, key).toString(CryptoJS.enc.Base64);`` | ||
* ... | ||
##Installation | ||
###Node.js | ||
$ npm install oauth-1.0a | ||
$ npm install oauth-1.0a --production | ||
* You can use the native crypto package for ``hash_function``. | ||
* It is possible for Node.js to be built without including support for the crypto module. In such cases, calling ``require('crypto')`` will result in an error being thrown. | ||
* You can use your own hash function which has format as: | ||
```js | ||
function(base_string, key) return <string> | ||
``` | ||
###Browser | ||
Download oauth-1.0a.js [here](https://raw.githubusercontent.com/ddo/oauth-1.0a/master/oauth-1.0a.js) | ||
And also your crypto lib. For example [CryptoJS](https://code.google.com/archive/p/crypto-js/) | ||
```html | ||
@@ -96,2 +151,3 @@ <!-- sha1 --> | ||
var OAuth = require('oauth-1.0a'); | ||
var crypto = require('crypto'); | ||
``` | ||
@@ -103,6 +159,9 @@ | ||
consumer: { | ||
public: 'xvz1evFS4wEEPTGEFPHBog', | ||
key: 'xvz1evFS4wEEPTGEFPHBog', | ||
secret: 'kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw' | ||
}, | ||
signature_method: 'HMAC-SHA1' | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
} | ||
}); | ||
@@ -125,3 +184,3 @@ ``` | ||
var token = { | ||
public: '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb', | ||
key: '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb', | ||
secret: 'LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE' | ||
@@ -164,6 +223,9 @@ }; | ||
consumer: { | ||
public: 'xvz1evFS4wEEPTGEFPHBog', | ||
key: 'xvz1evFS4wEEPTGEFPHBog', | ||
secret: 'kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw' | ||
}, | ||
signature_method: 'HMAC-SHA1' | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return CryptoJS.HmacSHA1(base_string, key).toString(CryptoJS.enc.Base64); | ||
} | ||
}); | ||
@@ -186,3 +248,3 @@ ``` | ||
var token = { | ||
public: '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb', | ||
key: '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb', | ||
secret: 'LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE' | ||
@@ -257,3 +319,3 @@ }; | ||
{ | ||
public: <your consumer key>, | ||
key: <your consumer key>, | ||
secret: <your consumer secret> | ||
@@ -263,3 +325,4 @@ } | ||
* ``signature_method``: ``String`` default ``'HMAC-SHA1'`` | ||
* ``signature_method``: ``String`` default ``'PLAINTEXT'`` | ||
* ``hash_function``: ``Function`` if ``signature_method`` = ``'PLAINTEXT'`` default ``return key`` | ||
* ``nonce_length``: ``Int`` default ``32`` | ||
@@ -276,3 +339,3 @@ * ``version``: ``String`` default ``'1.0'`` | ||
* Or just token public only ``.authorize(request_data, {public: 'xxxxx'})`` | ||
* Or just token key only ``.authorize(request_data, {key: 'xxxxx'})`` | ||
@@ -299,6 +362,2 @@ * Want easier? Take a look: | ||
##[Changelog](https://github.com/ddo/oauth-1.0a/releases) | ||
##Depencies | ||
* Browser: [crypto-js](https://code.google.com/p/crypto-js/) | ||
* Node: [crypto-js](https://github.com/evanvosberg/crypto-js) | ||
##[Changelog](https://github.com/ddo/oauth-1.0a/releases) |
@@ -1,11 +0,4 @@ | ||
var expect; | ||
var expect = require('chai').expect; | ||
var OAuth = require('../../oauth-1.0a'); | ||
//Node.js | ||
if(typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') { | ||
expect = require('chai').expect; | ||
var OAuth = require('../../oauth-1.0a'); | ||
} else { //Browser | ||
expect = chai.expect; | ||
} | ||
//TODO: check alphabet and numberic only | ||
@@ -12,0 +5,0 @@ |
@@ -1,9 +0,7 @@ | ||
var expect; | ||
var expect = require('chai').expect; | ||
var OAuth = require('../../oauth-1.0a'); | ||
var crypto = require('crypto'); | ||
//Node.js | ||
if(typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') { | ||
expect = require('chai').expect; | ||
var OAuth = require('../../oauth-1.0a'); | ||
} else { //Browser | ||
expect = chai.expect; | ||
function hash_function_SHA1(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
} | ||
@@ -17,3 +15,5 @@ | ||
secret: 'kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw' | ||
} | ||
}, | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: hash_function_SHA1 | ||
}); | ||
@@ -39,2 +39,4 @@ | ||
}, | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: hash_function_SHA1, | ||
last_ampersand: false | ||
@@ -41,0 +43,0 @@ }); |
@@ -1,9 +0,7 @@ | ||
var expect; | ||
var expect = require('chai').expect; | ||
var OAuth = require('../../oauth-1.0a'); | ||
var crypto = require('crypto'); | ||
//Node.js | ||
if(typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') { | ||
expect = require('chai').expect; | ||
var OAuth = require('../../oauth-1.0a'); | ||
} else { //Browser | ||
expect = chai.expect; | ||
function hash_function_SHA1(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
} | ||
@@ -14,7 +12,8 @@ | ||
var oauth = new OAuth({ | ||
consumer: { | ||
public: "batch-dbc2cd8c-6ca8-463b-96e2-6d8683eac6fd", | ||
consumer: { | ||
key: "batch-dbc2cd8c-6ca8-463b-96e2-6d8683eac6fd", | ||
secret: "4S4Rvm25CJZWv7HBg5HOhhlRTBSZ7npl" | ||
}, | ||
signature_method: 'HMAC-SHA1' | ||
}, | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: hash_function_SHA1 | ||
}); | ||
@@ -21,0 +20,0 @@ |
@@ -1,11 +0,4 @@ | ||
var expect; | ||
var expect = require('chai').expect; | ||
var OAuth = require('../../oauth-1.0a'); | ||
//Node.js | ||
if(typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') { | ||
expect = require('chai').expect; | ||
var OAuth = require('../../oauth-1.0a'); | ||
} else { //Browser | ||
expect = chai.expect; | ||
} | ||
//TODO: check alphabet and numberic only | ||
@@ -12,0 +5,0 @@ |
@@ -1,9 +0,7 @@ | ||
var expect; | ||
var expect = require('chai').expect; | ||
var OAuth = require('../../oauth-1.0a'); | ||
var crypto = require('crypto'); | ||
//Node.js | ||
if(typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') { | ||
expect = require('chai').expect; | ||
var OAuth = require('../../oauth-1.0a'); | ||
} else { //Browser | ||
expect = chai.expect; | ||
function hash_function_SHA1(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
} | ||
@@ -15,5 +13,7 @@ | ||
consumer: { | ||
public: 'xvz1evFS4wEEPTGEFPHBog', | ||
key: 'xvz1evFS4wEEPTGEFPHBog', | ||
secret: 'kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw' | ||
} | ||
}, | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: hash_function_SHA1 | ||
}); | ||
@@ -32,3 +32,3 @@ | ||
var token = { | ||
public: '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb', | ||
key: '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb', | ||
secret: 'LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE' | ||
@@ -53,5 +53,7 @@ }; | ||
consumer: { | ||
public: 'xvz1evFS4wEEPTGEFPHBog', | ||
key: 'xvz1evFS4wEEPTGEFPHBog', | ||
secret: 'kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw' | ||
}, | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: hash_function_SHA1, | ||
parameter_seperator: '-' | ||
@@ -71,3 +73,3 @@ }); | ||
var token = { | ||
public: '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb', | ||
key: '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb', | ||
secret: 'LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE' | ||
@@ -74,0 +76,0 @@ }; |
@@ -1,14 +0,17 @@ | ||
var expect; | ||
var expect = require('chai').expect; | ||
var OAuth = require('../../oauth-1.0a'); | ||
//Node.js | ||
if(typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') { | ||
expect = require('chai').expect; | ||
var OAuth = require('../../oauth-1.0a'); | ||
} else { //Browser | ||
expect = chai.expect; | ||
} | ||
describe("Signature method", function() { | ||
describe("PLAINTEXT signature method", function() { | ||
describe("default PLAINTEXT signature method", function() { | ||
var oauth = new OAuth({ | ||
consumer: {} | ||
}); | ||
it("hash should be return key only", function() { | ||
expect(oauth.signature_method).to.equal('PLAINTEXT'); | ||
}); | ||
}); | ||
describe("default PLAINTEXT hash function", function() { | ||
var oauth = new OAuth({ | ||
consumer: {}, | ||
@@ -19,7 +22,7 @@ signature_method: 'PLAINTEXT' | ||
it("hash should be return key only", function() { | ||
expect(oauth.hash('base_string', 'key')).to.equal('key'); | ||
expect(oauth.hash_function('base_string', 'key')).to.equal('key'); | ||
}); | ||
}); | ||
describe("RSA-SHA1 signature method", function() { | ||
describe("missing hash function", function() { | ||
it("constructor should throw a error", function() { | ||
@@ -29,18 +32,7 @@ expect(function() { | ||
consumer: {}, | ||
signature_method: 'RSA-SHA1' | ||
signature_method: 'RSA-SHA1', | ||
}); | ||
}).to.throw('oauth-1.0a does not support this signature method right now. Coming Soon...'); | ||
}).to.throw('hash_function option is required'); | ||
}); | ||
}); | ||
describe("UNKNOWN signature method", function() { | ||
it("constructor should throw a error", function() { | ||
expect(function() { | ||
new OAuth({ | ||
consumer: {}, | ||
signature_method: 'UNKNOWN' | ||
}); | ||
}).to.throw('The OAuth 1.0a protocol defines three signature methods: HMAC-SHA1, RSA-SHA1, and PLAINTEXT only'); | ||
}); | ||
}); | ||
}); |
var expect = require('chai').expect; | ||
var Request = require('request'); | ||
var OAuth = require('../../oauth-1.0a'); | ||
var crypto = require('crypto'); | ||
@@ -10,6 +11,9 @@ describe("Bitbucket Personal Consumer", function() { | ||
consumer: { | ||
public: process.env.BITBUCKET_CONSUMER_PUBLIC, | ||
key: process.env.BITBUCKET_CONSUMER_PUBLIC, | ||
secret: process.env.BITBUCKET_CONSUMER_SECRET | ||
}, | ||
signature_method: 'HMAC-SHA1' | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
} | ||
}); | ||
@@ -16,0 +20,0 @@ |
var expect = require('chai').expect; | ||
var Request = require('request'); | ||
var OAuth = require('../../oauth-1.0a'); | ||
var crypto = require('crypto'); | ||
@@ -10,6 +11,9 @@ describe("Flickr Personal Consumer", function() { | ||
consumer: { | ||
public: process.env.FLICKR_CONSUMER_PUBLIC, | ||
key: process.env.FLICKR_CONSUMER_key, | ||
secret: process.env.FLICKR_CONSUMER_SECRET | ||
}, | ||
signature_method: 'HMAC-SHA1' | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
} | ||
}); | ||
@@ -70,3 +74,3 @@ | ||
console.log(body); | ||
console.log('http://www.flickr.com/services/oauth/authorize?oauth_token=' + token.public); | ||
console.log('http://www.flickr.com/services/oauth/authorize?oauth_token=' + token.key); | ||
@@ -85,3 +89,3 @@ done(); | ||
var token = { | ||
public: 'get from Request Token', | ||
key: 'get from Request Token', | ||
secret: 'get from Request Token' | ||
@@ -114,3 +118,3 @@ }; | ||
token.public = body.oauth_token; | ||
token.key = body.oauth_token; | ||
token.secret = body.oauth_token_secret; | ||
@@ -128,3 +132,3 @@ | ||
var token = { | ||
public: process.env.FLICKR_TOKEN_PUBLIC, | ||
key: process.env.FLICKR_TOKEN_PUBLIC, | ||
secret: process.env.FLICKR_SECRET_SECRET | ||
@@ -137,3 +141,3 @@ }; | ||
data: { | ||
api_key: token.public, | ||
api_key: token.key, | ||
format: 'json' | ||
@@ -161,3 +165,3 @@ } | ||
var token = { | ||
public: process.env.FLICKR_TOKEN_PUBLIC, | ||
key: process.env.FLICKR_TOKEN_PUBLIC, | ||
secret: process.env.FLICKR_SECRET_SECRET | ||
@@ -170,3 +174,3 @@ }; | ||
data: { | ||
api_key: token.public, | ||
api_key: token.key, | ||
format: 'json' | ||
@@ -173,0 +177,0 @@ } |
var expect = require('chai').expect; | ||
var Request = require('request'); | ||
var OAuth = require('../../oauth-1.0a'); | ||
var crypto = require('crypto'); | ||
@@ -13,6 +14,9 @@ /* | ||
consumer: { | ||
public: process.env.LINKEDIN_CONSUMER_PUBLIC, | ||
key: process.env.LINKEDIN_CONSUMER_PUBLIC, | ||
secret: process.env.LINKEDIN_CONSUMER_SECRET | ||
}, | ||
signature_method: 'HMAC-SHA1' | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
} | ||
}); | ||
@@ -19,0 +23,0 @@ |
var expect = require('chai').expect; | ||
var Request = require('request'); | ||
var OAuth = require('../../oauth-1.0a'); | ||
var crypto = require('crypto'); | ||
@@ -10,6 +11,9 @@ describe("Openbank Personal Consumer", function() { | ||
consumer: { | ||
public: process.env.OPENBANK_CONSUMER_PUBLIC, | ||
key: process.env.OPENBANK_CONSUMER_PUBLIC, | ||
secret: process.env.OPENBANK_CONSUMER_SECRET | ||
}, | ||
signature_method: 'HMAC-SHA256' | ||
signature_method: 'HMAC-SHA256', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha256', key).update(base_string).digest('base64'); | ||
} | ||
}); | ||
@@ -16,0 +20,0 @@ |
var expect = require('chai').expect; | ||
var Request = require('request'); | ||
var OAuth = require('../../oauth-1.0a'); | ||
var crypto = require('crypto'); | ||
@@ -8,10 +9,13 @@ describe("Twitter Personal Consumer", function() { | ||
consumer: { | ||
public: process.env.TWITTER_CONSUMER_PUBLIC, | ||
key: process.env.TWITTER_CONSUMER_PUBLIC, | ||
secret: process.env.TWITTER_CONSUMER_SECRET | ||
}, | ||
signature_method: 'HMAC-SHA1' | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
} | ||
}); | ||
var token = { | ||
public: process.env.TWITTER_TOKEN_PUBLIC, | ||
key: process.env.TWITTER_TOKEN_PUBLIC, | ||
secret: process.env.TWITTER_TOKEN_SECRET | ||
@@ -18,0 +22,0 @@ }; |
@@ -1,18 +0,15 @@ | ||
var expect; | ||
var expect = require('chai').expect; | ||
var OAuth = require('../oauth-1.0a'); | ||
var crypto = require('crypto'); | ||
//Node.js | ||
if(typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') { | ||
expect = require('chai').expect; | ||
var OAuth = require('../oauth-1.0a'); | ||
} else { //Browser | ||
expect = chai.expect; | ||
} | ||
describe("Twitter Sample", function() { | ||
var oauth = new OAuth({ | ||
consumer: { | ||
public: 'xvz1evFS4wEEPTGEFPHBog', | ||
key: 'xvz1evFS4wEEPTGEFPHBog', | ||
secret: 'kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw' | ||
}, | ||
signature_method: 'HMAC-SHA1' | ||
signature_method: 'HMAC-SHA1', | ||
hash_function: function(base_string, key) { | ||
return crypto.createHmac('sha1', key).update(base_string).digest('base64'); | ||
} | ||
}); | ||
@@ -31,3 +28,3 @@ | ||
var token = { | ||
public: '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb', | ||
key: '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb', | ||
secret: 'LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE' | ||
@@ -45,3 +42,3 @@ }; | ||
var oauth_data = { | ||
oauth_consumer_key: oauth.consumer.public, | ||
oauth_consumer_key: oauth.consumer.key, | ||
oauth_nonce: oauth.getNonce(), | ||
@@ -51,3 +48,3 @@ oauth_signature_method: oauth.signature_method, | ||
oauth_version: '1.0', | ||
oauth_token: token.public | ||
oauth_token: token.key | ||
}; | ||
@@ -54,0 +51,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
0
351
17
1
52471
20
1081
- Removedcrypto-js@~3.1.2-2
- Removedcrypto-js@3.1.8(transitive)