faye-authentication 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +43 -32
- data/app/assets/javascripts/faye-authentication.js +22 -7
- data/faye-authentication.gemspec +3 -1
- data/lib/faye/authentication/extension.rb +17 -8
- data/lib/faye/authentication/http_client.rb +2 -1
- data/lib/faye/authentication/version.rb +1 -1
- data/lib/faye/authentication.rb +20 -18
- data/spec/javascripts/faye-authentication_spec.js +2 -3
- data/spec/javascripts/faye-extension_spec.js +35 -5
- data/spec/javascripts/support/jasmine_helper.rb +2 -0
- data/spec/lib/faye/authentication/http_client_spec.rb +2 -1
- data/spec/lib/faye/authentication_spec.rb +44 -10
- data/spec/utils/javascripts/jwt.js +2249 -0
- data/spec/utils/javascripts/query-string.js +66 -0
- metadata +23 -6
- data/spec/utils/javascripts/hmac.js +0 -131
@@ -0,0 +1,66 @@
|
|
1
|
+
/*!
|
2
|
+
query-string
|
3
|
+
Parse and stringify URL query strings
|
4
|
+
https://github.com/sindresorhus/query-string
|
5
|
+
by Sindre Sorhus
|
6
|
+
MIT License
|
7
|
+
*/
|
8
|
+
(function () {
|
9
|
+
'use strict';
|
10
|
+
var queryString = {};
|
11
|
+
|
12
|
+
queryString.parse = function (str) {
|
13
|
+
if (typeof str !== 'string') {
|
14
|
+
return {};
|
15
|
+
}
|
16
|
+
|
17
|
+
str = str.trim().replace(/^(\?|#)/, '');
|
18
|
+
|
19
|
+
if (!str) {
|
20
|
+
return {};
|
21
|
+
}
|
22
|
+
|
23
|
+
return str.trim().split('&').reduce(function (ret, param) {
|
24
|
+
var parts = param.replace(/\+/g, ' ').split('=');
|
25
|
+
var key = parts[0];
|
26
|
+
var val = parts[1];
|
27
|
+
|
28
|
+
key = decodeURIComponent(key);
|
29
|
+
// missing `=` should be `null`:
|
30
|
+
// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
|
31
|
+
val = val === undefined ? null : decodeURIComponent(val);
|
32
|
+
|
33
|
+
if (!ret.hasOwnProperty(key)) {
|
34
|
+
ret[key] = val;
|
35
|
+
} else if (Array.isArray(ret[key])) {
|
36
|
+
ret[key].push(val);
|
37
|
+
} else {
|
38
|
+
ret[key] = [ret[key], val];
|
39
|
+
}
|
40
|
+
|
41
|
+
return ret;
|
42
|
+
}, {});
|
43
|
+
};
|
44
|
+
|
45
|
+
queryString.stringify = function (obj) {
|
46
|
+
return obj ? Object.keys(obj).map(function (key) {
|
47
|
+
var val = obj[key];
|
48
|
+
|
49
|
+
if (Array.isArray(val)) {
|
50
|
+
return val.map(function (val2) {
|
51
|
+
return encodeURIComponent(key) + '=' + encodeURIComponent(val2);
|
52
|
+
}).join('&');
|
53
|
+
}
|
54
|
+
|
55
|
+
return encodeURIComponent(key) + '=' + encodeURIComponent(val);
|
56
|
+
}).join('&') : '';
|
57
|
+
};
|
58
|
+
|
59
|
+
if (typeof define === 'function' && define.amd) {
|
60
|
+
define([], queryString);
|
61
|
+
} else if (typeof module !== 'undefined' && module.exports) {
|
62
|
+
module.exports = queryString;
|
63
|
+
} else {
|
64
|
+
window.queryString = queryString;
|
65
|
+
}
|
66
|
+
})();
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faye-authentication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrien Siami
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jwt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +58,14 @@ dependencies:
|
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.0
|
61
|
+
version: '3.0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.0
|
68
|
+
version: '3.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: jasmine
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +146,7 @@ files:
|
|
132
146
|
- ".gitignore"
|
133
147
|
- ".rspec"
|
134
148
|
- ".travis.yml"
|
149
|
+
- CHANGELOG.md
|
135
150
|
- Gemfile
|
136
151
|
- LICENSE.txt
|
137
152
|
- README.md
|
@@ -154,9 +169,10 @@ files:
|
|
154
169
|
- spec/spec_helper.rb
|
155
170
|
- spec/utils/javascripts/core.js
|
156
171
|
- spec/utils/javascripts/faye.js
|
157
|
-
- spec/utils/javascripts/hmac.js
|
158
172
|
- spec/utils/javascripts/jquery.js
|
173
|
+
- spec/utils/javascripts/jwt.js
|
159
174
|
- spec/utils/javascripts/mock-ajax.js
|
175
|
+
- spec/utils/javascripts/query-string.js
|
160
176
|
- spec/utils/javascripts/sha1.js
|
161
177
|
homepage: https://github.com/dimelo/faye-authentication
|
162
178
|
licenses:
|
@@ -194,7 +210,8 @@ test_files:
|
|
194
210
|
- spec/spec_helper.rb
|
195
211
|
- spec/utils/javascripts/core.js
|
196
212
|
- spec/utils/javascripts/faye.js
|
197
|
-
- spec/utils/javascripts/hmac.js
|
198
213
|
- spec/utils/javascripts/jquery.js
|
214
|
+
- spec/utils/javascripts/jwt.js
|
199
215
|
- spec/utils/javascripts/mock-ajax.js
|
216
|
+
- spec/utils/javascripts/query-string.js
|
200
217
|
- spec/utils/javascripts/sha1.js
|
@@ -1,131 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
CryptoJS v3.1.2
|
3
|
-
code.google.com/p/crypto-js
|
4
|
-
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
5
|
-
code.google.com/p/crypto-js/wiki/License
|
6
|
-
*/
|
7
|
-
(function () {
|
8
|
-
// Shortcuts
|
9
|
-
var C = CryptoJS;
|
10
|
-
var C_lib = C.lib;
|
11
|
-
var Base = C_lib.Base;
|
12
|
-
var C_enc = C.enc;
|
13
|
-
var Utf8 = C_enc.Utf8;
|
14
|
-
var C_algo = C.algo;
|
15
|
-
|
16
|
-
/**
|
17
|
-
* HMAC algorithm.
|
18
|
-
*/
|
19
|
-
var HMAC = C_algo.HMAC = Base.extend({
|
20
|
-
/**
|
21
|
-
* Initializes a newly created HMAC.
|
22
|
-
*
|
23
|
-
* @param {Hasher} hasher The hash algorithm to use.
|
24
|
-
* @param {WordArray|string} key The secret key.
|
25
|
-
*
|
26
|
-
* @example
|
27
|
-
*
|
28
|
-
* var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
|
29
|
-
*/
|
30
|
-
init: function (hasher, key) {
|
31
|
-
// Init hasher
|
32
|
-
hasher = this._hasher = new hasher.init();
|
33
|
-
|
34
|
-
// Convert string to WordArray, else assume WordArray already
|
35
|
-
if (typeof key == 'string') {
|
36
|
-
key = Utf8.parse(key);
|
37
|
-
}
|
38
|
-
|
39
|
-
// Shortcuts
|
40
|
-
var hasherBlockSize = hasher.blockSize;
|
41
|
-
var hasherBlockSizeBytes = hasherBlockSize * 4;
|
42
|
-
|
43
|
-
// Allow arbitrary length keys
|
44
|
-
if (key.sigBytes > hasherBlockSizeBytes) {
|
45
|
-
key = hasher.finalize(key);
|
46
|
-
}
|
47
|
-
|
48
|
-
// Clamp excess bits
|
49
|
-
key.clamp();
|
50
|
-
|
51
|
-
// Clone key for inner and outer pads
|
52
|
-
var oKey = this._oKey = key.clone();
|
53
|
-
var iKey = this._iKey = key.clone();
|
54
|
-
|
55
|
-
// Shortcuts
|
56
|
-
var oKeyWords = oKey.words;
|
57
|
-
var iKeyWords = iKey.words;
|
58
|
-
|
59
|
-
// XOR keys with pad constants
|
60
|
-
for (var i = 0; i < hasherBlockSize; i++) {
|
61
|
-
oKeyWords[i] ^= 0x5c5c5c5c;
|
62
|
-
iKeyWords[i] ^= 0x36363636;
|
63
|
-
}
|
64
|
-
oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
|
65
|
-
|
66
|
-
// Set initial values
|
67
|
-
this.reset();
|
68
|
-
},
|
69
|
-
|
70
|
-
/**
|
71
|
-
* Resets this HMAC to its initial state.
|
72
|
-
*
|
73
|
-
* @example
|
74
|
-
*
|
75
|
-
* hmacHasher.reset();
|
76
|
-
*/
|
77
|
-
reset: function () {
|
78
|
-
// Shortcut
|
79
|
-
var hasher = this._hasher;
|
80
|
-
|
81
|
-
// Reset
|
82
|
-
hasher.reset();
|
83
|
-
hasher.update(this._iKey);
|
84
|
-
},
|
85
|
-
|
86
|
-
/**
|
87
|
-
* Updates this HMAC with a message.
|
88
|
-
*
|
89
|
-
* @param {WordArray|string} messageUpdate The message to append.
|
90
|
-
*
|
91
|
-
* @return {HMAC} This HMAC instance.
|
92
|
-
*
|
93
|
-
* @example
|
94
|
-
*
|
95
|
-
* hmacHasher.update('message');
|
96
|
-
* hmacHasher.update(wordArray);
|
97
|
-
*/
|
98
|
-
update: function (messageUpdate) {
|
99
|
-
this._hasher.update(messageUpdate);
|
100
|
-
|
101
|
-
// Chainable
|
102
|
-
return this;
|
103
|
-
},
|
104
|
-
|
105
|
-
/**
|
106
|
-
* Finalizes the HMAC computation.
|
107
|
-
* Note that the finalize operation is effectively a destructive, read-once operation.
|
108
|
-
*
|
109
|
-
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
110
|
-
*
|
111
|
-
* @return {WordArray} The HMAC.
|
112
|
-
*
|
113
|
-
* @example
|
114
|
-
*
|
115
|
-
* var hmac = hmacHasher.finalize();
|
116
|
-
* var hmac = hmacHasher.finalize('message');
|
117
|
-
* var hmac = hmacHasher.finalize(wordArray);
|
118
|
-
*/
|
119
|
-
finalize: function (messageUpdate) {
|
120
|
-
// Shortcut
|
121
|
-
var hasher = this._hasher;
|
122
|
-
|
123
|
-
// Compute HMAC
|
124
|
-
var innerHash = hasher.finalize(messageUpdate);
|
125
|
-
hasher.reset();
|
126
|
-
var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
|
127
|
-
|
128
|
-
return hmac;
|
129
|
-
}
|
130
|
-
});
|
131
|
-
}());
|