react / wstein / node_modules / jest-cli / node_modules / jsdom / node_modules / request / node_modules / hawk / lib / browser.js
81146 views/*1HTTP Hawk Authentication Scheme2Copyright (c) 2012-2014, Eran Hammer <[email protected]>3BSD Licensed4*/567// Declare namespace89var hawk = {10internals: {}11};121314hawk.client = {1516// Generate an Authorization header for a given request1718/*19uri: 'http://example.com/resource?a=b' or object generated by hawk.utils.parseUri()20method: HTTP verb (e.g. 'GET', 'POST')21options: {2223// Required2425credentials: {26id: 'dh37fgj492je',27key: 'aoijedoaijsdlaksjdl',28algorithm: 'sha256' // 'sha1', 'sha256'29},3031// Optional3233ext: 'application-specific', // Application specific data sent via the ext attribute34timestamp: Date.now() / 1000, // A pre-calculated timestamp in seconds35nonce: '2334f34f', // A pre-generated nonce36localtimeOffsetMsec: 400, // Time offset to sync with server time (ignored if timestamp provided)37payload: '{"some":"payload"}', // UTF-8 encoded string for body hash generation (ignored if hash provided)38contentType: 'application/json', // Payload content-type (ignored if hash provided)39hash: 'U4MKKSmiVxk37JCCrAVIjV=', // Pre-calculated payload hash40app: '24s23423f34dx', // Oz application id41dlg: '234sz34tww3sd' // Oz delegated-by application id42}43*/4445header: function (uri, method, options) {4647var result = {48field: '',49artifacts: {}50};5152// Validate inputs5354if (!uri || (typeof uri !== 'string' && typeof uri !== 'object') ||55!method || typeof method !== 'string' ||56!options || typeof options !== 'object') {5758result.err = 'Invalid argument type';59return result;60}6162// Application time6364var timestamp = options.timestamp || hawk.utils.now(options.localtimeOffsetMsec);6566// Validate credentials6768var credentials = options.credentials;69if (!credentials ||70!credentials.id ||71!credentials.key ||72!credentials.algorithm) {7374result.err = 'Invalid credentials object';75return result;76}7778if (hawk.crypto.algorithms.indexOf(credentials.algorithm) === -1) {79result.err = 'Unknown algorithm';80return result;81}8283// Parse URI8485if (typeof uri === 'string') {86uri = hawk.utils.parseUri(uri);87}8889// Calculate signature9091var artifacts = {92ts: timestamp,93nonce: options.nonce || hawk.utils.randomString(6),94method: method,95resource: uri.relative,96host: uri.hostname,97port: uri.port,98hash: options.hash,99ext: options.ext,100app: options.app,101dlg: options.dlg102};103104result.artifacts = artifacts;105106// Calculate payload hash107108if (!artifacts.hash &&109(options.payload || options.payload === '')) {110111artifacts.hash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, options.contentType);112}113114var mac = hawk.crypto.calculateMac('header', credentials, artifacts);115116// Construct header117118var hasExt = artifacts.ext !== null && artifacts.ext !== undefined && artifacts.ext !== ''; // Other falsey values allowed119var header = 'Hawk id="' + credentials.id +120'", ts="' + artifacts.ts +121'", nonce="' + artifacts.nonce +122(artifacts.hash ? '", hash="' + artifacts.hash : '') +123(hasExt ? '", ext="' + hawk.utils.escapeHeaderAttribute(artifacts.ext) : '') +124'", mac="' + mac + '"';125126if (artifacts.app) {127header += ', app="' + artifacts.app +128(artifacts.dlg ? '", dlg="' + artifacts.dlg : '') + '"';129}130131result.field = header;132133return result;134},135136// Generate a bewit value for a given URI137138/*139uri: 'http://example.com/resource?a=b'140options: {141142// Required143144credentials: {145id: 'dh37fgj492je',146key: 'aoijedoaijsdlaksjdl',147algorithm: 'sha256' // 'sha1', 'sha256'148},149ttlSec: 60 * 60, // TTL in seconds150151// Optional152153ext: 'application-specific', // Application specific data sent via the ext attribute154localtimeOffsetMsec: 400 // Time offset to sync with server time155};156*/157158bewit: function (uri, options) {159160// Validate inputs161162if (!uri ||163(typeof uri !== 'string') ||164!options ||165typeof options !== 'object' ||166!options.ttlSec) {167168return '';169}170171options.ext = (options.ext === null || options.ext === undefined ? '' : options.ext); // Zero is valid value172173// Application time174175var now = hawk.utils.now(options.localtimeOffsetMsec);176177// Validate credentials178179var credentials = options.credentials;180if (!credentials ||181!credentials.id ||182!credentials.key ||183!credentials.algorithm) {184185return '';186}187188if (hawk.crypto.algorithms.indexOf(credentials.algorithm) === -1) {189return '';190}191192// Parse URI193194uri = hawk.utils.parseUri(uri);195196// Calculate signature197198var exp = now + options.ttlSec;199var mac = hawk.crypto.calculateMac('bewit', credentials, {200ts: exp,201nonce: '',202method: 'GET',203resource: uri.relative, // Maintain trailing '?' and query params204host: uri.hostname,205port: uri.port,206ext: options.ext207});208209// Construct bewit: id\exp\mac\ext210211var bewit = credentials.id + '\\' + exp + '\\' + mac + '\\' + options.ext;212return hawk.utils.base64urlEncode(bewit);213},214215// Validate server response216217/*218request: object created via 'new XMLHttpRequest()' after response received219artifacts: object received from header().artifacts220options: {221payload: optional payload received222required: specifies if a Server-Authorization header is required. Defaults to 'false'223}224*/225226authenticate: function (request, credentials, artifacts, options) {227228options = options || {};229230var getHeader = function (name) {231232return request.getResponseHeader ? request.getResponseHeader(name) : request.getHeader(name);233};234235var wwwAuthenticate = getHeader('www-authenticate');236if (wwwAuthenticate) {237238// Parse HTTP WWW-Authenticate header239240var attributes = hawk.utils.parseAuthorizationHeader(wwwAuthenticate, ['ts', 'tsm', 'error']);241if (!attributes) {242return false;243}244245if (attributes.ts) {246var tsm = hawk.crypto.calculateTsMac(attributes.ts, credentials);247if (tsm !== attributes.tsm) {248return false;249}250251hawk.utils.setNtpOffset(attributes.ts - Math.floor((new Date()).getTime() / 1000)); // Keep offset at 1 second precision252}253}254255// Parse HTTP Server-Authorization header256257var serverAuthorization = getHeader('server-authorization');258if (!serverAuthorization &&259!options.required) {260261return true;262}263264var attributes = hawk.utils.parseAuthorizationHeader(serverAuthorization, ['mac', 'ext', 'hash']);265if (!attributes) {266return false;267}268269var modArtifacts = {270ts: artifacts.ts,271nonce: artifacts.nonce,272method: artifacts.method,273resource: artifacts.resource,274host: artifacts.host,275port: artifacts.port,276hash: attributes.hash,277ext: attributes.ext,278app: artifacts.app,279dlg: artifacts.dlg280};281282var mac = hawk.crypto.calculateMac('response', credentials, modArtifacts);283if (mac !== attributes.mac) {284return false;285}286287if (!options.payload &&288options.payload !== '') {289290return true;291}292293if (!attributes.hash) {294return false;295}296297var calculatedHash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, getHeader('content-type'));298return (calculatedHash === attributes.hash);299},300301message: function (host, port, message, options) {302303// Validate inputs304305if (!host || typeof host !== 'string' ||306!port || typeof port !== 'number' ||307message === null || message === undefined || typeof message !== 'string' ||308!options || typeof options !== 'object') {309310return null;311}312313// Application time314315var timestamp = options.timestamp || hawk.utils.now(options.localtimeOffsetMsec);316317// Validate credentials318319var credentials = options.credentials;320if (!credentials ||321!credentials.id ||322!credentials.key ||323!credentials.algorithm) {324325// Invalid credential object326return null;327}328329if (hawk.crypto.algorithms.indexOf(credentials.algorithm) === -1) {330return null;331}332333// Calculate signature334335var artifacts = {336ts: timestamp,337nonce: options.nonce || hawk.utils.randomString(6),338host: host,339port: port,340hash: hawk.crypto.calculatePayloadHash(message, credentials.algorithm)341};342343// Construct authorization344345var result = {346id: credentials.id,347ts: artifacts.ts,348nonce: artifacts.nonce,349hash: artifacts.hash,350mac: hawk.crypto.calculateMac('message', credentials, artifacts)351};352353return result;354},355356authenticateTimestamp: function (message, credentials, updateClock) { // updateClock defaults to true357358var tsm = hawk.crypto.calculateTsMac(message.ts, credentials);359if (tsm !== message.tsm) {360return false;361}362363if (updateClock !== false) {364hawk.utils.setNtpOffset(message.ts - Math.floor((new Date()).getTime() / 1000)); // Keep offset at 1 second precision365}366367return true;368}369};370371372hawk.crypto = {373374headerVersion: '1',375376algorithms: ['sha1', 'sha256'],377378calculateMac: function (type, credentials, options) {379380var normalized = hawk.crypto.generateNormalizedString(type, options);381382var hmac = CryptoJS['Hmac' + credentials.algorithm.toUpperCase()](normalized, credentials.key);383return hmac.toString(CryptoJS.enc.Base64);384},385386generateNormalizedString: function (type, options) {387388var normalized = 'hawk.' + hawk.crypto.headerVersion + '.' + type + '\n' +389options.ts + '\n' +390options.nonce + '\n' +391(options.method || '').toUpperCase() + '\n' +392(options.resource || '') + '\n' +393options.host.toLowerCase() + '\n' +394options.port + '\n' +395(options.hash || '') + '\n';396397if (options.ext) {398normalized += options.ext.replace('\\', '\\\\').replace('\n', '\\n');399}400401normalized += '\n';402403if (options.app) {404normalized += options.app + '\n' +405(options.dlg || '') + '\n';406}407408return normalized;409},410411calculatePayloadHash: function (payload, algorithm, contentType) {412413var hash = CryptoJS.algo[algorithm.toUpperCase()].create();414hash.update('hawk.' + hawk.crypto.headerVersion + '.payload\n');415hash.update(hawk.utils.parseContentType(contentType) + '\n');416hash.update(payload);417hash.update('\n');418return hash.finalize().toString(CryptoJS.enc.Base64);419},420421calculateTsMac: function (ts, credentials) {422423var hash = CryptoJS['Hmac' + credentials.algorithm.toUpperCase()]('hawk.' + hawk.crypto.headerVersion + '.ts\n' + ts + '\n', credentials.key);424return hash.toString(CryptoJS.enc.Base64);425}426};427428429// localStorage compatible interface430431hawk.internals.LocalStorage = function () {432433this._cache = {};434this.length = 0;435436this.getItem = function (key) {437438return this._cache.hasOwnProperty(key) ? String(this._cache[key]) : null;439};440441this.setItem = function (key, value) {442443this._cache[key] = String(value);444this.length = Object.keys(this._cache).length;445};446447this.removeItem = function (key) {448449delete this._cache[key];450this.length = Object.keys(this._cache).length;451};452453this.clear = function () {454455this._cache = {};456this.length = 0;457};458459this.key = function (i) {460461return Object.keys(this._cache)[i || 0];462};463};464465466hawk.utils = {467468storage: new hawk.internals.LocalStorage(),469470setStorage: function (storage) {471472var ntpOffset = hawk.utils.storage.getItem('hawk_ntp_offset');473hawk.utils.storage = storage;474if (ntpOffset) {475hawk.utils.setNtpOffset(ntpOffset);476}477},478479setNtpOffset: function (offset) {480481try {482hawk.utils.storage.setItem('hawk_ntp_offset', offset);483}484catch (err) {485console.error('[hawk] could not write to storage.');486console.error(err);487}488},489490getNtpOffset: function () {491492var offset = hawk.utils.storage.getItem('hawk_ntp_offset');493if (!offset) {494return 0;495}496497return parseInt(offset, 10);498},499500now: function (localtimeOffsetMsec) {501502return Math.floor(((new Date()).getTime() + (localtimeOffsetMsec || 0)) / 1000) + hawk.utils.getNtpOffset();503},504505escapeHeaderAttribute: function (attribute) {506507return attribute.replace(/\\/g, '\\\\').replace(/\"/g, '\\"');508},509510parseContentType: function (header) {511512if (!header) {513return '';514}515516return header.split(';')[0].replace(/^\s+|\s+$/g, '').toLowerCase();517},518519parseAuthorizationHeader: function (header, keys) {520521if (!header) {522return null;523}524525var headerParts = header.match(/^(\w+)(?:\s+(.*))?$/); // Header: scheme[ something]526if (!headerParts) {527return null;528}529530var scheme = headerParts[1];531if (scheme.toLowerCase() !== 'hawk') {532return null;533}534535var attributesString = headerParts[2];536if (!attributesString) {537return null;538}539540var attributes = {};541var verify = attributesString.replace(/(\w+)="([^"\\]*)"\s*(?:,\s*|$)/g, function ($0, $1, $2) {542543// Check valid attribute names544545if (keys.indexOf($1) === -1) {546return;547}548549// Allowed attribute value characters: !#$%&'()*+,-./:;<=>?@[]^_`{|}~ and space, a-z, A-Z, 0-9550551if ($2.match(/^[ \w\!#\$%&'\(\)\*\+,\-\.\/\:;<\=>\?@\[\]\^`\{\|\}~]+$/) === null) {552return;553}554555// Check for duplicates556557if (attributes.hasOwnProperty($1)) {558return;559}560561attributes[$1] = $2;562return '';563});564565if (verify !== '') {566return null;567}568569return attributes;570},571572randomString: function (size) {573574var randomSource = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';575var len = randomSource.length;576577var result = [];578for (var i = 0; i < size; ++i) {579result[i] = randomSource[Math.floor(Math.random() * len)];580}581582return result.join('');583},584585parseUri: function (input) {586587// Based on: parseURI 1.2.2588// http://blog.stevenlevithan.com/archives/parseuri589// (c) Steven Levithan <stevenlevithan.com>590// MIT License591592var keys = ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'hostname', 'port', 'resource', 'relative', 'pathname', 'directory', 'file', 'query', 'fragment'];593594var uriRegex = /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?(((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?)(?:#(.*))?)/;595var uriByNumber = input.match(uriRegex);596var uri = {};597598for (var i = 0, il = keys.length; i < il; ++i) {599uri[keys[i]] = uriByNumber[i] || '';600}601602if (uri.port === '') {603uri.port = (uri.protocol.toLowerCase() === 'http' ? '80' : (uri.protocol.toLowerCase() === 'https' ? '443' : ''));604}605606return uri;607},608609base64urlEncode: function (value) {610611var wordArray = CryptoJS.enc.Utf8.parse(value);612var encoded = CryptoJS.enc.Base64.stringify(wordArray);613return encoded.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');614}615};616617618// $lab:coverage:off$619620// Based on: Crypto-JS v3.1.2621// Copyright (c) 2009-2013, Jeff Mott. All rights reserved.622// http://code.google.com/p/crypto-js/623// http://code.google.com/p/crypto-js/wiki/License624625var CryptoJS = CryptoJS || function (h, r) { var k = {}, l = k.lib = {}, n = function () { }, f = l.Base = { extend: function (a) { n.prototype = this; var b = new n; a && b.mixIn(a); b.hasOwnProperty("init") || (b.init = function () { b.$super.init.apply(this, arguments) }); b.init.prototype = b; b.$super = this; return b }, create: function () { var a = this.extend(); a.init.apply(a, arguments); return a }, init: function () { }, mixIn: function (a) { for (var b in a) a.hasOwnProperty(b) && (this[b] = a[b]); a.hasOwnProperty("toString") && (this.toString = a.toString) }, clone: function () { return this.init.prototype.extend(this) } }, j = l.WordArray = f.extend({ init: function (a, b) { a = this.words = a || []; this.sigBytes = b != r ? b : 4 * a.length }, toString: function (a) { return (a || s).stringify(this) }, concat: function (a) { var b = this.words, d = a.words, c = this.sigBytes; a = a.sigBytes; this.clamp(); if (c % 4) for (var e = 0; e < a; e++) b[c + e >>> 2] |= (d[e >>> 2] >>> 24 - 8 * (e % 4) & 255) << 24 - 8 * ((c + e) % 4); else if (65535 < d.length) for (e = 0; e < a; e += 4) b[c + e >>> 2] = d[e >>> 2]; else b.push.apply(b, d); this.sigBytes += a; return this }, clamp: function () { var a = this.words, b = this.sigBytes; a[b >>> 2] &= 4294967295 << 32 - 8 * (b % 4); a.length = h.ceil(b / 4) }, clone: function () { var a = f.clone.call(this); a.words = this.words.slice(0); return a }, random: function (a) { for (var b = [], d = 0; d < a; d += 4) b.push(4294967296 * h.random() | 0); return new j.init(b, a) } }), m = k.enc = {}, s = m.Hex = { stringify: function (a) { var b = a.words; a = a.sigBytes; for (var d = [], c = 0; c < a; c++) { var e = b[c >>> 2] >>> 24 - 8 * (c % 4) & 255; d.push((e >>> 4).toString(16)); d.push((e & 15).toString(16)) } return d.join("") }, parse: function (a) { for (var b = a.length, d = [], c = 0; c < b; c += 2) d[c >>> 3] |= parseInt(a.substr(c, 2), 16) << 24 - 4 * (c % 8); return new j.init(d, b / 2) } }, p = m.Latin1 = { stringify: function (a) { var b = a.words; a = a.sigBytes; for (var d = [], c = 0; c < a; c++) d.push(String.fromCharCode(b[c >>> 2] >>> 24 - 8 * (c % 4) & 255)); return d.join("") }, parse: function (a) { for (var b = a.length, d = [], c = 0; c < b; c++) d[c >>> 2] |= (a.charCodeAt(c) & 255) << 24 - 8 * (c % 4); return new j.init(d, b) } }, t = m.Utf8 = { stringify: function (a) { try { return decodeURIComponent(escape(p.stringify(a))) } catch (b) { throw Error("Malformed UTF-8 data"); } }, parse: function (a) { return p.parse(unescape(encodeURIComponent(a))) } }, q = l.BufferedBlockAlgorithm = f.extend({ reset: function () { this._data = new j.init; this._nDataBytes = 0 }, _append: function (a) { "string" == typeof a && (a = t.parse(a)); this._data.concat(a); this._nDataBytes += a.sigBytes }, _process: function (a) { var b = this._data, d = b.words, c = b.sigBytes, e = this.blockSize, f = c / (4 * e), f = a ? h.ceil(f) : h.max((f | 0) - this._minBufferSize, 0); a = f * e; c = h.min(4 * a, c); if (a) { for (var g = 0; g < a; g += e) this._doProcessBlock(d, g); g = d.splice(0, a); b.sigBytes -= c } return new j.init(g, c) }, clone: function () { var a = f.clone.call(this); a._data = this._data.clone(); return a }, _minBufferSize: 0 }); l.Hasher = q.extend({ cfg: f.extend(), init: function (a) { this.cfg = this.cfg.extend(a); this.reset() }, reset: function () { q.reset.call(this); this._doReset() }, update: function (a) { this._append(a); this._process(); return this }, finalize: function (a) { a && this._append(a); return this._doFinalize() }, blockSize: 16, _createHelper: function (a) { return function (b, d) { return (new a.init(d)).finalize(b) } }, _createHmacHelper: function (a) { return function (b, d) { return (new u.HMAC.init(a, d)).finalize(b) } } }); var u = k.algo = {}; return k }(Math);626(function () { var k = CryptoJS, b = k.lib, m = b.WordArray, l = b.Hasher, d = [], b = k.algo.SHA1 = l.extend({ _doReset: function () { this._hash = new m.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) }, _doProcessBlock: function (n, p) { for (var a = this._hash.words, e = a[0], f = a[1], h = a[2], j = a[3], b = a[4], c = 0; 80 > c; c++) { if (16 > c) d[c] = n[p + c] | 0; else { var g = d[c - 3] ^ d[c - 8] ^ d[c - 14] ^ d[c - 16]; d[c] = g << 1 | g >>> 31 } g = (e << 5 | e >>> 27) + b + d[c]; g = 20 > c ? g + ((f & h | ~f & j) + 1518500249) : 40 > c ? g + ((f ^ h ^ j) + 1859775393) : 60 > c ? g + ((f & h | f & j | h & j) - 1894007588) : g + ((f ^ h ^ j) - 899497514); b = j; j = h; h = f << 30 | f >>> 2; f = e; e = g } a[0] = a[0] + e | 0; a[1] = a[1] + f | 0; a[2] = a[2] + h | 0; a[3] = a[3] + j | 0; a[4] = a[4] + b | 0 }, _doFinalize: function () { var b = this._data, d = b.words, a = 8 * this._nDataBytes, e = 8 * b.sigBytes; d[e >>> 5] |= 128 << 24 - e % 32; d[(e + 64 >>> 9 << 4) + 14] = Math.floor(a / 4294967296); d[(e + 64 >>> 9 << 4) + 15] = a; b.sigBytes = 4 * d.length; this._process(); return this._hash }, clone: function () { var b = l.clone.call(this); b._hash = this._hash.clone(); return b } }); k.SHA1 = l._createHelper(b); k.HmacSHA1 = l._createHmacHelper(b) })();627(function (k) { for (var g = CryptoJS, h = g.lib, v = h.WordArray, j = h.Hasher, h = g.algo, s = [], t = [], u = function (q) { return 4294967296 * (q - (q | 0)) | 0 }, l = 2, b = 0; 64 > b;) { var d; a: { d = l; for (var w = k.sqrt(d), r = 2; r <= w; r++) if (!(d % r)) { d = !1; break a } d = !0 } d && (8 > b && (s[b] = u(k.pow(l, 0.5))), t[b] = u(k.pow(l, 1 / 3)), b++); l++ } var n = [], h = h.SHA256 = j.extend({ _doReset: function () { this._hash = new v.init(s.slice(0)) }, _doProcessBlock: function (q, h) { for (var a = this._hash.words, c = a[0], d = a[1], b = a[2], k = a[3], f = a[4], g = a[5], j = a[6], l = a[7], e = 0; 64 > e; e++) { if (16 > e) n[e] = q[h + e] | 0; else { var m = n[e - 15], p = n[e - 2]; n[e] = ((m << 25 | m >>> 7) ^ (m << 14 | m >>> 18) ^ m >>> 3) + n[e - 7] + ((p << 15 | p >>> 17) ^ (p << 13 | p >>> 19) ^ p >>> 10) + n[e - 16] } m = l + ((f << 26 | f >>> 6) ^ (f << 21 | f >>> 11) ^ (f << 7 | f >>> 25)) + (f & g ^ ~f & j) + t[e] + n[e]; p = ((c << 30 | c >>> 2) ^ (c << 19 | c >>> 13) ^ (c << 10 | c >>> 22)) + (c & d ^ c & b ^ d & b); l = j; j = g; g = f; f = k + m | 0; k = b; b = d; d = c; c = m + p | 0 } a[0] = a[0] + c | 0; a[1] = a[1] + d | 0; a[2] = a[2] + b | 0; a[3] = a[3] + k | 0; a[4] = a[4] + f | 0; a[5] = a[5] + g | 0; a[6] = a[6] + j | 0; a[7] = a[7] + l | 0 }, _doFinalize: function () { var d = this._data, b = d.words, a = 8 * this._nDataBytes, c = 8 * d.sigBytes; b[c >>> 5] |= 128 << 24 - c % 32; b[(c + 64 >>> 9 << 4) + 14] = k.floor(a / 4294967296); b[(c + 64 >>> 9 << 4) + 15] = a; d.sigBytes = 4 * b.length; this._process(); return this._hash }, clone: function () { var b = j.clone.call(this); b._hash = this._hash.clone(); return b } }); g.SHA256 = j._createHelper(h); g.HmacSHA256 = j._createHmacHelper(h) })(Math);628(function () { var c = CryptoJS, k = c.enc.Utf8; c.algo.HMAC = c.lib.Base.extend({ init: function (a, b) { a = this._hasher = new a.init; "string" == typeof b && (b = k.parse(b)); var c = a.blockSize, e = 4 * c; b.sigBytes > e && (b = a.finalize(b)); b.clamp(); for (var f = this._oKey = b.clone(), g = this._iKey = b.clone(), h = f.words, j = g.words, d = 0; d < c; d++) h[d] ^= 1549556828, j[d] ^= 909522486; f.sigBytes = g.sigBytes = e; this.reset() }, reset: function () { var a = this._hasher; a.reset(); a.update(this._iKey) }, update: function (a) { this._hasher.update(a); return this }, finalize: function (a) { var b = this._hasher; a = b.finalize(a); b.reset(); return b.finalize(this._oKey.clone().concat(a)) } }) })();629(function () { var h = CryptoJS, j = h.lib.WordArray; h.enc.Base64 = { stringify: function (b) { var e = b.words, f = b.sigBytes, c = this._map; b.clamp(); b = []; for (var a = 0; a < f; a += 3) for (var d = (e[a >>> 2] >>> 24 - 8 * (a % 4) & 255) << 16 | (e[a + 1 >>> 2] >>> 24 - 8 * ((a + 1) % 4) & 255) << 8 | e[a + 2 >>> 2] >>> 24 - 8 * ((a + 2) % 4) & 255, g = 0; 4 > g && a + 0.75 * g < f; g++) b.push(c.charAt(d >>> 6 * (3 - g) & 63)); if (e = c.charAt(64)) for (; b.length % 4;) b.push(e); return b.join("") }, parse: function (b) { var e = b.length, f = this._map, c = f.charAt(64); c && (c = b.indexOf(c), -1 != c && (e = c)); for (var c = [], a = 0, d = 0; d < e; d++) if (d % 4) { var g = f.indexOf(b.charAt(d - 1)) << 2 * (d % 4), h = f.indexOf(b.charAt(d)) >>> 6 - 2 * (d % 4); c[a >>> 2] |= (g | h) << 24 - 8 * (a % 4); a++ } return j.create(c, a) }, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" } })();630631hawk.crypto.internals = CryptoJS;632633634// Export if used as a module635636if (typeof module !== 'undefined' && module.exports) {637module.exports = hawk;638}639640// $lab:coverage:on$641642643