-
Notifications
You must be signed in to change notification settings - Fork 1
/
deps.js
87 lines (71 loc) · 2.83 KB
/
deps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require=(function(e,t,n,r){function i(r){if(!n[r]){if(!t[r]){if(e)return e(r);throw new Error("Cannot find module '"+r+"'")}var s=n[r]={exports:{}};t[r][0](function(e){var n=t[r][1][e];return i(n?n:e)},s,s.exports)}return n[r].exports}for(var s=0;s<r.length;s++)i(r[s]);return i})(typeof require!=="undefined"&&require,{"ohauth":[function(require,module,exports){
module.exports=require('k/J4/z');
},{}],"k/J4/z":[function(require,module,exports){
(function(context) {
var ohauth = {};
ohauth.qsString = function(obj) {
return Object.keys(obj).sort().map(function(key) {
return encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]);
}).join('&');
};
ohauth.sha = sha1();
ohauth.stringQs = function(str) {
return str.split('&').reduce(function(obj, pair){
var parts = pair.split('=');
obj[parts[0]] = (null === parts[1]) ? '' : decodeURIComponent(parts[1]);
return obj;
}, {});
};
ohauth.xhr = function(method, url, auth, data, options, callback) {
var xhr = new XMLHttpRequest(),
twoHundred = /^20\d$/;
xhr.onreadystatechange = function() {
if (4 == xhr.readyState && 0 !== xhr.status) {
if (twoHundred.test(xhr.status)) {
callback(null, xhr);
} else {
callback(xhr, null);
}
}
};
var headers = (options && options.header) || { 'Content-Type': 'application/x-www-form-urlencoded' };
xhr.open(method, url, true);
xhr.setRequestHeader('Authorization', 'OAuth ' + ohauth.authHeader(auth));
for (var h in headers) xhr.setRequestHeader(h, headers[h]);
xhr.send(data);
};
ohauth.nonce = function() {
for (var o = ''; o.length < 6;) {
o += '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'[Math.floor(Math.random() * 61)];
}
return o;
};
ohauth.authHeader = function(obj) {
return Object.keys(obj).sort().map(function(key) {
return encodeURIComponent(key) + '="' + encodeURIComponent(obj[key]) + '"';
}).join(', ');
};
ohauth.timestamp = function() { return ~~((+new Date()) / 1000); };
ohauth.percentEncode = function(s) {
return encodeURIComponent(s)
.replace(/\!/g, '%21').replace(/\'/g, '%27')
.replace(/\*/g, '%2A').replace(/\(/g, '%28').replace(/\)/g, '%29');
};
ohauth.baseString = function(method, url, params) {
if (params.oauth_signature) delete params.oauth_signature;
return [
method,
ohauth.percentEncode(url),
ohauth.percentEncode(ohauth.qsString(params))].join('&');
};
ohauth.signature = function(oauth_secret, token_secret, baseString) {
return ohauth.sha.b64_hmac_sha1(
ohauth.percentEncode(oauth_secret) + '&' +
ohauth.percentEncode(token_secret),
baseString);
};
context.ohauth = ohauth;
if (typeof module !== 'undefined') module.exports = ohauth;
})(this);
},{}]},{},[])
;