1 |
|
2 |
|
3 |
|
4 | var oauth = require('oauth')
|
5 |
|
6 | var required = [
|
7 | 'oauth_request_url'
|
8 | , 'oauth_access_url'
|
9 | , 'consumer_key'
|
10 | , 'consumer_secret'
|
11 | , 'access_token'
|
12 | , 'access_token_secret'
|
13 | ];
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | function Auth (config) {
|
19 |
|
20 | if (typeof config !== 'object')
|
21 | throw new TypeError('config must be object, got ' + typeof config)
|
22 |
|
23 | required.forEach(function (requirement) {
|
24 | if (!config[requirement])
|
25 | throw new Error('config must provide ' + requirement)
|
26 | })
|
27 |
|
28 |
|
29 | this.config = config
|
30 | this.oa = new oauth.OAuth(
|
31 | config.oauth_request_url
|
32 | , config.oauth_access_url
|
33 | , config.consumer_key
|
34 | , config.consumer_secret
|
35 | , '1.0'
|
36 | , null
|
37 | , 'HMAC-SHA1'
|
38 | )
|
39 | }
|
40 |
|
41 | module.exports = Auth
|
42 |
|