PageRenderTime 51ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/Sketchbots/sw/labqueue/static/help/js/lib/lask.client.mootools.js

https://gitlab.com/x33n/ChromeWebLab
JavaScript | 334 lines | 298 code | 6 blank | 30 comment | 37 complexity | 074b0b64e6f00b66fdc7a32eb370c70d MD5 | raw file
  1. /*
  2. Copyright 2013 Google Inc
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /* lask client tools for MooTools
  14. */
  15. var SignedJSONRequest = new Class({
  16. Extends: Request.JSON,
  17. initialize: function(options) {
  18. options['isSigned'] = true;
  19. this.parent(options);
  20. if (!options.hasOwnProperty('app_key'))
  21. throw new Error('ERROR: The \'app_key\' property must be specified in SignedJSONRequest options. It should contain your API app key as the value.');
  22. if (!options.hasOwnProperty('app_secret'))
  23. throw new Error('ERROR: The \'app_secret\' property must be specified in SignedJSONRequest options. It should contain your API app secret as the value.');
  24. },
  25. send: function(options) {
  26. //make sure the request is signed before sending
  27. if (!options) options = {}
  28. options['_auth'] = this.getAuthString();
  29. //this.options.headers['Authorization'] = this.getAuthString();
  30. this.parent(options);
  31. },
  32. get: function(options) {
  33. //make sure the request is signed before sending
  34. if (!options) options = {}
  35. options['_auth'] = this.getAuthString();
  36. //this.options.headers['Authorization'] = this.getAuthString();
  37. this.parent(options);
  38. },
  39. post: function(options) {
  40. //make sure the request is signed before sending
  41. if (!options) options = {}
  42. options['_auth'] = this.getAuthString();
  43. //this.options.headers['Authorization'] = this.getAuthString();
  44. this.parent(options);
  45. },
  46. getAuthString: function() {
  47. var a = document.createElement('a');
  48. a.href = this.options.url;
  49. var sig_target = a.pathname;
  50. var signature = __lask_client_mootools__CryptoJS.HmacMD5(sig_target, this.options.app_secret);
  51. return this.options.app_key + ':' + signature;
  52. }
  53. });
  54. /*******************************************************/
  55. /*
  56. CryptoJS v3.0.2
  57. code.google.com/p/crypto-js
  58. (c) 2009-2012 by Jeff Mott. All rights reserved.
  59. code.google.com/p/crypto-js/wiki/License
  60. */
  61. var __lask_client_mootools__CryptoJS = __lask_client_mootools__CryptoJS || function(l, q) {
  62. var g = {}, i = g.lib = {}, p = i.Base = function() {
  63. function a() {}
  64. return {
  65. extend: function(f) {
  66. a.prototype = this;
  67. var c = new a;
  68. f && c.mixIn(f);
  69. c.$super = this;
  70. return c
  71. },
  72. create: function() {
  73. var a = this.extend();
  74. a.init.apply(a, arguments);
  75. return a
  76. },
  77. init: function() {},
  78. mixIn: function(a) {
  79. for (var c in a) a.hasOwnProperty(c) && (this[c] = a[c]);
  80. a.hasOwnProperty("toString") && (this.toString = a.toString)
  81. },
  82. clone: function() {
  83. return this.$super.extend(this)
  84. }
  85. }
  86. }(),
  87. m = i.WordArray = p.extend({
  88. init: function(a, f) {
  89. a =
  90. this.words = a || [];
  91. this.sigBytes = f != q ? f : 4 * a.length
  92. },
  93. toString: function(a) {
  94. return (a || r).stringify(this)
  95. },
  96. concat: function(a) {
  97. var f = this.words,
  98. c = a.words,
  99. d = this.sigBytes,
  100. a = a.sigBytes;
  101. this.clamp();
  102. if (d % 4)
  103. for (var b = 0; b < a; b++) f[d + b >>> 2] |= (c[b >>> 2] >>> 24 - 8 * (b % 4) & 255) << 24 - 8 * ((d + b) % 4);
  104. else if (65535 < c.length)
  105. for (b = 0; b < a; b += 4) f[d + b >>> 2] = c[b >>> 2];
  106. else f.push.apply(f, c);
  107. this.sigBytes += a;
  108. return this
  109. },
  110. clamp: function() {
  111. var a = this.words,
  112. b = this.sigBytes;
  113. a[b >>> 2] &= 4294967295 << 32 - 8 * (b % 4);
  114. a.length = l.ceil(b / 4)
  115. },
  116. clone: function() {
  117. var a =
  118. p.clone.call(this);
  119. a.words = this.words.slice(0);
  120. return a
  121. },
  122. random: function(a) {
  123. for (var b = [], c = 0; c < a; c += 4) b.push(4294967296 * l.random() | 0);
  124. return m.create(b, a)
  125. }
  126. }),
  127. n = g.enc = {}, r = n.Hex = {
  128. stringify: function(a) {
  129. for (var b = a.words, a = a.sigBytes, c = [], d = 0; d < a; d++) {
  130. var e = b[d >>> 2] >>> 24 - 8 * (d % 4) & 255;
  131. c.push((e >>> 4).toString(16));
  132. c.push((e & 15).toString(16))
  133. }
  134. return c.join("")
  135. },
  136. parse: function(a) {
  137. for (var b = a.length, c = [], d = 0; d < b; d += 2) c[d >>> 3] |= parseInt(a.substr(d, 2), 16) << 24 - 4 * (d % 8);
  138. return m.create(c, b / 2)
  139. }
  140. }, o = n.Latin1 = {
  141. stringify: function(a) {
  142. for (var b =
  143. a.words, a = a.sigBytes, c = [], d = 0; d < a; d++) c.push(String.fromCharCode(b[d >>> 2] >>> 24 - 8 * (d % 4) & 255));
  144. return c.join("")
  145. },
  146. parse: function(a) {
  147. for (var b = a.length, c = [], d = 0; d < b; d++) c[d >>> 2] |= (a.charCodeAt(d) & 255) << 24 - 8 * (d % 4);
  148. return m.create(c, b)
  149. }
  150. }, j = n.Utf8 = {
  151. stringify: function(a) {
  152. try {
  153. return decodeURIComponent(escape(o.stringify(a)))
  154. } catch (b) {
  155. throw Error("Malformed UTF-8 data");
  156. }
  157. },
  158. parse: function(a) {
  159. return o.parse(unescape(encodeURIComponent(a)))
  160. }
  161. }, b = i.BufferedBlockAlgorithm = p.extend({
  162. reset: function() {
  163. this._data = m.create();
  164. this._nDataBytes = 0
  165. },
  166. _append: function(a) {
  167. "string" == typeof a && (a = j.parse(a));
  168. this._data.concat(a);
  169. this._nDataBytes += a.sigBytes
  170. },
  171. _process: function(a) {
  172. var b = this._data,
  173. c = b.words,
  174. d = b.sigBytes,
  175. e = this.blockSize,
  176. h = d / (4 * e),
  177. h = a ? l.ceil(h) : l.max((h | 0) - this._minBufferSize, 0),
  178. a = h * e,
  179. d = l.min(4 * a, d);
  180. if (a) {
  181. for (var g = 0; g < a; g += e) this._doProcessBlock(c, g);
  182. g = c.splice(0, a);
  183. b.sigBytes -= d
  184. }
  185. return m.create(g, d)
  186. },
  187. clone: function() {
  188. var a = p.clone.call(this);
  189. a._data = this._data.clone();
  190. return a
  191. },
  192. _minBufferSize: 0
  193. });
  194. i.Hasher = b.extend({
  195. init: function() {
  196. this.reset()
  197. },
  198. reset: function() {
  199. b.reset.call(this);
  200. this._doReset()
  201. },
  202. update: function(a) {
  203. this._append(a);
  204. this._process();
  205. return this
  206. },
  207. finalize: function(a) {
  208. a && this._append(a);
  209. this._doFinalize();
  210. return this._hash
  211. },
  212. clone: function() {
  213. var a = b.clone.call(this);
  214. a._hash = this._hash.clone();
  215. return a
  216. },
  217. blockSize: 16,
  218. _createHelper: function(a) {
  219. return function(b, c) {
  220. return a.create(c).finalize(b)
  221. }
  222. },
  223. _createHmacHelper: function(a) {
  224. return function(b, c) {
  225. return e.HMAC.create(a, c).finalize(b)
  226. }
  227. }
  228. });
  229. var e = g.algo = {};
  230. return g
  231. }(Math);
  232. (function(l) {
  233. function q(b, e, a, f, c, d, g) {
  234. b = b + (e & a | ~e & f) + c + g;
  235. return (b << d | b >>> 32 - d) + e
  236. }
  237. function g(b, e, a, f, c, d, g) {
  238. b = b + (e & f | a & ~f) + c + g;
  239. return (b << d | b >>> 32 - d) + e
  240. }
  241. function i(b, e, a, f, c, d, g) {
  242. b = b + (e ^ a ^ f) + c + g;
  243. return (b << d | b >>> 32 - d) + e
  244. }
  245. function p(b, e, a, f, c, d, g) {
  246. b = b + (a ^ (e | ~f)) + c + g;
  247. return (b << d | b >>> 32 - d) + e
  248. }
  249. var m = __lask_client_mootools__CryptoJS,
  250. n = m.lib,
  251. r = n.WordArray,
  252. n = n.Hasher,
  253. o = m.algo,
  254. j = [];
  255. (function() {
  256. for (var b = 0; 64 > b; b++) j[b] = 4294967296 * l.abs(l.sin(b + 1)) | 0
  257. })();
  258. o = o.MD5 = n.extend({
  259. _doReset: function() {
  260. this._hash = r.create([1732584193, 4023233417,
  261. 2562383102, 271733878
  262. ])
  263. },
  264. _doProcessBlock: function(b, e) {
  265. for (var a = 0; 16 > a; a++) {
  266. var f = e + a,
  267. c = b[f];
  268. b[f] = (c << 8 | c >>> 24) & 16711935 | (c << 24 | c >>> 8) & 4278255360
  269. }
  270. for (var f = this._hash.words, c = f[0], d = f[1], k = f[2], h = f[3], a = 0; 64 > a; a += 4) 16 > a ? (c = q(c, d, k, h, b[e + a], 7, j[a]), h = q(h, c, d, k, b[e + a + 1], 12, j[a + 1]), k = q(k, h, c, d, b[e + a + 2], 17, j[a + 2]), d = q(d, k, h, c, b[e + a + 3], 22, j[a + 3])) : 32 > a ? (c = g(c, d, k, h, b[e + (a + 1) % 16], 5, j[a]), h = g(h, c, d, k, b[e + (a + 6) % 16], 9, j[a + 1]), k = g(k, h, c, d, b[e + (a + 11) % 16], 14, j[a + 2]), d = g(d, k, h, c, b[e + a % 16], 20, j[a + 3])) : 48 > a ? (c =
  271. i(c, d, k, h, b[e + (3 * a + 5) % 16], 4, j[a]), h = i(h, c, d, k, b[e + (3 * a + 8) % 16], 11, j[a + 1]), k = i(k, h, c, d, b[e + (3 * a + 11) % 16], 16, j[a + 2]), d = i(d, k, h, c, b[e + (3 * a + 14) % 16], 23, j[a + 3])) : (c = p(c, d, k, h, b[e + 3 * a % 16], 6, j[a]), h = p(h, c, d, k, b[e + (3 * a + 7) % 16], 10, j[a + 1]), k = p(k, h, c, d, b[e + (3 * a + 14) % 16], 15, j[a + 2]), d = p(d, k, h, c, b[e + (3 * a + 5) % 16], 21, j[a + 3]));
  272. f[0] = f[0] + c | 0;
  273. f[1] = f[1] + d | 0;
  274. f[2] = f[2] + k | 0;
  275. f[3] = f[3] + h | 0
  276. },
  277. _doFinalize: function() {
  278. var b = this._data,
  279. e = b.words,
  280. a = 8 * this._nDataBytes,
  281. f = 8 * b.sigBytes;
  282. e[f >>> 5] |= 128 << 24 - f % 32;
  283. e[(f + 64 >>> 9 << 4) + 14] = (a << 8 | a >>>
  284. 24) & 16711935 | (a << 24 | a >>> 8) & 4278255360;
  285. b.sigBytes = 4 * (e.length + 1);
  286. this._process();
  287. b = this._hash.words;
  288. for (e = 0; 4 > e; e++) a = b[e], b[e] = (a << 8 | a >>> 24) & 16711935 | (a << 24 | a >>> 8) & 4278255360
  289. }
  290. });
  291. m.MD5 = n._createHelper(o);
  292. m.HmacMD5 = n._createHmacHelper(o)
  293. })(Math);
  294. (function() {
  295. var l = __lask_client_mootools__CryptoJS,
  296. q = l.enc.Utf8;
  297. l.algo.HMAC = l.lib.Base.extend({
  298. init: function(g, i) {
  299. g = this._hasher = g.create();
  300. "string" == typeof i && (i = q.parse(i));
  301. var l = g.blockSize,
  302. m = 4 * l;
  303. i.sigBytes > m && (i = g.finalize(i));
  304. for (var n = this._oKey = i.clone(), r = this._iKey = i.clone(), o = n.words, j = r.words, b = 0; b < l; b++) o[b] ^= 1549556828, j[b] ^= 909522486;
  305. n.sigBytes = r.sigBytes = m;
  306. this.reset()
  307. },
  308. reset: function() {
  309. var g = this._hasher;
  310. g.reset();
  311. g.update(this._iKey)
  312. },
  313. update: function(g) {
  314. this._hasher.update(g);
  315. return this
  316. },
  317. finalize: function(g) {
  318. var i =
  319. this._hasher,
  320. g = i.finalize(g);
  321. i.reset();
  322. return i.finalize(this._oKey.clone().concat(g))
  323. }
  324. })
  325. })();