From 22ee8b36bb164c1c2dab7960f4302d83363834fa Mon Sep 17 00:00:00 2001 From: Zachary Carter Date: Tue, 9 Dec 2014 12:00:27 -0800 Subject: [PATCH] Built fxa-js-client from commit 8880bbc on branch master --- fxa-client.js | 12 ++++++++++-- fxa-client.min.js | 2 +- fxa-client.min.js.map | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/fxa-client.js b/fxa-client.js index 1e78f39..5f5b0ab 100644 --- a/fxa-client.js +++ b/fxa-client.js @@ -2015,7 +2015,15 @@ define('client/FxAccountClient',[ } } - return self.request.send(endpoint, 'POST', null, data, requestOpts); + return self.request.send(endpoint, 'POST', null, data, requestOpts) + .then( + function(accountData) { + if (options && options.keys) { + accountData.unwrapBKey = sjcl.codec.hex.fromBits(result.unwrapBKey); + } + return accountData; + } + ); } ); }; @@ -2495,7 +2503,7 @@ define('client/FxAccountClient',[ * @method certificateSign * @param {String} sessionToken User session token * @param {Object} publicKey The key to sign - * @param {int} duration Time interval from now when the certificate will expire in seconds + * @param {int} duration Time interval from now when the certificate will expire in milliseconds * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request */ FxAccountClient.prototype.certificateSign = function(sessionToken, publicKey, duration) { diff --git a/fxa-client.min.js b/fxa-client.min.js index 468a517..a5de4e9 100644 --- a/fxa-client.min.js +++ b/fxa-client.min.js @@ -1,2 +1,2 @@ -!function(e,t){"function"==typeof define&&define.amd?define([],t):e.FxAccountClient=t()}(this,function(){var e,t,r;return function(n){function o(e,t){return b.call(e,t)}function i(e,t){var r,n,o,i,s,a,c,u,f,l,h=t&&t.split("/"),p=v.map,d=p&&p["*"]||{};if(e&&"."===e.charAt(0))if(t){for(h=h.slice(0,h.length-1),e=h.concat(e.split("/")),u=0;u0&&(e.splice(u-1,2),u-=2)}e=e.join("/")}else 0===e.indexOf("./")&&(e=e.substring(2));if((h||d)&&p){for(r=e.split("/"),u=r.length;u>0;u-=1){if(n=r.slice(0,u).join("/"),h)for(f=h.length;f>0;f-=1)if(o=p[h.slice(0,f).join("/")],o&&(o=o[n])){i=o,s=u;break}if(i)break;!a&&d&&d[n]&&(a=d[n],c=u)}!i&&a&&(i=a,s=c),i&&(r.splice(0,s,i),e=r.join("/"))}return e}function s(e,t){return function(){return p.apply(n,T.call(arguments,0).concat([e,t]))}}function a(e){return function(t){return i(t,e)}}function c(e){return function(t){y[e]=t}}function u(e){if(o(g,e)){var t=g[e];delete g[e],w[e]=!0,h.apply(n,t)}if(!o(y,e)&&!o(w,e))throw new Error("No "+e);return y[e]}function f(e){var t,r=e?e.indexOf("!"):-1;return r>-1&&(t=e.substring(0,r),e=e.substring(r+1,e.length)),[t,e]}function l(e){return function(){return v&&v.config&&v.config[e]||{}}}var h,p,d,m,y={},g={},v={},w={},b=Object.prototype.hasOwnProperty,T=[].slice;d=function(e,t){var r,n=f(e),o=n[0];return e=n[1],o&&(o=i(o,t),r=u(o)),o?e=r&&r.normalize?r.normalize(e,a(t)):i(e,t):(e=i(e,t),n=f(e),o=n[0],e=n[1],o&&(r=u(o))),{f:o?o+"!"+e:e,n:e,pr:o,p:r}},m={require:function(e){return s(e)},exports:function(e){var t=y[e];return"undefined"!=typeof t?t:y[e]={}},module:function(e){return{id:e,uri:"",exports:y[e],config:l(e)}}},h=function(e,t,r,i){var a,f,l,h,p,v,b=[];if(i=i||e,"function"==typeof r){for(t=!t.length&&r.length?["require","exports","module"]:t,p=0;pl;l++)c=e[i>>>24]^m[s>>16&255]^y[a>>8&255]^g[255&t]^o[p],u=e[s>>>24]^m[a>>16&255]^y[t>>8&255]^g[255&i]^o[p+1],f=e[a>>>24]^m[t>>16&255]^y[i>>8&255]^g[255&s]^o[p+2],t=e[t>>>24]^m[i>>16&255]^y[s>>8&255]^g[255&a]^o[p+3],p+=4,i=c,s=u,a=f;for(l=0;4>l;l++)d[n?3&-l:l]=v[i>>>24]<<24^v[s>>16&255]<<16^v[a>>8&255]<<8^v[255&t]^o[p++],c=i,i=s,s=a,a=t,t=c;return d}function t(e,t){var r,n,o,i=t.slice(0),s=e.f,a=e.e,c=s[0],u=s[1],f=s[2],l=s[3],h=s[4],p=s[5],d=s[6],m=s[7];for(r=0;64>r;r++)16>r?n=i[r]:(n=i[r+1&15],o=i[r+14&15],n=i[15&r]=(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(o>>>17^o>>>19^o>>>10^o<<15^o<<13)+i[15&r]+i[r+9&15]|0),n=n+m+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(d^h&(p^d))+a[r],m=d,d=p,p=h,h=l+n|0,l=f,f=u,u=c,c=n+(u&f^l&(u^f))+(u>>>2^u>>>13^u>>>22^u<<30^u<<19^u<<10)|0;s[0]=s[0]+c|0,s[1]=s[1]+u|0,s[2]=s[2]+f|0,s[3]=s[3]+l|0,s[4]=s[4]+h|0,s[5]=s[5]+p|0,s[6]=s[6]+d|0,s[7]=s[7]+m|0}var r={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(e){this.toString=function(){return"CORRUPT: "+this.message},this.message=e},invalid:function(e){this.toString=function(){return"INVALID: "+this.message},this.message=e},bug:function(e){this.toString=function(){return"BUG: "+this.message},this.message=e},notReady:function(e){this.toString=function(){return"NOT READY: "+this.message},this.message=e}}};return"undefined"!=typeof module&&module.exports&&(module.exports=r),r.cipher.aes=function(e){this.b[0][0][0]||this.g();var t,n,o,i,s=this.b[0][4],a=this.b[1];t=e.length;var c=1;if(4!==t&&6!==t&&8!==t)throw new r.exception.invalid("invalid aes key size");for(this.e=[o=e.slice(0),i=[]],e=t;4*t+28>e;e++)n=o[e-1],(0===e%t||8===t&&4===e%t)&&(n=s[n>>>24]<<24^s[n>>16&255]<<16^s[n>>8&255]<<8^s[255&n],0===e%t&&(n=n<<8^n>>>24^c<<24,c=c<<1^283*(c>>7))),o[e]=o[e-t]^n;for(t=0;e;t++,e--)n=o[3&t?e:e-4],i[t]=4>=e||4>t?n:a[0][s[n>>>24]]^a[1][s[n>>16&255]]^a[2][s[n>>8&255]]^a[3][s[255&n]]},r.cipher.aes.prototype={encrypt:function(t){return e(this,t,0)},decrypt:function(t){return e(this,t,1)},b:[[[],[],[],[],[]],[[],[],[],[],[]]],g:function(){var e,t,r,n,o,i,s,a=this.b[0],c=this.b[1],u=a[4],f=c[4],l=[],h=[];for(e=0;256>e;e++)h[(l[e]=e<<1^283*(e>>7))^e]=e;for(t=r=0;!u[t];t^=n||1,r=h[r]||1)for(i=r^r<<1^r<<2^r<<3^r<<4,i=i>>8^255&i^99,u[t]=i,f[i]=t,o=l[e=l[n=l[t]]],s=16843009*o^65537*e^257*n^16843008*t,o=257*l[i]^16843008*i,e=0;4>e;e++)a[e][t]=o=o<<24^o>>>8,c[e][i]=s=s<<24^s>>>8;for(e=0;5>e;e++)a[e]=a[e].slice(0),c[e]=c[e].slice(0)}},r.bitArray={bitSlice:function(e,t,n){return e=r.bitArray.l(e.slice(t/32),32-(31&t)).slice(1),void 0===n?e:r.bitArray.clamp(e,n-t)},extract:function(e,t,r){var n=Math.floor(-t-r&31);return(-32&(t+r-1^t)?e[t/32|0]<<32-n^e[t/32+1|0]>>>n:e[t/32|0]>>>n)&(1<0&&t&&(e[n-1]=r.bitArray.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:function(e,t,r){return 32===e?t:(r?0|t:t<<32-e)+1099511627776*e},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(e,t){if(r.bitArray.bitLength(e)!==r.bitArray.bitLength(t))return!1;var n,o=0;for(n=0;n=32;t-=32)o.push(n),n=0;if(0===t)return o.concat(e);for(i=0;i>>t),n=e[i]<<32-t;return i=e.length?e[e.length-1]:0,e=r.bitArray.getPartial(i),o.push(r.bitArray.partial(t+e&31,t+e>32?n:o.pop(),1)),o},n:function(e,t){return[e[0]^t[0],e[1]^t[1],e[2]^t[2],e[3]^t[3]]}},r.codec.utf8String={fromBits:function(e){var t,n,o="",i=r.bitArray.bitLength(e);for(t=0;i/8>t;t++)0===(3&t)&&(n=e[t/4]),o+=String.fromCharCode(n>>>24),n<<=8;return decodeURIComponent(escape(o))},toBits:function(e){e=unescape(encodeURIComponent(e));var t,n=[],o=0;for(t=0;t>>i)>>>26),6>i?(a=e[n]<<6-i,i+=26,n++):(a<<=6,i-=6);for(;3&o.length&&!t;)o+="=";return o},toBits:function(e,t){e=e.replace(/\s|=/g,"");var n,o,i=[],s=0,a=r.codec.base64.i,c=0;for(t&&(a=a.substr(0,62)+"-_"),n=0;no)throw new r.exception.invalid("this isn't base64!");s>26?(s-=26,i.push(c^o>>>s),c=o<<32-s):(s+=6,c^=o<<32-s)}return 56&s&&i.push(r.bitArray.partial(56&s,c,1)),i}},r.codec.base64url={fromBits:function(e){return r.codec.base64.fromBits(e,1,1)},toBits:function(e){return r.codec.base64.toBits(e,1)}},r.hash.sha256=function(e){this.e[0]||this.g(),e?(this.f=e.f.slice(0),this.d=e.d.slice(0),this.a=e.a):this.reset()},r.hash.sha256.hash=function(e){return(new r.hash.sha256).update(e).finalize()},r.hash.sha256.prototype={blockSize:512,reset:function(){return this.f=this.k.slice(0),this.d=[],this.a=0,this},update:function(e){"string"==typeof e&&(e=r.codec.utf8String.toBits(e));var n,o=this.d=r.bitArray.concat(this.d,e);for(n=this.a,e=this.a=n+r.bitArray.bitLength(e),n=512+n&-512;e>=n;n+=512)t(this,o.splice(0,16));return this},finalize:function(){var e,n=this.d,o=this.f,n=r.bitArray.concat(n,[r.bitArray.partial(1,1)]);for(e=n.length+2;15&e;e++)n.push(0);for(n.push(Math.floor(this.a/4294967296)),n.push(0|this.a);n.length;)t(this,n.splice(0,16));return this.reset(),o},k:[],e:[],g:function(){function e(e){return 4294967296*(e-Math.floor(e))|0}var t,r=0,n=2;e:for(;64>r;n++){for(t=2;n>=t*t;t++)if(0===n%t)continue e;8>r&&(this.k[r]=e(Math.pow(n,.5))),this.e[r]=e(Math.pow(n,1/3)),r++}}},r.misc.hmac=function(e,t){this.j=t=t||r.hash.sha256;var n,o=[[],[]],i=t.prototype.blockSize/32;for(this.c=[new t,new t],e.length>i&&(e=t.hash(e)),n=0;i>n;n++)o[0][n]=909522486^e[n],o[1][n]=1549556828^e[n];this.c[0].update(o[0]),this.c[1].update(o[1]),this.h=new t(this.c[0])},r.misc.hmac.prototype.encrypt=r.misc.hmac.prototype.mac=function(e){if(this.m)throw new r.exception.invalid("encrypt on already updated hmac called!");return this.update(e),this.digest(e)},r.misc.hmac.prototype.reset=function(){this.h=new this.j(this.c[0]),this.m=!1},r.misc.hmac.prototype.update=function(e){this.m=!0,this.h.update(e)},r.misc.hmac.prototype.digest=function(){var e=this.h.finalize(),e=new this.j(this.c[1]).update(e).finalize();return this.reset(),e},r.misc.pbkdf2=function(e,t,n,o,i){if(n=n||1e3,0>o||0>n)throw r.exception.invalid("invalid params to pbkdf2");"string"==typeof e&&(e=r.codec.utf8String.toBits(e)),"string"==typeof t&&(t=r.codec.utf8String.toBits(t)),i=i||r.misc.hmac,e=new i(e);var s,a,c,u,f=[],l=r.bitArray;for(u=1;32*f.length<(o||1);u++){for(i=s=e.encrypt(l.concat(t,[u])),a=1;n>a;a++)for(s=e.encrypt(s),c=0;c\?@\[\]\^`\{\|\}~]+$/)||i.hasOwnProperty(r)?void 0:(i[r]=n,"")});return""!==s?null:i},randomString:function(e){for(var t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=t.length,n=[],o=0;e>o;++o)n[o]=t[Math.floor(Math.random()*r)];return n.join("")},baseIndexOf:function(e,t,r){for(var n=(r||0)-1,o=e?e.length:0;++nr;++r)r in e&&t(e[r],r)}function u(e){a(function(){if(!f.onerror)throw e;f.onerror.call(null,e)})}function f(e){return e instanceof v?e:d(new v,e)}function l(e,t,r,n){return e._state?e:(e._state=t,e._value=r,n?e._domain=n:B&&t===L&&(e._domain=process.domain),e._pending.length&&c(e._pending,R),e._pending=null,e)}function h(e,t){e._pending.push(t)}function p(e,t){l(t,e._state,e._value,e._domain)}function d(e,t){return e._state?e:(t instanceof v?t===e?l(e,L,new TypeError("You can't resolve a promise with itself")):t._state?p(t,e):h(t,function(){p(t,e)}):t!==Object(t)?l(e,F,t):S(function(){var r=m(e);try{var n=t.then;"function"==typeof n?j.call(n,t,r.resolve,r.reject):l(e,F,t)}catch(o){r.reject(o)}}),e)}function m(e){var t=!1;return{promise:e,resolve:function(r){t||(t=!0,d(e,r))},reject:function(r){t||(t=!0,l(e,L,r))}}}function y(){return m(new v)}function g(e){return l(new v,L,e)}function v(){this._state=0,this._value=void 0,this._domain=null,this._pending=[]}function w(e){function t(t){return e(t,[])}function r(e){return f(e).then(t)}return r._=e,r}function b(e,t){var r=0,n=new v;return c(e,function(e,o){var i=f(e);i._state===K?(++r,h(i,function(){t[o]=i.inspect(),0===--r&&l(n,F,t)})):t[o]=i.inspect()}),0===r&&l(n,F,t),n}function T(e,t){var r=0,n=y();return c(e,function(e,o){var i=f(e);i._state===F?t[o]=i._value:(++r,i.then(function(e){t[o]=e,0===--r&&n.resolve(t)},n.reject))}),0===r&&n.resolve(t),n.promise}function k(e){function t(t){return I.apply(e,t)}return function(){var e=T(arguments,[]);return T([this,e],[]).then(t)}}var x,S,_,B=e(typeof process)&&"[object process]"==={}.toString.call(process),A=e(typeof setImmediate),C={f:null,n:null},O=C,M=!1,P=B&&o||i(n)||s(n),q=[],E=s(r),j=e.call,I=e.apply,R=function(e){O=O.n={f:e,n:null},M||(M=!0,P())};B?(x=function(e){var t=process.domain;return function(){if(t){if(t._disposed)return;t.enter()}try{e.call()}catch(r){throw P(),r}t&&t.exit()}},S=function(e){var t=process.domain;R(t?function(){t._disposed||(t.enter(),e.call(),t.exit())}:e)}):(x=function(e){return function(){try{e.call()}catch(t){q.push(t),E()}}},S=R);var K=0,F=1,L=2;return f.defer=y,f.reject=g,v.prototype.then=function(e,t){function r(){var e=i._state===F?n:o;if(!e)return void p(i,s);var t,r=!1,c=i._domain||a;if(c){if(c._disposed)return;c.enter()}try{t=e(i._value)}catch(u){r=!0,l(s,L,u)}r||d(s,t),c&&c.exit()}var n="function"==typeof e?e:null,o="function"==typeof t?t:null,i=this,s=new v,a=B&&process.domain;return i._state===K?h(i,r):R(r),s},v.prototype.done=function(e,t){var r=this;(e||t)&&(r=r.then(e,t)),r.then(null,u)},v.prototype.fail=function(e){return this.then(null,e)},v.prototype.spread=function(e,t){return this.then(e&&function(r){return T(r,[]).then(function(t){return I.call(e,void 0,t)},t)},t)},v.prototype.timeout=function(e,t){var r=this,n=new v;if(r._state!==K)p(r,n);else{var o=setTimeout(function(){l(n,L,new Error(t||"Timed out after "+e+" ms"))},e);h(r,function(){clearTimeout(o),p(r,n)})}return n},v.prototype.delay=function(e){var t=y();return this.then(function(r){setTimeout(function(){t.resolve(r)},e)},t.reject),t.promise},v.prototype.inspect=function(){switch(this._state){case K:return{state:"pending"};case F:return{state:"fulfilled",value:this._value};case L:return{state:"rejected",reason:this._value};default:throw new TypeError("invalid state")}},f.allSettled=w(b),f.all=w(T),f.promised=k,f.onerror=null,f.nextTick=a,f}),r("client/lib/errors",[],function(){return{INVALID_TIMESTAMP:111,INCORRECT_EMAIL_CASE:120}}),r("client/lib/request",["./hawk","p","./errors"],function(e,t,r){function n(e,t,r){r||(r={}),this.baseUri=e,this._localtimeOffsetMsec=r.localtimeOffsetMsec,this.xhr=t||XMLHttpRequest,this.timeout=r.timeout||3e4}return n.prototype.send=function(n,o,i,s,a){var c=t.defer(),u=new this.xhr,f=this.baseUri+n,l=null,h=this;a=a||{},s&&(l=JSON.stringify(s));try{u.open(o,f)}catch(p){c.reject({error:"Unknown error",message:p.toString(),errno:999})}if(u.timeout=this.timeout,u.onreadystatechange=function(){if(4===u.readyState){var e=u.responseText;try{e=JSON.parse(u.responseText)}catch(t){}if(e.errno){if(e.errno!==r.INVALID_TIMESTAMP||a.retrying)return c.reject(e);var f=e.serverTime;return h._localtimeOffsetMsec=1e3*f-(new Date).getTime(),a.retrying=!0,h.send(n,o,i,s,a).then(c.resolve,c.reject)}if("undefined"==typeof u.status||200!==u.status)return c.reject(0===e.length?{error:"Timeout error",errno:999}:{error:"Unknown error",message:e,errno:999,code:u.status});c.resolve(e)}},i){var d=e.client.header(f,o,{credentials:i,payload:l,contentType:"application/json",localtimeOffsetMsec:this._localtimeOffsetMsec||0});u.setRequestHeader("authorization",d.field)}if(u.setRequestHeader("Content-Type","application/json"),a&&a.headers)for(var m in a.headers)u.setRequestHeader(m,a.headers[m]);return u.send(l),c.promise},n}),r("client/lib/hkdf",["sjcl","p"],function(e,t){function r(r,n,o,i){var s=new e.misc.hmac(o,e.hash.sha256);s.update(r);for(var a=s.digest(),c=32,u=Math.ceil(i/c),f=e.codec.hex.toBits(""),l="",h=0;u>h;h++){var p=new e.misc.hmac(a,e.hash.sha256),d=e.bitArray.concat(e.bitArray.concat(f,n),e.codec.utf8String.toBits(String.fromCharCode(h+1)));p.update(d),f=p.digest(),l+=e.codec.hex.fromBits(f)}var m=e.bitArray.clamp(e.codec.hex.toBits(l),8*i);return t(m)}return r}),r("client/lib/pbkdf2",["sjcl","p"],function(e,t){var r={derive:function(r,n,o,i){var s=e.misc.pbkdf2(r,n,o,i,e.misc.hmac);return t(s)}};return r}),r("client/lib/credentials",["./request","sjcl","p","./hkdf","./pbkdf2"],function(e,t,r,n,o){function i(e){return t.codec.utf8String.toBits(a+e)}function s(e,r){return t.codec.utf8String.toBits(a+e+":"+r)}var a="identity.mozilla.com/picl/v1/",c=1e3,u=256,f=t.codec.hex.toBits("00"),l=32;return{setup:function(e,r){var a={},h=s("quickStretch",e),p=t.codec.utf8String.toBits(r);return a.emailUTF8=e,a.passwordUTF8=r,o.derive(p,h,c,u).then(function(e){return a.quickStretchedPW=e,n(e,i("authPW"),f,l).then(function(t){return a.authPW=t,n(e,i("unwrapBkey"),f,l)})}).then(function(e){return a.unwrapBKey=e,a})},xor:function(e,t){for(var r=[],n=0;n0&&(e.splice(u-1,2),u-=2)}e=e.join("/")}else 0===e.indexOf("./")&&(e=e.substring(2));if((l||d)&&p){for(r=e.split("/"),u=r.length;u>0;u-=1){if(n=r.slice(0,u).join("/"),l)for(f=l.length;f>0;f-=1)if(o=p[l.slice(0,f).join("/")],o&&(o=o[n])){i=o,s=u;break}if(i)break;!a&&d&&d[n]&&(a=d[n],c=u)}!i&&a&&(i=a,s=c),i&&(r.splice(0,s,i),e=r.join("/"))}return e}function s(e,t){return function(){return p.apply(n,T.call(arguments,0).concat([e,t]))}}function a(e){return function(t){return i(t,e)}}function c(e){return function(t){y[e]=t}}function u(e){if(o(g,e)){var t=g[e];delete g[e],w[e]=!0,l.apply(n,t)}if(!o(y,e)&&!o(w,e))throw new Error("No "+e);return y[e]}function f(e){var t,r=e?e.indexOf("!"):-1;return r>-1&&(t=e.substring(0,r),e=e.substring(r+1,e.length)),[t,e]}function h(e){return function(){return v&&v.config&&v.config[e]||{}}}var l,p,d,m,y={},g={},v={},w={},b=Object.prototype.hasOwnProperty,T=[].slice;d=function(e,t){var r,n=f(e),o=n[0];return e=n[1],o&&(o=i(o,t),r=u(o)),o?e=r&&r.normalize?r.normalize(e,a(t)):i(e,t):(e=i(e,t),n=f(e),o=n[0],e=n[1],o&&(r=u(o))),{f:o?o+"!"+e:e,n:e,pr:o,p:r}},m={require:function(e){return s(e)},exports:function(e){var t=y[e];return"undefined"!=typeof t?t:y[e]={}},module:function(e){return{id:e,uri:"",exports:y[e],config:h(e)}}},l=function(e,t,r,i){var a,f,h,l,p,v,b=[];if(i=i||e,"function"==typeof r){for(t=!t.length&&r.length?["require","exports","module"]:t,p=0;ph;h++)c=e[i>>>24]^m[s>>16&255]^y[a>>8&255]^g[255&t]^o[p],u=e[s>>>24]^m[a>>16&255]^y[t>>8&255]^g[255&i]^o[p+1],f=e[a>>>24]^m[t>>16&255]^y[i>>8&255]^g[255&s]^o[p+2],t=e[t>>>24]^m[i>>16&255]^y[s>>8&255]^g[255&a]^o[p+3],p+=4,i=c,s=u,a=f;for(h=0;4>h;h++)d[n?3&-h:h]=v[i>>>24]<<24^v[s>>16&255]<<16^v[a>>8&255]<<8^v[255&t]^o[p++],c=i,i=s,s=a,a=t,t=c;return d}function t(e,t){var r,n,o,i=t.slice(0),s=e.f,a=e.e,c=s[0],u=s[1],f=s[2],h=s[3],l=s[4],p=s[5],d=s[6],m=s[7];for(r=0;64>r;r++)16>r?n=i[r]:(n=i[r+1&15],o=i[r+14&15],n=i[15&r]=(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(o>>>17^o>>>19^o>>>10^o<<15^o<<13)+i[15&r]+i[r+9&15]|0),n=n+m+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(d^l&(p^d))+a[r],m=d,d=p,p=l,l=h+n|0,h=f,f=u,u=c,c=n+(u&f^h&(u^f))+(u>>>2^u>>>13^u>>>22^u<<30^u<<19^u<<10)|0;s[0]=s[0]+c|0,s[1]=s[1]+u|0,s[2]=s[2]+f|0,s[3]=s[3]+h|0,s[4]=s[4]+l|0,s[5]=s[5]+p|0,s[6]=s[6]+d|0,s[7]=s[7]+m|0}var r={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(e){this.toString=function(){return"CORRUPT: "+this.message},this.message=e},invalid:function(e){this.toString=function(){return"INVALID: "+this.message},this.message=e},bug:function(e){this.toString=function(){return"BUG: "+this.message},this.message=e},notReady:function(e){this.toString=function(){return"NOT READY: "+this.message},this.message=e}}};return"undefined"!=typeof module&&module.exports&&(module.exports=r),r.cipher.aes=function(e){this.b[0][0][0]||this.g();var t,n,o,i,s=this.b[0][4],a=this.b[1];t=e.length;var c=1;if(4!==t&&6!==t&&8!==t)throw new r.exception.invalid("invalid aes key size");for(this.e=[o=e.slice(0),i=[]],e=t;4*t+28>e;e++)n=o[e-1],(0===e%t||8===t&&4===e%t)&&(n=s[n>>>24]<<24^s[n>>16&255]<<16^s[n>>8&255]<<8^s[255&n],0===e%t&&(n=n<<8^n>>>24^c<<24,c=c<<1^283*(c>>7))),o[e]=o[e-t]^n;for(t=0;e;t++,e--)n=o[3&t?e:e-4],i[t]=4>=e||4>t?n:a[0][s[n>>>24]]^a[1][s[n>>16&255]]^a[2][s[n>>8&255]]^a[3][s[255&n]]},r.cipher.aes.prototype={encrypt:function(t){return e(this,t,0)},decrypt:function(t){return e(this,t,1)},b:[[[],[],[],[],[]],[[],[],[],[],[]]],g:function(){var e,t,r,n,o,i,s,a=this.b[0],c=this.b[1],u=a[4],f=c[4],h=[],l=[];for(e=0;256>e;e++)l[(h[e]=e<<1^283*(e>>7))^e]=e;for(t=r=0;!u[t];t^=n||1,r=l[r]||1)for(i=r^r<<1^r<<2^r<<3^r<<4,i=i>>8^255&i^99,u[t]=i,f[i]=t,o=h[e=h[n=h[t]]],s=16843009*o^65537*e^257*n^16843008*t,o=257*h[i]^16843008*i,e=0;4>e;e++)a[e][t]=o=o<<24^o>>>8,c[e][i]=s=s<<24^s>>>8;for(e=0;5>e;e++)a[e]=a[e].slice(0),c[e]=c[e].slice(0)}},r.bitArray={bitSlice:function(e,t,n){return e=r.bitArray.l(e.slice(t/32),32-(31&t)).slice(1),void 0===n?e:r.bitArray.clamp(e,n-t)},extract:function(e,t,r){var n=Math.floor(-t-r&31);return(-32&(t+r-1^t)?e[t/32|0]<<32-n^e[t/32+1|0]>>>n:e[t/32|0]>>>n)&(1<0&&t&&(e[n-1]=r.bitArray.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:function(e,t,r){return 32===e?t:(r?0|t:t<<32-e)+1099511627776*e},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(e,t){if(r.bitArray.bitLength(e)!==r.bitArray.bitLength(t))return!1;var n,o=0;for(n=0;n=32;t-=32)o.push(n),n=0;if(0===t)return o.concat(e);for(i=0;i>>t),n=e[i]<<32-t;return i=e.length?e[e.length-1]:0,e=r.bitArray.getPartial(i),o.push(r.bitArray.partial(t+e&31,t+e>32?n:o.pop(),1)),o},n:function(e,t){return[e[0]^t[0],e[1]^t[1],e[2]^t[2],e[3]^t[3]]}},r.codec.utf8String={fromBits:function(e){var t,n,o="",i=r.bitArray.bitLength(e);for(t=0;i/8>t;t++)0===(3&t)&&(n=e[t/4]),o+=String.fromCharCode(n>>>24),n<<=8;return decodeURIComponent(escape(o))},toBits:function(e){e=unescape(encodeURIComponent(e));var t,n=[],o=0;for(t=0;t>>i)>>>26),6>i?(a=e[n]<<6-i,i+=26,n++):(a<<=6,i-=6);for(;3&o.length&&!t;)o+="=";return o},toBits:function(e,t){e=e.replace(/\s|=/g,"");var n,o,i=[],s=0,a=r.codec.base64.i,c=0;for(t&&(a=a.substr(0,62)+"-_"),n=0;no)throw new r.exception.invalid("this isn't base64!");s>26?(s-=26,i.push(c^o>>>s),c=o<<32-s):(s+=6,c^=o<<32-s)}return 56&s&&i.push(r.bitArray.partial(56&s,c,1)),i}},r.codec.base64url={fromBits:function(e){return r.codec.base64.fromBits(e,1,1)},toBits:function(e){return r.codec.base64.toBits(e,1)}},r.hash.sha256=function(e){this.e[0]||this.g(),e?(this.f=e.f.slice(0),this.d=e.d.slice(0),this.a=e.a):this.reset()},r.hash.sha256.hash=function(e){return(new r.hash.sha256).update(e).finalize()},r.hash.sha256.prototype={blockSize:512,reset:function(){return this.f=this.k.slice(0),this.d=[],this.a=0,this},update:function(e){"string"==typeof e&&(e=r.codec.utf8String.toBits(e));var n,o=this.d=r.bitArray.concat(this.d,e);for(n=this.a,e=this.a=n+r.bitArray.bitLength(e),n=512+n&-512;e>=n;n+=512)t(this,o.splice(0,16));return this},finalize:function(){var e,n=this.d,o=this.f,n=r.bitArray.concat(n,[r.bitArray.partial(1,1)]);for(e=n.length+2;15&e;e++)n.push(0);for(n.push(Math.floor(this.a/4294967296)),n.push(0|this.a);n.length;)t(this,n.splice(0,16));return this.reset(),o},k:[],e:[],g:function(){function e(e){return 4294967296*(e-Math.floor(e))|0}var t,r=0,n=2;e:for(;64>r;n++){for(t=2;n>=t*t;t++)if(0===n%t)continue e;8>r&&(this.k[r]=e(Math.pow(n,.5))),this.e[r]=e(Math.pow(n,1/3)),r++}}},r.misc.hmac=function(e,t){this.j=t=t||r.hash.sha256;var n,o=[[],[]],i=t.prototype.blockSize/32;for(this.c=[new t,new t],e.length>i&&(e=t.hash(e)),n=0;i>n;n++)o[0][n]=909522486^e[n],o[1][n]=1549556828^e[n];this.c[0].update(o[0]),this.c[1].update(o[1]),this.h=new t(this.c[0])},r.misc.hmac.prototype.encrypt=r.misc.hmac.prototype.mac=function(e){if(this.m)throw new r.exception.invalid("encrypt on already updated hmac called!");return this.update(e),this.digest(e)},r.misc.hmac.prototype.reset=function(){this.h=new this.j(this.c[0]),this.m=!1},r.misc.hmac.prototype.update=function(e){this.m=!0,this.h.update(e)},r.misc.hmac.prototype.digest=function(){var e=this.h.finalize(),e=new this.j(this.c[1]).update(e).finalize();return this.reset(),e},r.misc.pbkdf2=function(e,t,n,o,i){if(n=n||1e3,0>o||0>n)throw r.exception.invalid("invalid params to pbkdf2");"string"==typeof e&&(e=r.codec.utf8String.toBits(e)),"string"==typeof t&&(t=r.codec.utf8String.toBits(t)),i=i||r.misc.hmac,e=new i(e);var s,a,c,u,f=[],h=r.bitArray;for(u=1;32*f.length<(o||1);u++){for(i=s=e.encrypt(h.concat(t,[u])),a=1;n>a;a++)for(s=e.encrypt(s),c=0;c\?@\[\]\^`\{\|\}~]+$/)||i.hasOwnProperty(r)?void 0:(i[r]=n,"")});return""!==s?null:i},randomString:function(e){for(var t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=t.length,n=[],o=0;e>o;++o)n[o]=t[Math.floor(Math.random()*r)];return n.join("")},baseIndexOf:function(e,t,r){for(var n=(r||0)-1,o=e?e.length:0;++nr;++r)r in e&&t(e[r],r)}function u(e){a(function(){if(!f.onerror)throw e;f.onerror.call(null,e)})}function f(e){return e instanceof v?e:d(new v,e)}function h(e,t,r,n){return e._state?e:(e._state=t,e._value=r,n?e._domain=n:_&&t===L&&(e._domain=process.domain),e._pending.length&&c(e._pending,K),e._pending=null,e)}function l(e,t){e._pending.push(t)}function p(e,t){h(t,e._state,e._value,e._domain)}function d(e,t){return e._state?e:(t instanceof v?t===e?h(e,L,new TypeError("You can't resolve a promise with itself")):t._state?p(t,e):l(t,function(){p(t,e)}):t!==Object(t)?h(e,F,t):B(function(){var r=m(e);try{var n=t.then;"function"==typeof n?j.call(n,t,r.resolve,r.reject):h(e,F,t)}catch(o){r.reject(o)}}),e)}function m(e){var t=!1;return{promise:e,resolve:function(r){t||(t=!0,d(e,r))},reject:function(r){t||(t=!0,h(e,L,r))}}}function y(){return m(new v)}function g(e){return h(new v,L,e)}function v(){this._state=0,this._value=void 0,this._domain=null,this._pending=[]}function w(e){function t(t){return e(t,[])}function r(e){return f(e).then(t)}return r._=e,r}function b(e,t){var r=0,n=new v;return c(e,function(e,o){var i=f(e);i._state===R?(++r,l(i,function(){t[o]=i.inspect(),0===--r&&h(n,F,t)})):t[o]=i.inspect()}),0===r&&h(n,F,t),n}function T(e,t){var r=0,n=y();return c(e,function(e,o){var i=f(e);i._state===F?t[o]=i._value:(++r,i.then(function(e){t[o]=e,0===--r&&n.resolve(t)},n.reject))}),0===r&&n.resolve(t),n.promise}function k(e){function t(t){return I.apply(e,t)}return function(){var e=T(arguments,[]);return T([this,e],[]).then(t)}}var x,B,S,_=e(typeof process)&&"[object process]"==={}.toString.call(process),A=e(typeof setImmediate),C={f:null,n:null},O=C,M=!1,P=_&&o||i(n)||s(n),q=[],E=s(r),j=e.call,I=e.apply,K=function(e){O=O.n={f:e,n:null},M||(M=!0,P())};_?(x=function(e){var t=process.domain;return function(){if(t){if(t._disposed)return;t.enter()}try{e.call()}catch(r){throw P(),r}t&&t.exit()}},B=function(e){var t=process.domain;K(t?function(){t._disposed||(t.enter(),e.call(),t.exit())}:e)}):(x=function(e){return function(){try{e.call()}catch(t){q.push(t),E()}}},B=K);var R=0,F=1,L=2;return f.defer=y,f.reject=g,v.prototype.then=function(e,t){function r(){var e=i._state===F?n:o;if(!e)return void p(i,s);var t,r=!1,c=i._domain||a;if(c){if(c._disposed)return;c.enter()}try{t=e(i._value)}catch(u){r=!0,h(s,L,u)}r||d(s,t),c&&c.exit()}var n="function"==typeof e?e:null,o="function"==typeof t?t:null,i=this,s=new v,a=_&&process.domain;return i._state===R?l(i,r):K(r),s},v.prototype.done=function(e,t){var r=this;(e||t)&&(r=r.then(e,t)),r.then(null,u)},v.prototype.fail=function(e){return this.then(null,e)},v.prototype.spread=function(e,t){return this.then(e&&function(r){return T(r,[]).then(function(t){return I.call(e,void 0,t)},t)},t)},v.prototype.timeout=function(e,t){var r=this,n=new v;if(r._state!==R)p(r,n);else{var o=setTimeout(function(){h(n,L,new Error(t||"Timed out after "+e+" ms"))},e);l(r,function(){clearTimeout(o),p(r,n)})}return n},v.prototype.delay=function(e){var t=y();return this.then(function(r){setTimeout(function(){t.resolve(r)},e)},t.reject),t.promise},v.prototype.inspect=function(){switch(this._state){case R:return{state:"pending"};case F:return{state:"fulfilled",value:this._value};case L:return{state:"rejected",reason:this._value};default:throw new TypeError("invalid state")}},f.allSettled=w(b),f.all=w(T),f.promised=k,f.onerror=null,f.nextTick=a,f}),r("client/lib/errors",[],function(){return{INVALID_TIMESTAMP:111,INCORRECT_EMAIL_CASE:120}}),r("client/lib/request",["./hawk","p","./errors"],function(e,t,r){function n(e,t,r){r||(r={}),this.baseUri=e,this._localtimeOffsetMsec=r.localtimeOffsetMsec,this.xhr=t||XMLHttpRequest,this.timeout=r.timeout||3e4}return n.prototype.send=function(n,o,i,s,a){var c=t.defer(),u=new this.xhr,f=this.baseUri+n,h=null,l=this;a=a||{},s&&(h=JSON.stringify(s));try{u.open(o,f)}catch(p){c.reject({error:"Unknown error",message:p.toString(),errno:999})}if(u.timeout=this.timeout,u.onreadystatechange=function(){if(4===u.readyState){var e=u.responseText;try{e=JSON.parse(u.responseText)}catch(t){}if(e.errno){if(e.errno!==r.INVALID_TIMESTAMP||a.retrying)return c.reject(e);var f=e.serverTime;return l._localtimeOffsetMsec=1e3*f-(new Date).getTime(),a.retrying=!0,l.send(n,o,i,s,a).then(c.resolve,c.reject)}if("undefined"==typeof u.status||200!==u.status)return c.reject(0===e.length?{error:"Timeout error",errno:999}:{error:"Unknown error",message:e,errno:999,code:u.status});c.resolve(e)}},i){var d=e.client.header(f,o,{credentials:i,payload:h,contentType:"application/json",localtimeOffsetMsec:this._localtimeOffsetMsec||0});u.setRequestHeader("authorization",d.field)}if(u.setRequestHeader("Content-Type","application/json"),a&&a.headers)for(var m in a.headers)u.setRequestHeader(m,a.headers[m]);return u.send(h),c.promise},n}),r("client/lib/hkdf",["sjcl","p"],function(e,t){function r(r,n,o,i){var s=new e.misc.hmac(o,e.hash.sha256);s.update(r);for(var a=s.digest(),c=32,u=Math.ceil(i/c),f=e.codec.hex.toBits(""),h="",l=0;u>l;l++){var p=new e.misc.hmac(a,e.hash.sha256),d=e.bitArray.concat(e.bitArray.concat(f,n),e.codec.utf8String.toBits(String.fromCharCode(l+1)));p.update(d),f=p.digest(),h+=e.codec.hex.fromBits(f)}var m=e.bitArray.clamp(e.codec.hex.toBits(h),8*i);return t(m)}return r}),r("client/lib/pbkdf2",["sjcl","p"],function(e,t){var r={derive:function(r,n,o,i){var s=e.misc.pbkdf2(r,n,o,i,e.misc.hmac);return t(s)}};return r}),r("client/lib/credentials",["./request","sjcl","p","./hkdf","./pbkdf2"],function(e,t,r,n,o){function i(e){return t.codec.utf8String.toBits(a+e)}function s(e,r){return t.codec.utf8String.toBits(a+e+":"+r)}var a="identity.mozilla.com/picl/v1/",c=1e3,u=256,f=t.codec.hex.toBits("00"),h=32;return{setup:function(e,r){var a={},l=s("quickStretch",e),p=t.codec.utf8String.toBits(r);return a.emailUTF8=e,a.passwordUTF8=r,o.derive(p,l,c,u).then(function(e){return a.quickStretchedPW=e,n(e,i("authPW"),f,h).then(function(t){return a.authPW=t,n(e,i("unwrapBkey"),f,h)})}).then(function(e){return a.unwrapBKey=e,a})},xor:function(e,t){for(var r=[],n=0;n 0) {\n name.splice(i - 1, 2);\n i -= 2;\n }\n }\n }\n //end trimDots\n\n name = name.join(\"/\");\n } else if (name.indexOf('./') === 0) {\n // No baseName, so this is ID is resolved relative\n // to baseUrl, pull off the leading dot.\n name = name.substring(2);\n }\n }\n\n //Apply map config if available.\n if ((baseParts || starMap) && map) {\n nameParts = name.split('/');\n\n for (i = nameParts.length; i > 0; i -= 1) {\n nameSegment = nameParts.slice(0, i).join(\"/\");\n\n if (baseParts) {\n //Find the longest baseName segment match in the config.\n //So, do joins on the biggest to smallest lengths of baseParts.\n for (j = baseParts.length; j > 0; j -= 1) {\n mapValue = map[baseParts.slice(0, j).join('/')];\n\n //baseName segment has config, find if it has one for\n //this name.\n if (mapValue) {\n mapValue = mapValue[nameSegment];\n if (mapValue) {\n //Match, update name to the new value.\n foundMap = mapValue;\n foundI = i;\n break;\n }\n }\n }\n }\n\n if (foundMap) {\n break;\n }\n\n //Check for a star map match, but just hold on to it,\n //if there is a shorter segment match later in a matching\n //config, then favor over this star map.\n if (!foundStarMap && starMap && starMap[nameSegment]) {\n foundStarMap = starMap[nameSegment];\n starI = i;\n }\n }\n\n if (!foundMap && foundStarMap) {\n foundMap = foundStarMap;\n foundI = starI;\n }\n\n if (foundMap) {\n nameParts.splice(0, foundI, foundMap);\n name = nameParts.join('/');\n }\n }\n\n return name;\n }\n\n function makeRequire(relName, forceSync) {\n return function () {\n //A version of a require function that passes a moduleName\n //value for items that may need to\n //look up paths relative to the moduleName\n return req.apply(undef, aps.call(arguments, 0).concat([relName, forceSync]));\n };\n }\n\n function makeNormalize(relName) {\n return function (name) {\n return normalize(name, relName);\n };\n }\n\n function makeLoad(depName) {\n return function (value) {\n defined[depName] = value;\n };\n }\n\n function callDep(name) {\n if (hasProp(waiting, name)) {\n var args = waiting[name];\n delete waiting[name];\n defining[name] = true;\n main.apply(undef, args);\n }\n\n if (!hasProp(defined, name) && !hasProp(defining, name)) {\n throw new Error('No ' + name);\n }\n return defined[name];\n }\n\n //Turns a plugin!resource to [plugin, resource]\n //with the plugin being undefined if the name\n //did not have a plugin prefix.\n function splitPrefix(name) {\n var prefix,\n index = name ? name.indexOf('!') : -1;\n if (index > -1) {\n prefix = name.substring(0, index);\n name = name.substring(index + 1, name.length);\n }\n return [prefix, name];\n }\n\n /**\n * Makes a name map, normalizing the name, and using a plugin\n * for normalization if necessary. Grabs a ref to plugin\n * too, as an optimization.\n */\n makeMap = function (name, relName) {\n var plugin,\n parts = splitPrefix(name),\n prefix = parts[0];\n\n name = parts[1];\n\n if (prefix) {\n prefix = normalize(prefix, relName);\n plugin = callDep(prefix);\n }\n\n //Normalize according\n if (prefix) {\n if (plugin && plugin.normalize) {\n name = plugin.normalize(name, makeNormalize(relName));\n } else {\n name = normalize(name, relName);\n }\n } else {\n name = normalize(name, relName);\n parts = splitPrefix(name);\n prefix = parts[0];\n name = parts[1];\n if (prefix) {\n plugin = callDep(prefix);\n }\n }\n\n //Using ridiculous property names for space reasons\n return {\n f: prefix ? prefix + '!' + name : name, //fullName\n n: name,\n pr: prefix,\n p: plugin\n };\n };\n\n function makeConfig(name) {\n return function () {\n return (config && config.config && config.config[name]) || {};\n };\n }\n\n handlers = {\n require: function (name) {\n return makeRequire(name);\n },\n exports: function (name) {\n var e = defined[name];\n if (typeof e !== 'undefined') {\n return e;\n } else {\n return (defined[name] = {});\n }\n },\n module: function (name) {\n return {\n id: name,\n uri: '',\n exports: defined[name],\n config: makeConfig(name)\n };\n }\n };\n\n main = function (name, deps, callback, relName) {\n var cjsModule, depName, ret, map, i,\n args = [],\n usingExports;\n\n //Use name if no relName\n relName = relName || name;\n\n //Call the callback to define the module, if necessary.\n if (typeof callback === 'function') {\n\n //Pull out the defined dependencies and pass the ordered\n //values to the callback.\n //Default to [require, exports, module] if no deps\n deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;\n for (i = 0; i < deps.length; i += 1) {\n map = makeMap(deps[i], relName);\n depName = map.f;\n\n //Fast path CommonJS standard dependencies.\n if (depName === \"require\") {\n args[i] = handlers.require(name);\n } else if (depName === \"exports\") {\n //CommonJS module spec 1.1\n args[i] = handlers.exports(name);\n usingExports = true;\n } else if (depName === \"module\") {\n //CommonJS module spec 1.1\n cjsModule = args[i] = handlers.module(name);\n } else if (hasProp(defined, depName) ||\n hasProp(waiting, depName) ||\n hasProp(defining, depName)) {\n args[i] = callDep(depName);\n } else if (map.p) {\n map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});\n args[i] = defined[depName];\n } else {\n throw new Error(name + ' missing ' + depName);\n }\n }\n\n ret = callback.apply(defined[name], args);\n\n if (name) {\n //If setting exports via \"module\" is in play,\n //favor that over return value and exports. After that,\n //favor a non-undefined return value over exports use.\n if (cjsModule && cjsModule.exports !== undef &&\n cjsModule.exports !== defined[name]) {\n defined[name] = cjsModule.exports;\n } else if (ret !== undef || !usingExports) {\n //Use the return value from the function.\n defined[name] = ret;\n }\n }\n } else if (name) {\n //May just be an object definition for the module. Only\n //worry about defining if have a module name.\n defined[name] = callback;\n }\n };\n\n requirejs = require = req = function (deps, callback, relName, forceSync, alt) {\n if (typeof deps === \"string\") {\n if (handlers[deps]) {\n //callback in this case is really relName\n return handlers[deps](callback);\n }\n //Just return the module wanted. In this scenario, the\n //deps arg is the module name, and second arg (if passed)\n //is just the relName.\n //Normalize module name, if it contains . or ..\n return callDep(makeMap(deps, callback).f);\n } else if (!deps.splice) {\n //deps is a config object, not an array.\n config = deps;\n if (callback.splice) {\n //callback is an array, which means it is a dependency list.\n //Adjust args if there are dependencies\n deps = callback;\n callback = relName;\n relName = null;\n } else {\n deps = undef;\n }\n }\n\n //Support require(['a'])\n callback = callback || function () {};\n\n //If relName is a function, it is an errback handler,\n //so remove it.\n if (typeof relName === 'function') {\n relName = forceSync;\n forceSync = alt;\n }\n\n //Simulate async callback;\n if (forceSync) {\n main(undef, deps, callback, relName);\n } else {\n //Using a non-zero value because of concern for what old browsers\n //do, and latest browsers \"upgrade\" to 4 if lower value is used:\n //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:\n //If want a value immediately, use require('id') instead -- something\n //that works in almond on the global level, but not guaranteed and\n //unlikely to work in other AMD implementations.\n setTimeout(function () {\n main(undef, deps, callback, relName);\n }, 4);\n }\n\n return req;\n };\n\n /**\n * Just drops the config on the floor, but returns req in case\n * the config return value is used.\n */\n req.config = function (cfg) {\n config = cfg;\n if (config.deps) {\n req(config.deps, config.callback);\n }\n return req;\n };\n\n /**\n * Expose module registry for debugging and tooling\n */\n requirejs._defined = defined;\n\n define = function (name, deps, callback) {\n\n //This module may not have dependencies\n if (!deps.splice) {\n //deps is not an array, so probably means\n //an object literal or factory function for\n //the value. Adjust args.\n callback = deps;\n deps = [];\n }\n\n if (!hasProp(defined, name) && !hasProp(waiting, name)) {\n waiting[name] = [name, deps, callback];\n }\n };\n\n define.amd = {\n jQuery: true\n };\n}());\n\ndefine(\"components/almond/almond\", function(){});\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/FxAccountClient',[\n './lib/request',\n 'sjcl',\n 'p',\n './lib/credentials',\n './lib/hawkCredentials',\n './lib/errors'\n], function (Request, sjcl, P, credentials, hawkCredentials, ERRORS) {\n 'use strict';\n\n var VERSION = 'v1';\n var uriVersionRegExp = new RegExp('/' + VERSION + '$');\n\n function required(val, name) {\n if (!val) {\n throw new Error('Missing ' + name);\n }\n }\n\n /**\n * @class FxAccountClient\n * @constructor\n * @param {String} uri Auth Server URI\n * @param {Object} config Configuration\n */\n function FxAccountClient(uri, config) {\n if (typeof uri !== 'string') {\n config = uri || {};\n uri = config.uri;\n }\n if (typeof config === 'undefined') {\n config = {};\n }\n if (!uriVersionRegExp.test(uri)) {\n uri = uri + '/' + VERSION;\n }\n\n this.request = new Request(uri, config.xhr, { localtimeOffsetMsec: config.localtimeOffsetMsec });\n }\n\n FxAccountClient.VERSION = VERSION;\n\n /**\n * @method signUp\n * @param {String} email Email input\n * @param {String} password Password input\n * @param {Object} [options={}] Options\n * @param {String} [options.service]\n * Opaque alphanumeric token to be included in verification links\n * @param {String} [options.redirectTo]\n * a URL that the client should be redirected to after handling the request\n * @param {String} [options.preVerified]\n * set email to be verified if possible\n * @param {String} [options.preVerifyToken]\n * Opaque alphanumeric token that can be used to pre-verify a user.\n * @param {String} [options.resume]\n * Opaque url-encoded string that will be included in the verification link\n * as a querystring parameter, useful for continuing an OAuth flow for\n * example.\n * @param {String} [options.lang]\n * set the language for the 'Accept-Language' header\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.signUp = function (email, password, options) {\n var self = this;\n\n required(email, 'email');\n required(password, 'password');\n\n return credentials.setup(email, password)\n .then(\n function (result) {\n var endpoint = '/account/create';\n var data = {\n email: result.emailUTF8,\n authPW: sjcl.codec.hex.fromBits(result.authPW)\n };\n var requestOpts = {};\n\n if (options) {\n if (options.service) {\n data.service = options.service;\n }\n\n if (options.redirectTo) {\n data.redirectTo = options.redirectTo;\n }\n\n // preVerified and preVerifyToken exist for two different use\n // cases. preVerified is used for unit/functional testing, while\n // preVerifyToken is used by trusted RPs to indicate a user is\n // already verified. The plan is to eventually drop preVerified and\n // use preVerifyToken universally.\n if (options.preVerified) {\n data.preVerified = options.preVerified;\n }\n\n if (options.preVerifyToken) {\n data.preVerifyToken = options.preVerifyToken;\n }\n\n if (options.resume) {\n data.resume = options.resume;\n }\n\n if (options.keys) {\n endpoint += '?keys=true';\n }\n\n if (options.lang) {\n requestOpts.headers = {\n 'Accept-Language': options.lang\n };\n }\n }\n\n return self.request.send(endpoint, 'POST', null, data, requestOpts);\n }\n );\n };\n\n /**\n * @method signIn\n * @param {String} email Email input\n * @param {String} password Password input\n * @param {Object} [options={}] Options\n * @param {Boolean} [options.keys]\n * If `true`, calls the API with `?keys=true` to get the keyFetchToken\n * @param {Boolean} [options.skipCaseError]\n * If `true`, the request will skip the incorrect case error\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.signIn = function (email, password, options) {\n var self = this;\n options = options || {};\n\n required(email, 'email');\n required(password, 'password');\n\n return credentials.setup(email, password)\n .then(\n function (result) {\n var endpoint = '/account/login';\n\n var data = {\n email: result.emailUTF8,\n authPW: sjcl.codec.hex.fromBits(result.authPW)\n };\n\n if (options.keys) {\n endpoint += '?keys=true';\n }\n\n return self.request.send(endpoint, 'POST', null, data)\n .then(\n function(accountData) {\n if (options.keys) {\n accountData.unwrapBKey = sjcl.codec.hex.fromBits(result.unwrapBKey);\n }\n return accountData;\n },\n function(error) {\n if (error && error.email && error.errno === ERRORS.INCORRECT_EMAIL_CASE && !options.skipCaseError) {\n options.skipCaseError = true;\n\n return self.signIn(error.email, password, options);\n } else {\n throw error;\n }\n }\n );\n }\n );\n };\n\n /**\n * @method verifyCode\n * @param {String} uid Account ID\n * @param {String} code Verification code\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.verifyCode = function(uid, code) {\n required(uid, 'uid');\n required(code, 'verify code');\n\n return this.request.send('/recovery_email/verify_code', 'POST', null, {\n uid: uid,\n code: code\n });\n };\n\n /**\n * @method recoveryEmailStatus\n * @param {String} sessionToken sessionToken obtained from signIn\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.recoveryEmailStatus = function(sessionToken) {\n var self = this;\n required(sessionToken, 'sessionToken');\n\n return hawkCredentials(sessionToken, 'sessionToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/recovery_email/status', 'GET', creds);\n });\n };\n\n /**\n * Re-sends a verification code to the account's recovery email address.\n *\n * @method recoveryEmailResendCode\n * @param {String} sessionToken sessionToken obtained from signIn\n * @param {Object} [options={}] Options\n * @param {String} [options.service]\n * Opaque alphanumeric token to be included in verification links\n * @param {String} [options.redirectTo]\n * a URL that the client should be redirected to after handling the request\n * @param {String} [options.resume]\n * Opaque url-encoded string that will be included in the verification link\n * as a querystring parameter, useful for continuing an OAuth flow for\n * example.\n * @param {String} [options.lang]\n * set the language for the 'Accept-Language' header\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.recoveryEmailResendCode = function(sessionToken, options) {\n var self = this;\n var data = {};\n var requestOpts = {};\n\n required(sessionToken, 'sessionToken');\n\n if (options) {\n if (options.service) {\n data.service = options.service;\n }\n\n if (options.redirectTo) {\n data.redirectTo = options.redirectTo;\n }\n\n if (options.resume) {\n data.resume = options.resume;\n }\n\n if (options.lang) {\n requestOpts.headers = {\n 'Accept-Language': options.lang\n };\n }\n }\n\n return hawkCredentials(sessionToken, 'sessionToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/recovery_email/resend_code', 'POST', creds, data, requestOpts);\n });\n };\n\n /**\n * Used to ask the server to send a recovery code.\n * The API returns passwordForgotToken to the client.\n *\n * @method passwordForgotSendCode\n * @param {String} email\n * @param {Object} [options={}] Options\n * @param {String} [options.service]\n * Opaque alphanumeric token to be included in verification links\n * @param {String} [options.redirectTo]\n * a URL that the client should be redirected to after handling the request\n * @param {String} [options.resume]\n * Opaque url-encoded string that will be included in the verification link\n * as a querystring parameter, useful for continuing an OAuth flow for\n * example.\n * @param {String} [options.lang]\n * set the language for the 'Accept-Language' header\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.passwordForgotSendCode = function(email, options) {\n var data = {\n email: email\n };\n var requestOpts = {};\n\n required(email, 'email');\n\n if (options) {\n if (options.service) {\n data.service = options.service;\n }\n\n if (options.redirectTo) {\n data.redirectTo = options.redirectTo;\n }\n\n if (options.resume) {\n data.resume = options.resume;\n }\n\n if (options.lang) {\n requestOpts.headers = {\n 'Accept-Language': options.lang\n };\n }\n }\n\n return this.request.send('/password/forgot/send_code', 'POST', null, data, requestOpts);\n };\n\n /**\n * Re-sends a verification code to the account's recovery email address.\n * HAWK-authenticated with the passwordForgotToken.\n *\n * @method passwordForgotResendCode\n * @param {String} email\n * @param {String} passwordForgotToken\n * @param {Object} [options={}] Options\n * @param {String} [options.service]\n * Opaque alphanumeric token to be included in verification links\n * @param {String} [options.redirectTo]\n * a URL that the client should be redirected to after handling the request\n * @param {String} [options.resume]\n * Opaque url-encoded string that will be included in the verification link\n * as a querystring parameter, useful for continuing an OAuth flow for\n * example.\n * @param {String} [options.lang]\n * set the language for the 'Accept-Language' header\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.passwordForgotResendCode = function(email, passwordForgotToken, options) {\n var self = this;\n var data = {\n email: email\n };\n var requestOpts = {};\n\n required(email, 'email');\n required(passwordForgotToken, 'passwordForgotToken');\n\n if (options) {\n if (options.service) {\n data.service = options.service;\n }\n\n if (options.redirectTo) {\n data.redirectTo = options.redirectTo;\n }\n\n if (options.resume) {\n data.resume = options.resume;\n }\n\n if (options.lang) {\n requestOpts.headers = {\n 'Accept-Language': options.lang\n };\n }\n }\n\n return hawkCredentials(passwordForgotToken, 'passwordForgotToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/password/forgot/resend_code', 'POST', creds, data, requestOpts);\n });\n };\n\n /**\n * Submits the verification token to the server.\n * The API returns accountResetToken to the client.\n * HAWK-authenticated with the passwordForgotToken.\n *\n * @method passwordForgotVerifyCode\n * @param {String} code\n * @param {String} passwordForgotToken\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.passwordForgotVerifyCode = function(code, passwordForgotToken) {\n var self = this;\n required(code, 'reset code');\n required(passwordForgotToken, 'passwordForgotToken');\n\n return hawkCredentials(passwordForgotToken, 'passwordForgotToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/password/forgot/verify_code', 'POST', creds, {\n code: code\n });\n });\n };\n\n /**\n * Returns the status for the passwordForgotToken.\n * If the request returns a success response, the token has not yet been consumed.\n\n * @method passwordForgotStatus\n * @param {String} passwordForgotToken\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.passwordForgotStatus = function(passwordForgotToken) {\n var self = this;\n\n required(passwordForgotToken, 'passwordForgotToken');\n\n return hawkCredentials(passwordForgotToken, 'passwordForgotToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/password/forgot/status', 'GET', creds);\n });\n };\n\n /**\n * The API returns reset result to the client.\n * HAWK-authenticated with accountResetToken\n *\n * @method accountReset\n * @param {String} email\n * @param {String} newPassword\n * @param {String} accountResetToken\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.accountReset = function(email, newPassword, accountResetToken) {\n var self = this;\n var authPW;\n\n required(email, 'email');\n required(newPassword, 'new password');\n required(accountResetToken, 'accountResetToken');\n\n return credentials.setup(email, newPassword)\n .then(\n function (result) {\n authPW = sjcl.codec.hex.fromBits(result.authPW);\n\n return hawkCredentials(accountResetToken, 'accountResetToken', 2 * 32);\n }\n ).then(\n function (creds) {\n return self.request.send('/account/reset', 'POST', creds, {\n authPW: authPW\n });\n }\n );\n };\n\n /**\n * Get the base16 bundle of encrypted kA|wrapKb.\n *\n * @method accountKeys\n * @param {String} keyFetchToken\n * @param {String} oldUnwrapBKey\n * @return {Promise} A promise that will be fulfilled with JSON of {kA, kB} of the key bundle\n */\n FxAccountClient.prototype.accountKeys = function(keyFetchToken, oldUnwrapBKey) {\n var self = this;\n\n required(keyFetchToken, 'keyFetchToken');\n required(oldUnwrapBKey, 'oldUnwrapBKey');\n\n return hawkCredentials(keyFetchToken, 'keyFetchToken', 3 * 32)\n .then(function(creds) {\n var bundleKey = sjcl.codec.hex.fromBits(creds.bundleKey);\n\n return self.request.send('/account/keys', 'GET', creds)\n .then(\n function(payload) {\n\n return credentials.unbundleKeyFetchResponse(bundleKey, payload.bundle);\n });\n })\n .then(function(keys) {\n return {\n kB: sjcl.codec.hex.fromBits(\n credentials.xor(\n sjcl.codec.hex.toBits(keys.wrapKB),\n sjcl.codec.hex.toBits(oldUnwrapBKey)\n )\n ),\n kA: keys.kA\n };\n });\n };\n\n /**\n * Gets the collection of devices currently authenticated and syncing for the user.\n *\n * @method accountDevices\n * @param {String} sessionToken User session token\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.accountDevices = function(sessionToken) {\n var self = this;\n\n required(sessionToken, 'sessionToken');\n\n return hawkCredentials(sessionToken, 'sessionToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/account/devices', 'GET', creds);\n });\n };\n\n /**\n * This deletes the account completely. All stored data is erased.\n *\n * @method accountDestroy\n * @param {String} email Email input\n * @param {String} password Password input\n * @param {Object} [options={}] Options\n * @param {Boolean} [options.skipCaseError]\n * If `true`, the request will skip the incorrect case error\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.accountDestroy = function(email, password, options) {\n var self = this;\n options = options || {};\n\n required(email, 'email');\n required(password, 'password');\n\n return credentials.setup(email, password)\n .then(\n function (result) {\n var data = {\n email: result.emailUTF8,\n authPW: sjcl.codec.hex.fromBits(result.authPW)\n };\n\n return self.request.send('/account/destroy', 'POST', null, data)\n .then(\n function(response) {\n return response;\n },\n function(error) {\n // if incorrect email case error\n if (error && error.email && error.errno === ERRORS.INCORRECT_EMAIL_CASE && !options.skipCaseError) {\n options.skipCaseError = true;\n\n return self.accountDestroy(error.email, password, options);\n } else {\n throw error;\n }\n }\n );\n }\n );\n };\n\n /**\n * Gets the status of an account\n *\n * @method accountStatus\n * @param {String} uid User account id\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.accountStatus = function(uid) {\n required(uid, 'uid');\n\n return this.request.send('/account/status?uid=' + uid, 'GET');\n };\n\n /**\n * Destroys this session, by invalidating the sessionToken.\n *\n * @method sessionDestroy\n * @param {String} sessionToken User session token\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.sessionDestroy = function(sessionToken) {\n var self = this;\n\n required(sessionToken, 'sessionToken');\n\n return hawkCredentials(sessionToken, 'sessionToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/session/destroy', 'POST', creds);\n });\n };\n\n /**\n * Responds successfully if the session status is valid, requires the sessionToken.\n *\n * @method sessionStatus\n * @param {String} sessionToken User session token\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.sessionStatus = function(sessionToken) {\n var self = this;\n\n required(sessionToken, 'sessionToken');\n\n return hawkCredentials(sessionToken, 'sessionToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/session/status', 'GET', creds);\n });\n };\n\n /**\n * Sign a BrowserID public key\n *\n * @method certificateSign\n * @param {String} sessionToken User session token\n * @param {Object} publicKey The key to sign\n * @param {int} duration Time interval from now when the certificate will expire in seconds\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.certificateSign = function(sessionToken, publicKey, duration) {\n var self = this;\n var data = {\n publicKey: publicKey,\n duration: duration\n };\n\n required(sessionToken, 'sessionToken');\n required(publicKey, 'publicKey');\n required(duration, 'duration');\n\n return hawkCredentials(sessionToken, 'sessionToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/certificate/sign', 'POST', creds, data);\n });\n };\n\n /**\n * Change the password from one known value to another.\n *\n * @method passwordChange\n * @param {String} email\n * @param {String} oldPassword\n * @param {String} newPassword\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.passwordChange = function(email, oldPassword, newPassword) {\n var self = this;\n\n required(email, 'email');\n required(oldPassword, 'old password');\n required(newPassword, 'new password');\n\n return self._passwordChangeStart(email, oldPassword)\n .then(function (credentials) {\n\n var oldCreds = credentials;\n\n return self._passwordChangeKeys(oldCreds)\n .then(function (keys) {\n\n return self._passwordChangeFinish(email, newPassword, oldCreds, keys);\n });\n });\n\n };\n\n /**\n * First step to change the password.\n *\n * @method passwordChangeStart\n * @private\n * @param {String} email\n * @param {String} oldPassword\n * @param {Object} [options={}] Options\n * @param {Boolean} [options.skipCaseError]\n * If `true`, the request will skip the incorrect case error\n * @return {Promise} A promise that will be fulfilled with JSON of `xhr.responseText` and `oldUnwrapBKey`\n */\n FxAccountClient.prototype._passwordChangeStart = function(email, oldPassword, options) {\n var self = this;\n options = options || {};\n\n required(email, 'email');\n required(oldPassword, 'old password');\n\n return credentials.setup(email, oldPassword)\n .then(function (oldCreds) {\n var data = {\n email: oldCreds.emailUTF8,\n oldAuthPW: sjcl.codec.hex.fromBits(oldCreds.authPW)\n };\n\n return self.request.send('/password/change/start', 'POST', null, data)\n .then(\n function(passwordData) {\n passwordData.oldUnwrapBKey = sjcl.codec.hex.fromBits(oldCreds.unwrapBKey);\n return passwordData;\n },\n function(error) {\n // if incorrect email case error\n if (error && error.email && error.errno === ERRORS.INCORRECT_EMAIL_CASE && !options.skipCaseError) {\n options.skipCaseError = true;\n\n return self._passwordChangeStart(error.email, oldPassword, options);\n } else {\n throw error;\n }\n }\n );\n });\n };\n\n function checkCreds(creds) {\n required(creds, 'credentials');\n required(creds.oldUnwrapBKey, 'credentials.oldUnwrapBKey');\n required(creds.keyFetchToken, 'credentials.keyFetchToken');\n required(creds.passwordChangeToken, 'credentials.passwordChangeToken');\n }\n\n /**\n * Second step to change the password.\n *\n * @method _passwordChangeKeys\n * @private\n * @param {Object} oldCreds This object should consists of `oldUnwrapBKey`, `keyFetchToken` and `passwordChangeToken`.\n * @return {Promise} A promise that will be fulfilled with JSON of `xhr.responseText`\n */\n FxAccountClient.prototype._passwordChangeKeys = function(oldCreds) {\n checkCreds(oldCreds);\n\n return this.accountKeys(oldCreds.keyFetchToken, oldCreds.oldUnwrapBKey);\n };\n\n /**\n * Third step to change the password.\n *\n * @method _passwordChangeFinish\n * @private\n * @param {String} email\n * @param {String} newPassword\n * @param {Object} oldCreds This object should consists of `oldUnwrapBKey`, `keyFetchToken` and `passwordChangeToken`.\n * @return {Promise} A promise that will be fulfilled with JSON of `xhr.responseText`\n */\n FxAccountClient.prototype._passwordChangeFinish = function(email, newPassword, oldCreds, keys) {\n var self = this;\n\n required(email, 'email');\n required(newPassword, 'new password');\n checkCreds(oldCreds);\n required(keys, 'keys');\n required(keys.kB, 'keys.kB');\n\n var p1 = credentials.setup(email, newPassword);\n var p2 = hawkCredentials(oldCreds.passwordChangeToken, 'passwordChangeToken', 2 * 32);\n\n return P.all([p1, p2])\n .spread(function(newCreds, hawkCreds) {\n var newWrapKb = sjcl.codec.hex.fromBits(\n credentials.xor(\n sjcl.codec.hex.toBits(keys.kB),\n newCreds.unwrapBKey\n )\n );\n\n return self.request.send('/password/change/finish', 'POST', hawkCreds, {\n wrapKb: newWrapKb,\n authPW: sjcl.codec.hex.fromBits(newCreds.authPW)\n });\n });\n };\n\n /**\n * Get 32 bytes of random data. This should be combined with locally-sourced entropy when creating salts, etc.\n *\n * @method getRandomBytes\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.getRandomBytes = function() {\n\n return this.request.send('/get_random_bytes', 'POST');\n };\n\n return FxAccountClient;\n});\n\n\n\n","define('sjcl',[], function () {\"use strict\";var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return\"CORRUPT: \"+this.message};this.message=a},invalid:function(a){this.toString=function(){return\"INVALID: \"+this.message};this.message=a},bug:function(a){this.toString=function(){return\"BUG: \"+this.message};this.message=a},notReady:function(a){this.toString=function(){return\"NOT READY: \"+this.message};this.message=a}}};\n\"undefined\"!==typeof module&&module.exports&&(module.exports=sjcl);\nsjcl.cipher.aes=function(a){this.b[0][0][0]||this.g();var b,c,d,e,g=this.b[0][4],f=this.b[1];b=a.length;var h=1;if(4!==b&&6!==b&&8!==b)throw new sjcl.exception.invalid(\"invalid aes key size\");this.e=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(0===a%b||8===b&&4===a%b)c=g[c>>>24]<<24^g[c>>16&255]<<16^g[c>>8&255]<<8^g[c&255],0===a%b&&(c=c<<8^c>>>24^h<<24,h=h<<1^283*(h>>7));d[a]=d[a-b]^c}for(b=0;a;b++,a--)c=d[b&3?a:a-4],e[b]=4>=a||4>b?c:f[0][g[c>>>24]]^f[1][g[c>>16&255]]^f[2][g[c>>8&255]]^f[3][g[c&\n255]]};\nsjcl.cipher.aes.prototype={encrypt:function(a){return v(this,a,0)},decrypt:function(a){return v(this,a,1)},b:[[[],[],[],[],[]],[[],[],[],[],[]]],g:function(){var a=this.b[0],b=this.b[1],c=a[4],d=b[4],e,g,f,h=[],p=[],k,n,l,m;for(e=0;0x100>e;e++)p[(h[e]=e<<1^283*(e>>7))^e]=e;for(g=f=0;!c[g];g^=k||1,f=p[f]||1){l=f^f<<1^f<<2^f<<3^f<<4;l=l>>8^l&255^99;c[g]=l;d[l]=g;n=h[e=h[k=h[g]]];m=0x1010101*n^0x10001*e^0x101*k^0x1010100*g;n=0x101*h[l]^0x1010100*l;for(e=0;4>e;e++)a[e][g]=n=n<<24^n>>>8,b[e][l]=m=m<<24^m>>>8}for(e=\n0;5>e;e++)a[e]=a[e].slice(0),b[e]=b[e].slice(0)}};\nfunction v(a,b,c){if(4!==b.length)throw new sjcl.exception.invalid(\"invalid aes block size\");var d=a.e[c],e=b[0]^d[0],g=b[c?3:1]^d[1],f=b[2]^d[2];b=b[c?1:3]^d[3];var h,p,k,n=d.length/4-2,l,m=4,s=[0,0,0,0];h=a.b[c];a=h[0];var q=h[1],r=h[2],t=h[3],u=h[4];for(l=0;l>>24]^q[g>>16&255]^r[f>>8&255]^t[b&255]^d[m],p=a[g>>>24]^q[f>>16&255]^r[b>>8&255]^t[e&255]^d[m+1],k=a[f>>>24]^q[b>>16&255]^r[e>>8&255]^t[g&255]^d[m+2],b=a[b>>>24]^q[e>>16&255]^r[g>>8&255]^t[f&255]^d[m+3],m+=4,e=h,g=p,f=k;for(l=\n0;4>l;l++)s[c?3&-l:l]=u[e>>>24]<<24^u[g>>16&255]<<16^u[f>>8&255]<<8^u[b&255]^d[m++],h=e,e=g,g=f,f=b,b=h;return s}\nsjcl.bitArray={bitSlice:function(a,b,c){a=sjcl.bitArray.l(a.slice(b/32),32-(b&31)).slice(1);return void 0===c?a:sjcl.bitArray.clamp(a,c-b)},extract:function(a,b,c){var d=Math.floor(-b-c&31);return((b+c-1^b)&-32?a[b/32|0]<<32-d^a[b/32+1|0]>>>d:a[b/32|0]>>>d)&(1<>b-1,1));return a},partial:function(a,b,c){return 32===a?b:(c?b|0:b<<32-a)+0x10000000000*a},getPartial:function(a){return Math.round(a/0x10000000000)||32},equal:function(a,b){if(sjcl.bitArray.bitLength(a)!==sjcl.bitArray.bitLength(b))return!1;var c=0,d;for(d=0;d>>b),c=a[e]<<32-b;e=a.length?a[a.length-1]:0;a=sjcl.bitArray.getPartial(e);d.push(sjcl.bitArray.partial(b+a&31,32>>24),e<<=8;return decodeURIComponent(escape(b))},toBits:function(a){a=unescape(encodeURIComponent(a));var b=[],c,d=0;for(c=0;c>>e)>>>26),6>e?(f=a[c]<<6-e,e+=26,c++):(f<<=6,e-=6);for(;d.length&3&&!b;)d+=\"=\";return d},toBits:function(a,b){a=a.replace(/\\s|=/g,\"\");var c=[],d,e=0,g=sjcl.codec.base64.i,f=0,h;b&&(g=g.substr(0,62)+\"-_\");for(d=0;dh)throw new sjcl.exception.invalid(\"this isn't base64!\");26>>e),f=h<<32-e):(e+=6,f^=h<<32-e)}e&56&&c.push(sjcl.bitArray.partial(e&56,f,1));return c}};sjcl.codec.base64url={fromBits:function(a){return sjcl.codec.base64.fromBits(a,1,1)},toBits:function(a){return sjcl.codec.base64.toBits(a,1)}};sjcl.hash.sha256=function(a){this.e[0]||this.g();a?(this.f=a.f.slice(0),this.d=a.d.slice(0),this.a=a.a):this.reset()};sjcl.hash.sha256.hash=function(a){return(new sjcl.hash.sha256).update(a).finalize()};\nsjcl.hash.sha256.prototype={blockSize:512,reset:function(){this.f=this.k.slice(0);this.d=[];this.a=0;return this},update:function(a){\"string\"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));var b,c=this.d=sjcl.bitArray.concat(this.d,a);b=this.a;a=this.a=b+sjcl.bitArray.bitLength(a);for(b=512+b&-512;b<=a;b+=512)w(this,c.splice(0,16));return this},finalize:function(){var a,b=this.d,c=this.f,b=sjcl.bitArray.concat(b,[sjcl.bitArray.partial(1,1)]);for(a=b.length+2;a&15;a++)b.push(0);b.push(Math.floor(this.a/\n4294967296));for(b.push(this.a|0);b.length;)w(this,b.splice(0,16));this.reset();return c},k:[],e:[],g:function(){function a(a){return 0x100000000*(a-Math.floor(a))|0}var b=0,c=2,d;a:for(;64>b;c++){for(d=2;d*d<=c;d++)if(0===c%d)continue a;8>b&&(this.k[b]=a(Math.pow(c,0.5)));this.e[b]=a(Math.pow(c,1/3));b++}}};\nfunction w(a,b){var c,d,e,g=b.slice(0),f=a.f,h=a.e,p=f[0],k=f[1],n=f[2],l=f[3],m=f[4],s=f[5],q=f[6],r=f[7];for(c=0;64>c;c++)16>c?d=g[c]:(d=g[c+1&15],e=g[c+14&15],d=g[c&15]=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+g[c&15]+g[c+9&15]|0),d=d+r+(m>>>6^m>>>11^m>>>25^m<<26^m<<21^m<<7)+(q^m&(s^q))+h[c],r=q,q=s,s=m,m=l+d|0,l=n,n=k,k=p,p=d+(k&n^l&(k^n))+(k>>>2^k>>>13^k>>>22^k<<30^k<<19^k<<10)|0;f[0]=f[0]+p|0;f[1]=f[1]+k|0;f[2]=f[2]+n|0;f[3]=f[3]+l|0;f[4]=f[4]+m|0;f[5]=f[5]+s|0;f[6]=\nf[6]+q|0;f[7]=f[7]+r|0}sjcl.misc.hmac=function(a,b){this.j=b=b||sjcl.hash.sha256;var c=[[],[]],d,e=b.prototype.blockSize/32;this.c=[new b,new b];a.length>e&&(a=b.hash(a));for(d=0;dd||0>c)throw sjcl.exception.invalid(\"invalid params to pbkdf2\");\"string\"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));\"string\"===typeof b&&(b=sjcl.codec.utf8String.toBits(b));e=e||sjcl.misc.hmac;a=new e(a);var g,f,h,p,k=[],n=sjcl.bitArray;for(p=1;32*k.length<(d||1);p++){e=g=a.encrypt(n.concat(b,[p]));for(f=1;f\n MIT Licensed\n */\n\n\n// Declare namespace\n\n var hawk = {};\n\n hawk.client = {\n\n // Generate an Authorization header for a given request\n\n /*\n uri: 'http://example.com/resource?a=b'\n method: HTTP verb (e.g. 'GET', 'POST')\n options: {\n\n // Required\n\n credentials: {\n id: 'dh37fgj492je',\n key: 'aoijedoaijsdlaksjdl',\n algorithm: 'sha256' // 'sha1', 'sha256'\n },\n\n // Optional\n\n ext: 'application-specific', // Application specific data sent via the ext attribute\n timestamp: Date.now() / 1000, // A pre-calculated timestamp in seconds\n nonce: '2334f34f', // A pre-generated nonce\n localtimeOffsetMsec: 400, // Time offset to sync with server time (ignored if timestamp provided)\n payload: '{\"some\":\"payload\"}', // UTF-8 encoded string for body hash generation (ignored if hash provided)\n contentType: 'application/json', // Payload content-type (ignored if hash provided)\n hash: 'U4MKKSmiVxk37JCCrAVIjV=', // Pre-calculated payload hash\n app: '24s23423f34dx', // Oz application id\n dlg: '234sz34tww3sd' // Oz delegated-by application id\n }\n */\n\n header: function (uri, method, options) {\n\n var result = {\n field: '',\n artifacts: {}\n };\n\n // Validate inputs\n\n if (!uri || (typeof uri !== 'string' && typeof uri !== 'object') ||\n !method || typeof method !== 'string' ||\n !options || typeof options !== 'object') {\n\n result.err = 'Invalid argument type';\n return result;\n }\n\n // Application time\n\n var timestamp = options.timestamp || Math.floor((hawk.utils.now() + (options.localtimeOffsetMsec || 0)) / 1000);\n\n // Validate credentials\n\n var credentials = options.credentials;\n if (!credentials ||\n !credentials.id ||\n !credentials.key ||\n !credentials.algorithm) {\n\n result.err = 'Invalid credential object';\n return result;\n }\n\n if (hawk.utils.baseIndexOf(hawk.crypto.algorithms, credentials.algorithm) === -1) {\n result.err = 'Unknown algorithm';\n return result;\n }\n\n // Parse URI\n\n if (typeof uri === 'string') {\n uri = hawk.utils.parseUri(uri);\n }\n\n // Calculate signature\n\n var artifacts = {\n ts: timestamp,\n nonce: options.nonce || hawk.utils.randomString(6),\n method: method,\n resource: uri.relative,\n host: uri.hostname,\n port: uri.port,\n hash: options.hash,\n ext: options.ext,\n app: options.app,\n dlg: options.dlg\n };\n\n result.artifacts = artifacts;\n\n // Calculate payload hash\n\n if (!artifacts.hash &&\n options.hasOwnProperty('payload')) {\n\n artifacts.hash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, options.contentType);\n }\n\n var mac = hawk.crypto.calculateMac('header', credentials, artifacts);\n\n // Construct header\n\n var hasExt = artifacts.ext !== null && artifacts.ext !== undefined && artifacts.ext !== ''; // Other falsey values allowed\n var header = 'Hawk id=\"' + credentials.id +\n '\", ts=\"' + artifacts.ts +\n '\", nonce=\"' + artifacts.nonce +\n (artifacts.hash ? '\", hash=\"' + artifacts.hash : '') +\n (hasExt ? '\", ext=\"' + hawk.utils.escapeHeaderAttribute(artifacts.ext) : '') +\n '\", mac=\"' + mac + '\"';\n\n if (artifacts.app) {\n header += ', app=\"' + artifacts.app +\n (artifacts.dlg ? '\", dlg=\"' + artifacts.dlg : '') + '\"';\n }\n\n result.field = header;\n\n return result;\n },\n\n\n // Validate server response\n\n /*\n request: object created via 'new XMLHttpRequest()' after response received\n artifacts: object recieved from header().artifacts\n options: {\n payload: optional payload received\n required: specifies if a Server-Authorization header is required. Defaults to 'false'\n }\n */\n\n authenticate: function (request, credentials, artifacts, options) {\n\n options = options || {};\n\n if (request.getResponseHeader('www-authenticate')) {\n\n // Parse HTTP WWW-Authenticate header\n\n var attrsAuth = hawk.utils.parseAuthorizationHeader(request.getResponseHeader('www-authenticate'), ['ts', 'tsm', 'error']);\n if (!attrsAuth) {\n return false;\n }\n\n if (attrsAuth.ts) {\n var tsm = hawk.crypto.calculateTsMac(attrsAuth.ts, credentials);\n if (tsm !== attrsAuth.tsm) {\n return false;\n }\n\n hawk.utils.setNtpOffset(attrsAuth.ts - Math.floor((new Date()).getTime() / 1000)); // Keep offset at 1 second precision\n }\n }\n\n // Parse HTTP Server-Authorization header\n\n if (!request.getResponseHeader('server-authorization') &&\n !options.required) {\n\n return true;\n }\n\n var attributes = hawk.utils.parseAuthorizationHeader(request.getResponseHeader('server-authorization'), ['mac', 'ext', 'hash']);\n if (!attributes) {\n return false;\n }\n\n var modArtifacts = {\n ts: artifacts.ts,\n nonce: artifacts.nonce,\n method: artifacts.method,\n resource: artifacts.resource,\n host: artifacts.host,\n port: artifacts.port,\n hash: attributes.hash,\n ext: attributes.ext,\n app: artifacts.app,\n dlg: artifacts.dlg\n };\n\n var mac = hawk.crypto.calculateMac('response', credentials, modArtifacts);\n if (mac !== attributes.mac) {\n return false;\n }\n\n if (!options.hasOwnProperty('payload')) {\n return true;\n }\n\n if (!attributes.hash) {\n return false;\n }\n\n var calculatedHash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, request.getResponseHeader('content-type'));\n return (calculatedHash === attributes.hash);\n },\n\n message: function (host, port, message, options) {\n\n // Validate inputs\n\n if (!host || typeof host !== 'string' ||\n !port || typeof port !== 'number' ||\n message === null || message === undefined || typeof message !== 'string' ||\n !options || typeof options !== 'object') {\n\n return null;\n }\n\n // Application time\n\n var timestamp = options.timestamp || Math.floor((hawk.utils.now() + (options.localtimeOffsetMsec || 0)) / 1000);\n\n // Validate credentials\n\n var credentials = options.credentials;\n if (!credentials ||\n !credentials.id ||\n !credentials.key ||\n !credentials.algorithm) {\n\n // Invalid credential object\n return null;\n }\n\n if (hawk.crypto.algorithms.indexOf(credentials.algorithm) === -1) {\n return null;\n }\n\n // Calculate signature\n\n var artifacts = {\n ts: timestamp,\n nonce: options.nonce || hawk.utils.randomString(6),\n host: host,\n port: port,\n hash: hawk.crypto.calculatePayloadHash(message, credentials.algorithm)\n };\n\n // Construct authorization\n\n var result = {\n id: credentials.id,\n ts: artifacts.ts,\n nonce: artifacts.nonce,\n hash: artifacts.hash,\n mac: hawk.crypto.calculateMac('message', credentials, artifacts)\n };\n\n return result;\n },\n\n authenticateTimestamp: function (message, credentials, updateClock) { // updateClock defaults to true\n\n var tsm = hawk.crypto.calculateTsMac(message.ts, credentials);\n if (tsm !== message.tsm) {\n return false;\n }\n\n if (updateClock !== false) {\n hawk.utils.setNtpOffset(message.ts - Math.floor((new Date()).getTime() / 1000)); // Keep offset at 1 second precision\n }\n\n return true;\n }\n };\n\n\n hawk.crypto = {\n\n headerVersion: '1',\n\n algorithms: ['sha1', 'sha256'],\n\n calculateMac: function (type, credentials, options) {\n var normalized = hawk.crypto.generateNormalizedString(type, options);\n var hmac = new sjcl.misc.hmac(credentials.key, sjcl.hash.sha256);\n hmac.update(normalized);\n\n return sjcl.codec.base64.fromBits(hmac.digest());\n },\n\n generateNormalizedString: function (type, options) {\n\n var normalized = 'hawk.' + hawk.crypto.headerVersion + '.' + type + '\\n' +\n options.ts + '\\n' +\n options.nonce + '\\n' +\n (options.method || '').toUpperCase() + '\\n' +\n (options.resource || '') + '\\n' +\n options.host.toLowerCase() + '\\n' +\n options.port + '\\n' +\n (options.hash || '') + '\\n';\n\n if (options.ext) {\n normalized += options.ext.replace('\\\\', '\\\\\\\\').replace('\\n', '\\\\n');\n }\n\n normalized += '\\n';\n\n if (options.app) {\n normalized += options.app + '\\n' +\n (options.dlg || '') + '\\n';\n }\n\n return normalized;\n },\n\n calculatePayloadHash: function (payload, algorithm, contentType) {\n var hash = new sjcl.hash.sha256();\n hash.update('hawk.' + hawk.crypto.headerVersion + '.payload\\n')\n .update(hawk.utils.parseContentType(contentType) + '\\n')\n .update(payload || '')\n .update('\\n');\n\n return sjcl.codec.base64.fromBits(hash.finalize());\n },\n\n calculateTsMac: function (ts, credentials) {\n var hmac = new sjcl.misc.hmac(credentials.key, sjcl.hash.sha256);\n hmac.update('hawk.' + hawk.crypto.headerVersion + '.ts\\n' + ts + '\\n');\n\n return sjcl.codec.base64.fromBits(hmac.digest());\n }\n };\n\n\n hawk.utils = {\n\n storage: { // localStorage compatible interface\n _cache: {},\n setItem: function (key, value) {\n\n hawk.utils.storage._cache[key] = value;\n },\n getItem: function (key) {\n\n return hawk.utils.storage._cache[key];\n }\n },\n\n setStorage: function (storage) {\n\n var ntpOffset = hawk.utils.getNtpOffset() || 0;\n hawk.utils.storage = storage;\n hawk.utils.setNtpOffset(ntpOffset);\n },\n\n setNtpOffset: function (offset) {\n\n try {\n hawk.utils.storage.setItem('hawk_ntp_offset', offset);\n }\n catch (err) {\n console.error('[hawk] could not write to storage.');\n console.error(err);\n }\n },\n\n getNtpOffset: function () {\n\n return parseInt(hawk.utils.storage.getItem('hawk_ntp_offset') || '0', 10);\n },\n\n now: function () {\n\n return (new Date()).getTime() + hawk.utils.getNtpOffset();\n },\n\n escapeHeaderAttribute: function (attribute) {\n\n return attribute.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"');\n },\n\n parseContentType: function (header) {\n\n if (!header) {\n return '';\n }\n\n return header.split(';')[0].replace(/^\\s+|\\s+$/g, '').toLowerCase();\n },\n\n parseAuthorizationHeader: function (header, keys) {\n\n if (!header) {\n return null;\n }\n\n var headerParts = header.match(/^(\\w+)(?:\\s+(.*))?$/); // Header: scheme[ something]\n if (!headerParts) {\n return null;\n }\n\n var scheme = headerParts[1];\n if (scheme.toLowerCase() !== 'hawk') {\n return null;\n }\n\n var attributesString = headerParts[2];\n if (!attributesString) {\n return null;\n }\n\n var attributes = {};\n var verify = attributesString.replace(/(\\w+)=\"([^\"\\\\]*)\"\\s*(?:,\\s*|$)/g, function ($0, $1, $2) {\n\n // Check valid attribute names\n\n if (keys.indexOf($1) === -1) {\n return;\n }\n\n // Allowed attribute value characters: !#$%&'()*+,-./:;<=>?@[]^_`{|}~ and space, a-z, A-Z, 0-9\n\n if ($2.match(/^[ \\w\\!#\\$%&'\\(\\)\\*\\+,\\-\\.\\/\\:;<\\=>\\?@\\[\\]\\^`\\{\\|\\}~]+$/) === null) {\n return;\n }\n\n // Check for duplicates\n\n if (attributes.hasOwnProperty($1)) {\n return;\n }\n\n attributes[$1] = $2;\n return '';\n });\n\n if (verify !== '') {\n return null;\n }\n\n return attributes;\n },\n\n randomString: function (size) {\n\n var randomSource = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';\n var len = randomSource.length;\n\n var result = [];\n for (var i = 0; i < size; ++i) {\n result[i] = randomSource[Math.floor(Math.random() * len)];\n }\n\n return result.join('');\n },\n\n baseIndexOf: function(array, value, fromIndex) {\n var index = (fromIndex || 0) - 1,\n length = array ? array.length : 0;\n\n while (++index < length) {\n if (array[index] === value) {\n return index;\n }\n }\n return -1;\n },\n\n parseUri: function (input) {\n\n // Based on: parseURI 1.2.2\n // http://blog.stevenlevithan.com/archives/parseuri\n // (c) Steven Levithan \n // MIT License\n\n var keys = ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'hostname', 'port', 'resource', 'relative', 'pathname', 'directory', 'file', 'query', 'fragment'];\n\n var uriRegex = /^(?:([^:\\/?#]+):)?(?:\\/\\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?))?(((((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?)(?:#(.*))?)/;\n var uriByNumber = uriRegex.exec(input);\n var uri = {};\n\n var i = 15;\n while (i--) {\n uri[keys[i]] = uriByNumber[i] || '';\n }\n\n if (uri.port === null ||\n uri.port === '') {\n\n uri.port = (uri.protocol.toLowerCase() === 'http' ? '80' : (uri.protocol.toLowerCase() === 'https' ? '443' : ''));\n }\n\n return uri;\n }\n };\n\n\n return hawk;\n});\n\n","/*!\r\n * Copyright 2013 Robert Katić\r\n * Released under the MIT license\r\n * https://github.com/rkatic/p/blob/master/LICENSE\r\n *\r\n * High-priority-tasks code-portion based on https://github.com/kriskowal/asap\r\n */\r\n;(function( factory ){\r\n\t// CommonJS\r\n\tif ( typeof module !== \"undefined\" && module && module.exports ) {\r\n\t\tmodule.exports = factory();\r\n\r\n\t// RequireJS\r\n\t} else if ( typeof define === \"function\" && define.amd ) {\r\n\t\tdefine( 'p',factory );\r\n\r\n\t// global\r\n\t} else {\r\n\t\tP = factory();\r\n\t}\r\n})(function() {\r\n\t\"use strict\";\r\n\r\n\tvar\r\n\t\tisNodeJS = ot(typeof process) &&\r\n\t\t\t({}).toString.call(process) === \"[object process]\",\r\n\r\n\t\thasSetImmediate = ot(typeof setImmediate),\r\n\r\n\t\thead = { f: null, n: null }, tail = head,\r\n\t\tflushing = false,\r\n\r\n\t\trequestFlush =\r\n\t\t\tisNodeJS && requestFlushForNodeJS ||\r\n\t\t\tmakeRequestCallFromMutationObserver( flush ) ||\r\n\t\t\tmakeRequestCallFromTimer( flush ),\r\n\r\n\t\tpendingErrors = [],\r\n\t\trequestErrorThrow = makeRequestCallFromTimer( throwFristError ),\r\n\r\n\t\twrapTask,\r\n\t\tasapSafeTask,\r\n\r\n\t\tdomain,\r\n\r\n\t\tcall = ot.call,\r\n\t\tapply = ot.apply;\r\n\r\n\tfunction ot( type ) {\r\n\t\treturn type === \"object\" || type === \"function\";\r\n\t}\r\n\r\n\tfunction throwFristError() {\r\n\t\tif ( pendingErrors.length ) {\r\n\t\t\tthrow pendingErrors.shift();\r\n\t\t}\r\n\t}\r\n\r\n\tfunction flush() {\r\n\t\twhile ( head.n ) {\r\n\t\t\thead = head.n;\r\n\t\t\tvar f = head.f;\r\n\t\t\thead.f = null;\r\n\t\t\tf.call();\r\n\t\t}\r\n\t\tflushing = false;\r\n\t}\r\n\r\n\tvar runLater = function( f ) {\r\n\t\ttail = tail.n = { f: f, n: null };\r\n\t\tif ( !flushing ) {\r\n\t\t\tflushing = true;\r\n\t\t\trequestFlush();\r\n\t\t}\r\n\t};\r\n\r\n\tfunction requestFlushForNodeJS() {\r\n\t\tvar currentDomain = process.domain;\r\n\r\n\t\tif ( currentDomain ) {\r\n\t\t\tif ( !domain ) domain = (1,require)(\"domain\");\r\n\t\t\tdomain.active = process.domain = null;\r\n\t\t}\r\n\r\n\t\tif ( flushing && hasSetImmediate ) {\r\n\t\t\tsetImmediate( flush );\r\n\r\n\t\t} else {\r\n\t\t\tprocess.nextTick( flush );\r\n\t\t}\r\n\r\n\t\tif ( currentDomain ) {\r\n\t\t\tdomain.active = process.domain = currentDomain;\r\n\t\t}\r\n\t}\r\n\r\n\tfunction makeRequestCallFromMutationObserver( callback ) {\r\n\t\tvar observer =\r\n\t\t\tot(typeof MutationObserver) ? new MutationObserver( callback ) :\r\n\t\t\tot(typeof WebKitMutationObserver) ? new WebKitMutationObserver( callback ) :\r\n\t\t\tnull;\r\n\r\n\t\tif ( !observer ) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tvar toggle = 1;\r\n\t\tvar node = document.createTextNode(\"\");\r\n\t\tobserver.observe( node, {characterData: true} );\r\n\r\n\t\treturn function() {\r\n\t\t\ttoggle = -toggle;\r\n\t\t\tnode.data = toggle;\r\n\t\t};\r\n\t}\r\n\r\n\tfunction makeRequestCallFromTimer( callback ) {\r\n\t\treturn function() {\r\n\t\t\tvar timeoutHandle = setTimeout( handleTimer, 0 );\r\n\t\t\tvar intervalHandle = setInterval( handleTimer, 50 );\r\n\r\n\t\t\tfunction handleTimer() {\r\n\t\t\t\tclearTimeout( timeoutHandle );\r\n\t\t\t\tclearInterval( intervalHandle );\r\n\t\t\t\tcallback();\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n\r\n\tif ( isNodeJS ) {\r\n\t\twrapTask = function( task ) {\r\n\t\t\tvar d = process.domain;\r\n\r\n\t\t\treturn function() {\r\n\t\t\t\tif ( d ) {\r\n\t\t\t\t\tif ( d._disposed ) return;\r\n\t\t\t\t\td.enter();\r\n\t\t\t\t}\r\n\r\n\t\t\t\ttry {\r\n\t\t\t\t\ttask.call();\r\n\r\n\t\t\t\t} catch ( e ) {\r\n\t\t\t\t\trequestFlush();\r\n\t\t\t\t\tthrow e;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif ( d ) {\r\n\t\t\t\t\td.exit();\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t};\r\n\r\n\t\tasapSafeTask = function( task ) {\r\n\t\t\tvar d = process.domain;\r\n\t\t\trunLater(!d ? task : function() {\r\n\t\t\t\tif ( !d._disposed ) {\r\n\t\t\t\t\td.enter();\r\n\t\t\t\t\ttask.call();\r\n\t\t\t\t\td.exit();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t} else {\r\n\t\twrapTask = function( task ) {\r\n\t\t\treturn function() {\r\n\t\t\t\ttry {\r\n\t\t\t\t\ttask.call();\r\n\r\n\t\t\t\t} catch ( e ) {\r\n\t\t\t\t\tpendingErrors.push( e );\r\n\t\t\t\t\trequestErrorThrow();\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\tasapSafeTask = runLater;\r\n\t}\r\n\r\n\r\n\tfunction asap( task ) {\r\n\t\trunLater( wrapTask(task) );\r\n\t}\r\n\r\n\t//__________________________________________________________________________\r\n\r\n\r\n\tfunction forEach( arr, cb ) {\r\n\t\tfor ( var i = 0, l = arr.length; i < l; ++i ) {\r\n\t\t\tif ( i in arr ) {\r\n\t\t\t\tcb( arr[i], i );\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfunction reportError( error ) {\r\n\t\tasap(function() {\r\n\t\t\tif ( P.onerror ) {\r\n\t\t\t\tP.onerror.call( null, error );\r\n\r\n\t\t\t} else {\r\n\t\t\t\tthrow error;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tvar PENDING = 0;\r\n\tvar FULFILLED = 1;\r\n\tvar REJECTED = 2;\r\n\r\n\tfunction P( x ) {\r\n\t\treturn x instanceof Promise ?\r\n\t\t\tx :\r\n\t\t\tResolve( new Promise(), x );\r\n\t}\r\n\r\n\tfunction Settle( p, state, value, domain ) {\r\n\t\tif ( p._state ) {\r\n\t\t\treturn p;\r\n\t\t}\r\n\r\n\t\tp._state = state;\r\n\t\tp._value = value;\r\n\r\n\t\tif ( domain ) {\r\n\t\t\tp._domain = domain;\r\n\r\n\t\t} else if ( isNodeJS && state === REJECTED ) {\r\n\t\t\tp._domain = process.domain;\r\n\t\t}\r\n\r\n\t\tif ( p._pending.length ) {\r\n\t\t\tforEach( p._pending, runLater );\r\n\t\t}\r\n\t\tp._pending = null;\r\n\r\n\t\treturn p;\r\n\t}\r\n\r\n\tfunction OnSettled( p, f ) {\r\n\t\tp._pending.push( f );\r\n\t}\r\n\r\n\tfunction Propagate( p, p2 ) {\r\n\t\tSettle( p2, p._state, p._value, p._domain );\r\n\t}\r\n\r\n\tfunction Resolve( p, x ) {\r\n\t\tif ( p._state ) {\r\n\t\t\treturn p;\r\n\t\t}\r\n\r\n\t\tif ( x instanceof Promise ) {\r\n\t\t\tif ( x === p ) {\r\n\t\t\t\tSettle( p, REJECTED, new TypeError(\"You can't resolve a promise with itself\") );\r\n\r\n\t\t\t} else if ( x._state ) {\r\n\t\t\t\tPropagate( x, p );\r\n\r\n\t\t\t} else {\r\n\t\t\t\tOnSettled(x, function() {\r\n\t\t\t\t\tPropagate( x, p );\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t} else if ( x !== Object(x) ) {\r\n\t\t\tSettle( p, FULFILLED, x );\r\n\r\n\t\t} else {\r\n\t\t\tasapSafeTask(function() {\r\n\t\t\t\tvar r = resolverFor( p );\r\n\r\n\t\t\t\ttry {\r\n\t\t\t\t\tvar then = x.then;\r\n\r\n\t\t\t\t\tif ( typeof then === \"function\" ) {\r\n\t\t\t\t\t\tcall.call( then, x, r.resolve, r.reject );\r\n\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tSettle( p, FULFILLED, x );\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t} catch ( e ) {\r\n\t\t\t\t\tr.reject( e );\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn p;\r\n\t}\r\n\r\n\tfunction resolverFor( promise ) {\r\n\t\tvar done = false;\r\n\r\n\t\treturn {\r\n\t\t\tpromise: promise,\r\n\r\n\t\t\tresolve: function( y ) {\r\n\t\t\t\tif ( !done ) {\r\n\t\t\t\t\tdone = true;\r\n\t\t\t\t\tResolve( promise, y );\r\n\t\t\t\t}\r\n\t\t\t},\r\n\r\n\t\t\treject: function( reason ) {\r\n\t\t\t\tif ( !done ) {\r\n\t\t\t\t\tdone = true;\r\n\t\t\t\t\tSettle( promise, REJECTED, reason );\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n\r\n\tP.defer = defer;\r\n\tfunction defer() {\r\n\t\treturn resolverFor( new Promise() );\r\n\t}\r\n\r\n\tP.reject = reject;\r\n\tfunction reject( reason ) {\r\n\t\treturn Settle( new Promise(), REJECTED, reason );\r\n\t}\r\n\r\n\tfunction Promise() {\r\n\t\tthis._state = 0;\r\n\t\tthis._value = void 0;\r\n\t\tthis._domain = null;\r\n\t\tthis._pending = [];\r\n\t}\r\n\r\n\tPromise.prototype.then = function( onFulfilled, onRejected ) {\r\n\t\tvar cb = typeof onFulfilled === \"function\" ? onFulfilled : null;\r\n\t\tvar eb = typeof onRejected === \"function\" ? onRejected : null;\r\n\r\n\t\tvar p = this;\r\n\t\tvar p2 = new Promise();\r\n\r\n\t\tvar thenDomain = isNodeJS && process.domain;\r\n\r\n\t\tfunction onSettled() {\r\n\t\t\tvar func = p._state === FULFILLED ? cb : eb;\r\n\t\t\tif ( !func ) {\r\n\t\t\t\tPropagate( p, p2 );\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tvar x, catched = false;\r\n\t\t\tvar d = p._domain || thenDomain;\r\n\r\n\t\t\tif ( d ) {\r\n\t\t\t\tif ( d._disposed ) return;\r\n\t\t\t\td.enter();\r\n\t\t\t}\r\n\r\n\t\t\ttry {\r\n\t\t\t\tx = func( p._value );\r\n\r\n\t\t\t} catch ( e ) {\r\n\t\t\t\tcatched = true;\r\n\t\t\t\tSettle( p2, REJECTED, e );\r\n\t\t\t}\r\n\r\n\t\t\tif ( !catched ) {\r\n\t\t\t\tResolve( p2, x );\r\n\t\t\t}\r\n\r\n\t\t\tif ( d ) {\r\n\t\t\t\td.exit();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif ( p._state === PENDING ) {\r\n\t\t\tOnSettled( p, onSettled );\r\n\r\n\t\t} else {\r\n\t\t\trunLater( onSettled );\r\n\t\t}\r\n\r\n\t\treturn p2;\r\n\t};\r\n\r\n\tPromise.prototype.done = function( cb, eb ) {\r\n\t\tvar p = this;\r\n\r\n\t\tif ( cb || eb ) {\r\n\t\t\tp = p.then( cb, eb );\r\n\t\t}\r\n\r\n\t\tp.then( null, reportError );\r\n\t};\r\n\r\n\tPromise.prototype.fail = function( eb ) {\r\n\t\treturn this.then( null, eb );\r\n\t};\r\n\r\n\tPromise.prototype.spread = function( cb, eb ) {\r\n\t\treturn this.then(cb && function( array ) {\r\n\t\t\treturn all( array, [] ).then(function( values ) {\r\n\t\t\t\treturn apply.call( cb, void 0, values );\r\n\t\t\t}, eb);\r\n\t\t}, eb);\r\n\t};\r\n\r\n\tPromise.prototype.timeout = function( ms, msg ) {\r\n\t\tvar p = this;\r\n\t\tvar p2 = new Promise();\r\n\r\n\t\tif ( p._state !== PENDING ) {\r\n\t\t\tPropagate( p, p2 );\r\n\r\n\t\t} else {\r\n\t\t\tvar timeoutId = setTimeout(function() {\r\n\t\t\t\tSettle( p2, REJECTED,\r\n\t\t\t\t\tnew Error(msg || \"Timed out after \" + ms + \" ms\") );\r\n\t\t\t}, ms);\r\n\r\n\t\t\tOnSettled(p, function() {\r\n\t\t\t\tclearTimeout( timeoutId );\r\n\t\t\t\tPropagate( p, p2 );\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn p2;\r\n\t};\r\n\r\n\tPromise.prototype.delay = function( ms ) {\r\n\t\tvar d = defer();\r\n\r\n\t\tthis.then(function( value ) {\r\n\t\t\tsetTimeout(function() {\r\n\t\t\t\td.resolve( value );\r\n\t\t\t}, ms);\r\n\t\t}, d.reject);\r\n\r\n\t\treturn d.promise;\r\n\t};\r\n\r\n\tPromise.prototype.inspect = function() {\r\n\t\tswitch ( this._state ) {\r\n\t\t\tcase PENDING: return { state: \"pending\" };\r\n\t\t\tcase FULFILLED: return { state: \"fulfilled\", value: this._value };\r\n\t\t\tcase REJECTED: return { state: \"rejected\", reason: this._value };\r\n\t\t\tdefault: throw new TypeError(\"invalid state\");\r\n\t\t}\r\n\t};\r\n\r\n\tfunction valuesHandler( f ) {\r\n\t\tfunction onFulfilled( values ) {\r\n\t\t\treturn f( values, [] );\r\n\t\t}\r\n\r\n\t\tfunction handleValues( values ) {\r\n\t\t\treturn P( values ).then( onFulfilled );\r\n\t\t}\r\n\r\n\t\thandleValues._ = f;\r\n\t\treturn handleValues;\r\n\t}\r\n\r\n\tP.allSettled = valuesHandler( allSettled );\r\n\tfunction allSettled( input, output ) {\r\n\t\tvar waiting = 0;\r\n\t\tvar promise = new Promise();\r\n\t\tforEach( input, function( x, index ) {\r\n\t\t\tvar p = P( x );\r\n\t\t\tif ( p._state === PENDING ) {\r\n\t\t\t\t++waiting;\r\n\t\t\t\tOnSettled(p, function() {\r\n\t\t\t\t\toutput[ index ] = p.inspect();\r\n\t\t\t\t\tif ( --waiting === 0 ) {\r\n\t\t\t\t\t\tSettle( promise, FULFILLED, output );\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t} else {\r\n\t\t\t\toutput[ index ] = p.inspect();\r\n\t\t\t}\r\n\t\t});\r\n\t\tif ( waiting === 0 ) {\r\n\t\t\tSettle( promise, FULFILLED, output );\r\n\t\t}\r\n\t\treturn promise;\r\n\t}\r\n\r\n\tP.all = valuesHandler( all );\r\n\tfunction all( input, output ) {\r\n\t\tvar waiting = 0;\r\n\t\tvar d = defer();\r\n\t\tforEach( input, function( x, index ) {\r\n\t\t\tvar p = P( x );\r\n\t\t\tif ( p._state === FULFILLED ) {\r\n\t\t\t\toutput[ index ] = p._value;\r\n\r\n\t\t\t} else {\r\n\t\t\t\t++waiting;\r\n\t\t\t\tp.then(function( value ) {\r\n\t\t\t\t\toutput[ index ] = value;\r\n\t\t\t\t\tif ( --waiting === 0 ) {\r\n\t\t\t\t\t\td.resolve( output );\r\n\t\t\t\t\t}\r\n\t\t\t\t}, d.reject);\r\n\t\t\t}\r\n\t\t});\r\n\t\tif ( waiting === 0 ) {\r\n\t\t\td.resolve( output );\r\n\t\t}\r\n\t\treturn d.promise;\r\n\t}\r\n\r\n\tP.promised = promised;\r\n\tfunction promised( f ) {\r\n\t\tfunction onFulfilled( thisAndArgs ) {\r\n\t\t\treturn apply.apply( f, thisAndArgs );\r\n\t\t}\r\n\r\n\t\treturn function() {\r\n\t\t\tvar allArgs = all( arguments, [] );\r\n\t\t\treturn all( [this, allArgs], [] ).then( onFulfilled );\r\n\t\t};\r\n\t}\r\n\r\n\tP.onerror = null;\r\n\r\n\tP.nextTick = asap;\r\n\r\n\treturn P;\r\n});\r\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/lib/errors',[], function () {\n return {\n INVALID_TIMESTAMP: 111,\n INCORRECT_EMAIL_CASE: 120\n };\n});\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/lib/request',['./hawk', 'p', './errors'], function (hawk, P, ERRORS) {\n 'use strict';\n /* global XMLHttpRequest */\n\n /**\n * @class Request\n * @constructor\n * @param {String} baseUri Base URI\n * @param {Object} xhr XMLHttpRequest constructor\n * @param {Object} [options={}] Options\n * @param {Number} [options.localtimeOffsetMsec]\n * Local time offset with the remote auth server's clock\n */\n function Request (baseUri, xhr, options) {\n if (!options) {\n options = {};\n }\n this.baseUri = baseUri;\n this._localtimeOffsetMsec = options.localtimeOffsetMsec;\n this.xhr = xhr || XMLHttpRequest;\n this.timeout = options.timeout || 30 * 1000;\n }\n\n /**\n * @method send\n * @param {String} path Request path\n * @param {String} method HTTP Method\n * @param {Object} credentials HAWK Headers\n * @param {Object} jsonPayload JSON Payload\n * @param {Object} [options={}] Options\n * @param {String} [options.retrying]\n * Flag indicating if the request is a retry\n * @param {Array} [options.headers]\n * A set of extra headers to add to the request\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n Request.prototype.send = function request(path, method, credentials, jsonPayload, options) {\n var deferred = P.defer();\n var xhr = new this.xhr();\n var uri = this.baseUri + path;\n var payload = null;\n var self = this;\n options = options || {};\n\n if (jsonPayload) {\n payload = JSON.stringify(jsonPayload);\n }\n\n try {\n xhr.open(method, uri);\n } catch (e) {\n deferred.reject({ error: 'Unknown error', message: e.toString(), errno: 999 });\n }\n\n xhr.timeout = this.timeout;\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n var result = xhr.responseText;\n try {\n result = JSON.parse(xhr.responseText);\n } catch (e) { }\n\n if (result.errno) {\n // Try to recover from a timeskew error and not already tried\n if (result.errno === ERRORS.INVALID_TIMESTAMP && !options.retrying) {\n var serverTime = result.serverTime;\n self._localtimeOffsetMsec = (serverTime * 1000) - new Date().getTime();\n\n // add to options that the request is retrying\n options.retrying = true;\n\n return self.send(path, method, credentials, jsonPayload, options)\n .then(deferred.resolve, deferred.reject);\n\n } else {\n return deferred.reject(result);\n }\n }\n\n if (typeof xhr.status === 'undefined' || xhr.status !== 200) {\n if (result.length === 0) {\n return deferred.reject({ error: 'Timeout error', errno: 999 });\n } else {\n return deferred.reject({ error: 'Unknown error', message: result, errno: 999, code: xhr.status });\n }\n }\n\n deferred.resolve(result);\n }\n };\n\n // calculate Hawk header if credentials are supplied\n if (credentials) {\n var hawkHeader = hawk.client.header(uri, method, {\n credentials: credentials,\n payload: payload,\n contentType: 'application/json',\n localtimeOffsetMsec: this._localtimeOffsetMsec || 0\n });\n xhr.setRequestHeader('authorization', hawkHeader.field);\n }\n\n xhr.setRequestHeader('Content-Type', 'application/json');\n\n if (options && options.headers) {\n // set extra headers for this request\n for (var header in options.headers) {\n xhr.setRequestHeader(header, options.headers[header]);\n }\n }\n\n xhr.send(payload);\n\n return deferred.promise;\n };\n\n return Request;\n\n});\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/lib/hkdf',['sjcl', 'p'], function (sjcl, P) {\n 'use strict';\n\n /**\n * hkdf - The HMAC-based Key Derivation Function\n * based on https://github.com/mozilla/node-hkdf\n *\n * @class hkdf\n * @param {bitArray} ikm Initial keying material\n * @param {bitArray} info Key derivation data\n * @param {bitArray} salt Salt\n * @param {integer} length Length of the derived key in bytes\n * @return promise object- It will resolve with `output` data\n */\n function hkdf(ikm, info, salt, length) {\n\n var mac = new sjcl.misc.hmac(salt, sjcl.hash.sha256);\n mac.update(ikm);\n\n // compute the PRK\n var prk = mac.digest();\n\n // hash length is 32 because only sjcl.hash.sha256 is used at this moment\n var hashLength = 32;\n var num_blocks = Math.ceil(length / hashLength);\n var prev = sjcl.codec.hex.toBits('');\n var output = '';\n\n for (var i = 0; i < num_blocks; i++) {\n var hmac = new sjcl.misc.hmac(prk, sjcl.hash.sha256);\n\n var input = sjcl.bitArray.concat(\n sjcl.bitArray.concat(prev, info),\n sjcl.codec.utf8String.toBits((String.fromCharCode(i + 1)))\n );\n\n hmac.update(input);\n\n prev = hmac.digest();\n output += sjcl.codec.hex.fromBits(prev);\n }\n\n var truncated = sjcl.bitArray.clamp(sjcl.codec.hex.toBits(output), length * 8);\n\n return P(truncated);\n }\n\n return hkdf;\n\n});\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/lib/pbkdf2',['sjcl', 'p'], function (sjcl, P) {\n 'use strict';\n\n /**\n * @class pbkdf2\n * @constructor\n */\n var pbkdf2 = {\n /**\n * @method derive\n * @param {bitArray} input The password hex buffer.\n * @param {bitArray} salt The salt string buffer.\n * @return {int} iterations the derived key bit array.\n */\n derive: function(input, salt, iterations, len) {\n var result = sjcl.misc.pbkdf2(input, salt, iterations, len, sjcl.misc.hmac);\n return P(result);\n }\n };\n\n return pbkdf2;\n\n});\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/lib/credentials',['./request', 'sjcl', 'p', './hkdf', './pbkdf2'], function (Request, sjcl, P, hkdf, pbkdf2) {\n 'use strict';\n\n // Key wrapping and stretching configuration.\n var NAMESPACE = 'identity.mozilla.com/picl/v1/';\n var PBKDF2_ROUNDS = 1000;\n var STRETCHED_PASS_LENGTH_BYTES = 32 * 8;\n\n var HKDF_SALT = sjcl.codec.hex.toBits('00');\n var HKDF_LENGTH = 32;\n\n /**\n * Key Wrapping with a name\n *\n * @method kw\n * @static\n * @param {String} name The name of the salt\n * @return {bitArray} the salt combination with the namespace\n */\n function kw(name) {\n return sjcl.codec.utf8String.toBits(NAMESPACE + name);\n }\n\n /**\n * Key Wrapping with a name and an email\n *\n * @method kwe\n * @static\n * @param {String} name The name of the salt\n * @param {String} email The email of the user.\n * @return {bitArray} the salt combination with the namespace\n */\n function kwe(name, email) {\n return sjcl.codec.utf8String.toBits(NAMESPACE + name + ':' + email);\n }\n\n /**\n * @class credentials\n * @constructor\n */\n return {\n /**\n * Setup credentials\n *\n * @method setup\n * @param {String} emailInput\n * @param {String} passwordInput\n * @return {Promise} A promise that will be fulfilled with `result` of generated credentials\n */\n setup: function (emailInput, passwordInput) {\n var result = {};\n var email = kwe('quickStretch', emailInput);\n var password = sjcl.codec.utf8String.toBits(passwordInput);\n\n result.emailUTF8 = emailInput;\n result.passwordUTF8 = passwordInput;\n\n return pbkdf2.derive(password, email, PBKDF2_ROUNDS, STRETCHED_PASS_LENGTH_BYTES)\n .then(\n function (quickStretchedPW) {\n result.quickStretchedPW = quickStretchedPW;\n\n return hkdf(quickStretchedPW, kw('authPW'), HKDF_SALT, HKDF_LENGTH)\n .then(\n function (authPW) {\n result.authPW = authPW;\n\n return hkdf(quickStretchedPW, kw('unwrapBkey'), HKDF_SALT, HKDF_LENGTH);\n }\n );\n }\n )\n .then(\n function (unwrapBKey) {\n result.unwrapBKey = unwrapBKey;\n return result;\n }\n );\n },\n /**\n * Wrap\n *\n * @method wrap\n * @param {bitArray} bitArray1\n * @param {bitArray} bitArray2\n * @return {bitArray} wrap result of the two bitArrays\n */\n xor: function (bitArray1, bitArray2) {\n var result = [];\n\n for (var i = 0; i < bitArray1.length; i++) {\n result[i] = bitArray1[i] ^ bitArray2[i];\n }\n\n return result;\n },\n /**\n * Unbundle the WrapKB\n * @param {String} key Bundle Key in hex\n * @param {String} bundle Key bundle in hex\n * @returns {*}\n */\n unbundleKeyFetchResponse: function (key, bundle) {\n var self = this;\n var bitBundle = sjcl.codec.hex.toBits(bundle);\n\n return this.deriveBundleKeys(key, 'account/keys')\n .then(\n function (keys) {\n var ciphertext = sjcl.bitArray.bitSlice(bitBundle, 0, 8 * 64);\n var expectedHmac = sjcl.bitArray.bitSlice(bitBundle, 8 * -32);\n var hmac = new sjcl.misc.hmac(keys.hmacKey, sjcl.hash.sha256);\n hmac.update(ciphertext);\n\n if (!sjcl.bitArray.equal(hmac.digest(), expectedHmac)) {\n throw new Error('Bad HMac');\n }\n\n var keyAWrapB = self.xor(sjcl.bitArray.bitSlice(bitBundle, 0, 8 * 64), keys.xorKey);\n\n return {\n kA: sjcl.codec.hex.fromBits(sjcl.bitArray.bitSlice(keyAWrapB, 0, 8 * 32)),\n wrapKB: sjcl.codec.hex.fromBits(sjcl.bitArray.bitSlice(keyAWrapB, 8 * 32))\n };\n }\n );\n },\n /**\n * Derive the HMAC and XOR keys required to encrypt a given size of payload.\n * @param {String} key Hex Bundle Key\n * @param {String} keyInfo Bundle Key Info\n * @returns {Object} hmacKey, xorKey\n */\n deriveBundleKeys: function(key, keyInfo) {\n var bitKeyInfo = kw(keyInfo);\n var salt = sjcl.codec.hex.toBits('');\n key = sjcl.codec.hex.toBits(key);\n\n return hkdf(key, bitKeyInfo, salt, 3 * 32)\n .then(\n function (keyMaterial) {\n\n return {\n hmacKey: sjcl.bitArray.bitSlice(keyMaterial, 0, 8 * 32),\n xorKey: sjcl.bitArray.bitSlice(keyMaterial, 8 * 32)\n };\n }\n );\n }\n };\n\n});\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/lib/hawkCredentials',['sjcl', './hkdf'], function (sjcl, hkdf) {\n 'use strict';\n\n var PREFIX_NAME = 'identity.mozilla.com/picl/v1/';\n var bitSlice = sjcl.bitArray.bitSlice;\n var salt = sjcl.codec.hex.toBits('');\n\n /**\n * @class hawkCredentials\n * @method deriveHawkCredentials\n * @param {String} tokenHex\n * @param {String} context\n * @param {int} size\n * @returns {Promise}\n */\n function deriveHawkCredentials(tokenHex, context, size) {\n var token = sjcl.codec.hex.toBits(tokenHex);\n var info = sjcl.codec.utf8String.toBits(PREFIX_NAME + context);\n\n return hkdf(token, info, salt, size || 3 * 32)\n .then(function(out) {\n var authKey = bitSlice(out, 8 * 32, 8 * 64);\n var bundleKey = bitSlice(out, 8 * 64);\n\n return {\n algorithm: 'sha256',\n id: sjcl.codec.hex.fromBits(bitSlice(out, 0, 8 * 32)),\n key: authKey,\n bundleKey: bundleKey\n };\n });\n }\n\n return deriveHawkCredentials;\n});\n\n"]} \ No newline at end of file +{"version":3,"file":"fxa-client.min.js","sources":["components/almond/almond.js","client/FxAccountClient.js","components/sjcl/sjcl.js","client/lib/hawk.js","components/p/p.js","client/lib/errors.js","client/lib/request.js","client/lib/hkdf.js","client/lib/pbkdf2.js","client/lib/credentials.js","client/lib/hawkCredentials.js"],"names":[],"mappings":"CACA,SAAA,EAAA,GACA,kBAAA,SAAA,OAAA,IAKA,UAAA,GAIA,EAAA,gBAAA,KAEA,KAAA,WAUA,GAAA,GAAA,EAAA,CCmvBA,ODlvBA,UAAA,GASA,QAAA,GAAA,EAAA,GACA,MAAA,GAAA,KAAA,EAAA,GAWA,QAAA,GAAA,EAAA,GACA,GAAA,GAAA,EAAA,EAAA,EACA,EAAA,EAAA,EAAA,EAAA,EAAA,EACA,EAAA,GAAA,EAAA,MAAA,KACA,EAAA,EAAA,IACA,EAAA,GAAA,EAAA,QAGA,IAAA,GAAA,MAAA,EAAA,OAAA,GAIA,GAAA,EAAA,CAWA,IALA,EAAA,EAAA,MAAA,EAAA,EAAA,OAAA,GAEA,EAAA,EAAA,OAAA,EAAA,MAAA,MAGA,EAAA,EAAA,EAAA,EAAA,OAAA,GAAA,EAEA,GADA,EAAA,EAAA,GACA,MAAA,EACA,EAAA,OAAA,EAAA,GACA,GAAA,MACA,IAAA,OAAA,EAAA,CACA,GAAA,IAAA,IAAA,OAAA,EAAA,IAAA,OAAA,EAAA,IAOA,KACA,GAAA,IACA,EAAA,OAAA,EAAA,EAAA,GACA,GAAA,GAMA,EAAA,EAAA,KAAA,SACA,KAAA,EAAA,QAAA,QAGA,EAAA,EAAA,UAAA,GAKA,KAAA,GAAA,IAAA,EAAA,CAGA,IAFA,EAAA,EAAA,MAAA,KAEA,EAAA,EAAA,OAAA,EAAA,EAAA,GAAA,EAAA,CAGA,GAFA,EAAA,EAAA,MAAA,EAAA,GAAA,KAAA,KAEA,EAGA,IAAA,EAAA,EAAA,OAAA,EAAA,EAAA,GAAA,EAKA,GAJA,EAAA,EAAA,EAAA,MAAA,EAAA,GAAA,KAAA,MAIA,IACA,EAAA,EAAA,IACA,CAEA,EAA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AAA,EAAA,UACA,UAAA,EAAA,MAAA,IAAA,SAAA,EAAA,QAGA,OAAA,GAAA,QAAA,KAAA,yBAAA,OAAA,KAAA,GACA,KACA,SAAA,GAEA,MADA,GAAA,cAAA,EAAA,MAAA,IAAA,SAAA,EAAA,YACA,GAEA,SAAA,GAEA,GAAA,GAAA,EAAA,OAAA,EAAA,QAAA,EAAA,uBAAA,EAAA,cAGA,MAFA,GAAA,eAAA,EAEA,EAAA,qBAAA,EAAA,MAAA,EAAA,EAEA,MAAA,QAsBA,EAAA,UAAA,oBAAA,SAAA,GAGA,MAFA,GAAA,GAEA,KAAA,YAAA,EAAA,cAAA,EAAA,gBAaA,EAAA,UAAA,sBAAA,SAAA,EAAA,EAAA,EAAA,GACA,GAAA,GAAA,IAEA,GAAA,EAAA,SACA,EAAA,EAAA,gBACA,EAAA,GACA,EAAA,EAAA,QACA,EAAA,EAAA,GAAA,UAEA,IAAA,GAAA,EAAA,MAAA,EAAA,GACA,EAAA,EAAA,EAAA,oBAAA,sBAAA,GAEA,OAAA,GAAA,KAAA,EAAA,IACA,OAAA,SAAA,EAAA,GACA,GAAA,GAAA,EAAA,MAAA,IAAA,SACA,EAAA,IACA,EAAA,MAAA,IAAA,OAAA,EAAA,IACA,EAAA,YAIA,OAAA,GAAA,QAAA,KAAA,0BAAA,OAAA,GACA,OAAA,EACA,OAAA,EAAA,MAAA,IAAA,SAAA,EAAA,aAQA,EAAA,UAAA,eAAA,WAAA,MAAA,MAAA,QAAA,KAAA,oBAAA,SAAA,IAAA,EAAA","sourcesContent":["/**\n * almond 0.2.6 Copyright (c) 2011-2012, The Dojo Foundation All Rights Reserved.\n * Available via the MIT or new BSD license.\n * see: http://github.com/jrburke/almond for details\n */\n//Going sloppy to avoid 'use strict' string cost, but strict practices should\n//be followed.\n/*jslint sloppy: true */\n/*global setTimeout: false */\n\nvar requirejs, require, define;\n(function (undef) {\n var main, req, makeMap, handlers,\n defined = {},\n waiting = {},\n config = {},\n defining = {},\n hasOwn = Object.prototype.hasOwnProperty,\n aps = [].slice;\n\n function hasProp(obj, prop) {\n return hasOwn.call(obj, prop);\n }\n\n /**\n * Given a relative module name, like ./something, normalize it to\n * a real name that can be mapped to a path.\n * @param {String} name the relative name\n * @param {String} baseName a real name that the name arg is relative\n * to.\n * @returns {String} normalized name\n */\n function normalize(name, baseName) {\n var nameParts, nameSegment, mapValue, foundMap,\n foundI, foundStarMap, starI, i, j, part,\n baseParts = baseName && baseName.split(\"/\"),\n map = config.map,\n starMap = (map && map['*']) || {};\n\n //Adjust any relative paths.\n if (name && name.charAt(0) === \".\") {\n //If have a base name, try to normalize against it,\n //otherwise, assume it is a top-level require that will\n //be relative to baseUrl in the end.\n if (baseName) {\n //Convert baseName to array, and lop off the last part,\n //so that . matches that \"directory\" and not name of the baseName's\n //module. For instance, baseName of \"one/two/three\", maps to\n //\"one/two/three.js\", but we want the directory, \"one/two\" for\n //this normalization.\n baseParts = baseParts.slice(0, baseParts.length - 1);\n\n name = baseParts.concat(name.split(\"/\"));\n\n //start trimDots\n for (i = 0; i < name.length; i += 1) {\n part = name[i];\n if (part === \".\") {\n name.splice(i, 1);\n i -= 1;\n } else if (part === \"..\") {\n if (i === 1 && (name[2] === '..' || name[0] === '..')) {\n //End of the line. Keep at least one non-dot\n //path segment at the front so it can be mapped\n //correctly to disk. Otherwise, there is likely\n //no path mapping for a path starting with '..'.\n //This can still fail, but catches the most reasonable\n //uses of ..\n break;\n } else if (i > 0) {\n name.splice(i - 1, 2);\n i -= 2;\n }\n }\n }\n //end trimDots\n\n name = name.join(\"/\");\n } else if (name.indexOf('./') === 0) {\n // No baseName, so this is ID is resolved relative\n // to baseUrl, pull off the leading dot.\n name = name.substring(2);\n }\n }\n\n //Apply map config if available.\n if ((baseParts || starMap) && map) {\n nameParts = name.split('/');\n\n for (i = nameParts.length; i > 0; i -= 1) {\n nameSegment = nameParts.slice(0, i).join(\"/\");\n\n if (baseParts) {\n //Find the longest baseName segment match in the config.\n //So, do joins on the biggest to smallest lengths of baseParts.\n for (j = baseParts.length; j > 0; j -= 1) {\n mapValue = map[baseParts.slice(0, j).join('/')];\n\n //baseName segment has config, find if it has one for\n //this name.\n if (mapValue) {\n mapValue = mapValue[nameSegment];\n if (mapValue) {\n //Match, update name to the new value.\n foundMap = mapValue;\n foundI = i;\n break;\n }\n }\n }\n }\n\n if (foundMap) {\n break;\n }\n\n //Check for a star map match, but just hold on to it,\n //if there is a shorter segment match later in a matching\n //config, then favor over this star map.\n if (!foundStarMap && starMap && starMap[nameSegment]) {\n foundStarMap = starMap[nameSegment];\n starI = i;\n }\n }\n\n if (!foundMap && foundStarMap) {\n foundMap = foundStarMap;\n foundI = starI;\n }\n\n if (foundMap) {\n nameParts.splice(0, foundI, foundMap);\n name = nameParts.join('/');\n }\n }\n\n return name;\n }\n\n function makeRequire(relName, forceSync) {\n return function () {\n //A version of a require function that passes a moduleName\n //value for items that may need to\n //look up paths relative to the moduleName\n return req.apply(undef, aps.call(arguments, 0).concat([relName, forceSync]));\n };\n }\n\n function makeNormalize(relName) {\n return function (name) {\n return normalize(name, relName);\n };\n }\n\n function makeLoad(depName) {\n return function (value) {\n defined[depName] = value;\n };\n }\n\n function callDep(name) {\n if (hasProp(waiting, name)) {\n var args = waiting[name];\n delete waiting[name];\n defining[name] = true;\n main.apply(undef, args);\n }\n\n if (!hasProp(defined, name) && !hasProp(defining, name)) {\n throw new Error('No ' + name);\n }\n return defined[name];\n }\n\n //Turns a plugin!resource to [plugin, resource]\n //with the plugin being undefined if the name\n //did not have a plugin prefix.\n function splitPrefix(name) {\n var prefix,\n index = name ? name.indexOf('!') : -1;\n if (index > -1) {\n prefix = name.substring(0, index);\n name = name.substring(index + 1, name.length);\n }\n return [prefix, name];\n }\n\n /**\n * Makes a name map, normalizing the name, and using a plugin\n * for normalization if necessary. Grabs a ref to plugin\n * too, as an optimization.\n */\n makeMap = function (name, relName) {\n var plugin,\n parts = splitPrefix(name),\n prefix = parts[0];\n\n name = parts[1];\n\n if (prefix) {\n prefix = normalize(prefix, relName);\n plugin = callDep(prefix);\n }\n\n //Normalize according\n if (prefix) {\n if (plugin && plugin.normalize) {\n name = plugin.normalize(name, makeNormalize(relName));\n } else {\n name = normalize(name, relName);\n }\n } else {\n name = normalize(name, relName);\n parts = splitPrefix(name);\n prefix = parts[0];\n name = parts[1];\n if (prefix) {\n plugin = callDep(prefix);\n }\n }\n\n //Using ridiculous property names for space reasons\n return {\n f: prefix ? prefix + '!' + name : name, //fullName\n n: name,\n pr: prefix,\n p: plugin\n };\n };\n\n function makeConfig(name) {\n return function () {\n return (config && config.config && config.config[name]) || {};\n };\n }\n\n handlers = {\n require: function (name) {\n return makeRequire(name);\n },\n exports: function (name) {\n var e = defined[name];\n if (typeof e !== 'undefined') {\n return e;\n } else {\n return (defined[name] = {});\n }\n },\n module: function (name) {\n return {\n id: name,\n uri: '',\n exports: defined[name],\n config: makeConfig(name)\n };\n }\n };\n\n main = function (name, deps, callback, relName) {\n var cjsModule, depName, ret, map, i,\n args = [],\n usingExports;\n\n //Use name if no relName\n relName = relName || name;\n\n //Call the callback to define the module, if necessary.\n if (typeof callback === 'function') {\n\n //Pull out the defined dependencies and pass the ordered\n //values to the callback.\n //Default to [require, exports, module] if no deps\n deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;\n for (i = 0; i < deps.length; i += 1) {\n map = makeMap(deps[i], relName);\n depName = map.f;\n\n //Fast path CommonJS standard dependencies.\n if (depName === \"require\") {\n args[i] = handlers.require(name);\n } else if (depName === \"exports\") {\n //CommonJS module spec 1.1\n args[i] = handlers.exports(name);\n usingExports = true;\n } else if (depName === \"module\") {\n //CommonJS module spec 1.1\n cjsModule = args[i] = handlers.module(name);\n } else if (hasProp(defined, depName) ||\n hasProp(waiting, depName) ||\n hasProp(defining, depName)) {\n args[i] = callDep(depName);\n } else if (map.p) {\n map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});\n args[i] = defined[depName];\n } else {\n throw new Error(name + ' missing ' + depName);\n }\n }\n\n ret = callback.apply(defined[name], args);\n\n if (name) {\n //If setting exports via \"module\" is in play,\n //favor that over return value and exports. After that,\n //favor a non-undefined return value over exports use.\n if (cjsModule && cjsModule.exports !== undef &&\n cjsModule.exports !== defined[name]) {\n defined[name] = cjsModule.exports;\n } else if (ret !== undef || !usingExports) {\n //Use the return value from the function.\n defined[name] = ret;\n }\n }\n } else if (name) {\n //May just be an object definition for the module. Only\n //worry about defining if have a module name.\n defined[name] = callback;\n }\n };\n\n requirejs = require = req = function (deps, callback, relName, forceSync, alt) {\n if (typeof deps === \"string\") {\n if (handlers[deps]) {\n //callback in this case is really relName\n return handlers[deps](callback);\n }\n //Just return the module wanted. In this scenario, the\n //deps arg is the module name, and second arg (if passed)\n //is just the relName.\n //Normalize module name, if it contains . or ..\n return callDep(makeMap(deps, callback).f);\n } else if (!deps.splice) {\n //deps is a config object, not an array.\n config = deps;\n if (callback.splice) {\n //callback is an array, which means it is a dependency list.\n //Adjust args if there are dependencies\n deps = callback;\n callback = relName;\n relName = null;\n } else {\n deps = undef;\n }\n }\n\n //Support require(['a'])\n callback = callback || function () {};\n\n //If relName is a function, it is an errback handler,\n //so remove it.\n if (typeof relName === 'function') {\n relName = forceSync;\n forceSync = alt;\n }\n\n //Simulate async callback;\n if (forceSync) {\n main(undef, deps, callback, relName);\n } else {\n //Using a non-zero value because of concern for what old browsers\n //do, and latest browsers \"upgrade\" to 4 if lower value is used:\n //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:\n //If want a value immediately, use require('id') instead -- something\n //that works in almond on the global level, but not guaranteed and\n //unlikely to work in other AMD implementations.\n setTimeout(function () {\n main(undef, deps, callback, relName);\n }, 4);\n }\n\n return req;\n };\n\n /**\n * Just drops the config on the floor, but returns req in case\n * the config return value is used.\n */\n req.config = function (cfg) {\n config = cfg;\n if (config.deps) {\n req(config.deps, config.callback);\n }\n return req;\n };\n\n /**\n * Expose module registry for debugging and tooling\n */\n requirejs._defined = defined;\n\n define = function (name, deps, callback) {\n\n //This module may not have dependencies\n if (!deps.splice) {\n //deps is not an array, so probably means\n //an object literal or factory function for\n //the value. Adjust args.\n callback = deps;\n deps = [];\n }\n\n if (!hasProp(defined, name) && !hasProp(waiting, name)) {\n waiting[name] = [name, deps, callback];\n }\n };\n\n define.amd = {\n jQuery: true\n };\n}());\n\ndefine(\"components/almond/almond\", function(){});\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/FxAccountClient',[\n './lib/request',\n 'sjcl',\n 'p',\n './lib/credentials',\n './lib/hawkCredentials',\n './lib/errors'\n], function (Request, sjcl, P, credentials, hawkCredentials, ERRORS) {\n 'use strict';\n\n var VERSION = 'v1';\n var uriVersionRegExp = new RegExp('/' + VERSION + '$');\n\n function required(val, name) {\n if (!val) {\n throw new Error('Missing ' + name);\n }\n }\n\n /**\n * @class FxAccountClient\n * @constructor\n * @param {String} uri Auth Server URI\n * @param {Object} config Configuration\n */\n function FxAccountClient(uri, config) {\n if (typeof uri !== 'string') {\n config = uri || {};\n uri = config.uri;\n }\n if (typeof config === 'undefined') {\n config = {};\n }\n if (!uriVersionRegExp.test(uri)) {\n uri = uri + '/' + VERSION;\n }\n\n this.request = new Request(uri, config.xhr, { localtimeOffsetMsec: config.localtimeOffsetMsec });\n }\n\n FxAccountClient.VERSION = VERSION;\n\n /**\n * @method signUp\n * @param {String} email Email input\n * @param {String} password Password input\n * @param {Object} [options={}] Options\n * @param {String} [options.service]\n * Opaque alphanumeric token to be included in verification links\n * @param {String} [options.redirectTo]\n * a URL that the client should be redirected to after handling the request\n * @param {String} [options.preVerified]\n * set email to be verified if possible\n * @param {String} [options.preVerifyToken]\n * Opaque alphanumeric token that can be used to pre-verify a user.\n * @param {String} [options.resume]\n * Opaque url-encoded string that will be included in the verification link\n * as a querystring parameter, useful for continuing an OAuth flow for\n * example.\n * @param {String} [options.lang]\n * set the language for the 'Accept-Language' header\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.signUp = function (email, password, options) {\n var self = this;\n\n required(email, 'email');\n required(password, 'password');\n\n return credentials.setup(email, password)\n .then(\n function (result) {\n var endpoint = '/account/create';\n var data = {\n email: result.emailUTF8,\n authPW: sjcl.codec.hex.fromBits(result.authPW)\n };\n var requestOpts = {};\n\n if (options) {\n if (options.service) {\n data.service = options.service;\n }\n\n if (options.redirectTo) {\n data.redirectTo = options.redirectTo;\n }\n\n // preVerified and preVerifyToken exist for two different use\n // cases. preVerified is used for unit/functional testing, while\n // preVerifyToken is used by trusted RPs to indicate a user is\n // already verified. The plan is to eventually drop preVerified and\n // use preVerifyToken universally.\n if (options.preVerified) {\n data.preVerified = options.preVerified;\n }\n\n if (options.preVerifyToken) {\n data.preVerifyToken = options.preVerifyToken;\n }\n\n if (options.resume) {\n data.resume = options.resume;\n }\n\n if (options.keys) {\n endpoint += '?keys=true';\n }\n\n if (options.lang) {\n requestOpts.headers = {\n 'Accept-Language': options.lang\n };\n }\n }\n\n return self.request.send(endpoint, 'POST', null, data, requestOpts)\n .then(\n function(accountData) {\n if (options && options.keys) {\n accountData.unwrapBKey = sjcl.codec.hex.fromBits(result.unwrapBKey);\n }\n return accountData;\n }\n );\n }\n );\n };\n\n /**\n * @method signIn\n * @param {String} email Email input\n * @param {String} password Password input\n * @param {Object} [options={}] Options\n * @param {Boolean} [options.keys]\n * If `true`, calls the API with `?keys=true` to get the keyFetchToken\n * @param {Boolean} [options.skipCaseError]\n * If `true`, the request will skip the incorrect case error\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.signIn = function (email, password, options) {\n var self = this;\n options = options || {};\n\n required(email, 'email');\n required(password, 'password');\n\n return credentials.setup(email, password)\n .then(\n function (result) {\n var endpoint = '/account/login';\n\n var data = {\n email: result.emailUTF8,\n authPW: sjcl.codec.hex.fromBits(result.authPW)\n };\n\n if (options.keys) {\n endpoint += '?keys=true';\n }\n\n return self.request.send(endpoint, 'POST', null, data)\n .then(\n function(accountData) {\n if (options.keys) {\n accountData.unwrapBKey = sjcl.codec.hex.fromBits(result.unwrapBKey);\n }\n return accountData;\n },\n function(error) {\n if (error && error.email && error.errno === ERRORS.INCORRECT_EMAIL_CASE && !options.skipCaseError) {\n options.skipCaseError = true;\n\n return self.signIn(error.email, password, options);\n } else {\n throw error;\n }\n }\n );\n }\n );\n };\n\n /**\n * @method verifyCode\n * @param {String} uid Account ID\n * @param {String} code Verification code\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.verifyCode = function(uid, code) {\n required(uid, 'uid');\n required(code, 'verify code');\n\n return this.request.send('/recovery_email/verify_code', 'POST', null, {\n uid: uid,\n code: code\n });\n };\n\n /**\n * @method recoveryEmailStatus\n * @param {String} sessionToken sessionToken obtained from signIn\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.recoveryEmailStatus = function(sessionToken) {\n var self = this;\n required(sessionToken, 'sessionToken');\n\n return hawkCredentials(sessionToken, 'sessionToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/recovery_email/status', 'GET', creds);\n });\n };\n\n /**\n * Re-sends a verification code to the account's recovery email address.\n *\n * @method recoveryEmailResendCode\n * @param {String} sessionToken sessionToken obtained from signIn\n * @param {Object} [options={}] Options\n * @param {String} [options.service]\n * Opaque alphanumeric token to be included in verification links\n * @param {String} [options.redirectTo]\n * a URL that the client should be redirected to after handling the request\n * @param {String} [options.resume]\n * Opaque url-encoded string that will be included in the verification link\n * as a querystring parameter, useful for continuing an OAuth flow for\n * example.\n * @param {String} [options.lang]\n * set the language for the 'Accept-Language' header\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.recoveryEmailResendCode = function(sessionToken, options) {\n var self = this;\n var data = {};\n var requestOpts = {};\n\n required(sessionToken, 'sessionToken');\n\n if (options) {\n if (options.service) {\n data.service = options.service;\n }\n\n if (options.redirectTo) {\n data.redirectTo = options.redirectTo;\n }\n\n if (options.resume) {\n data.resume = options.resume;\n }\n\n if (options.lang) {\n requestOpts.headers = {\n 'Accept-Language': options.lang\n };\n }\n }\n\n return hawkCredentials(sessionToken, 'sessionToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/recovery_email/resend_code', 'POST', creds, data, requestOpts);\n });\n };\n\n /**\n * Used to ask the server to send a recovery code.\n * The API returns passwordForgotToken to the client.\n *\n * @method passwordForgotSendCode\n * @param {String} email\n * @param {Object} [options={}] Options\n * @param {String} [options.service]\n * Opaque alphanumeric token to be included in verification links\n * @param {String} [options.redirectTo]\n * a URL that the client should be redirected to after handling the request\n * @param {String} [options.resume]\n * Opaque url-encoded string that will be included in the verification link\n * as a querystring parameter, useful for continuing an OAuth flow for\n * example.\n * @param {String} [options.lang]\n * set the language for the 'Accept-Language' header\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.passwordForgotSendCode = function(email, options) {\n var data = {\n email: email\n };\n var requestOpts = {};\n\n required(email, 'email');\n\n if (options) {\n if (options.service) {\n data.service = options.service;\n }\n\n if (options.redirectTo) {\n data.redirectTo = options.redirectTo;\n }\n\n if (options.resume) {\n data.resume = options.resume;\n }\n\n if (options.lang) {\n requestOpts.headers = {\n 'Accept-Language': options.lang\n };\n }\n }\n\n return this.request.send('/password/forgot/send_code', 'POST', null, data, requestOpts);\n };\n\n /**\n * Re-sends a verification code to the account's recovery email address.\n * HAWK-authenticated with the passwordForgotToken.\n *\n * @method passwordForgotResendCode\n * @param {String} email\n * @param {String} passwordForgotToken\n * @param {Object} [options={}] Options\n * @param {String} [options.service]\n * Opaque alphanumeric token to be included in verification links\n * @param {String} [options.redirectTo]\n * a URL that the client should be redirected to after handling the request\n * @param {String} [options.resume]\n * Opaque url-encoded string that will be included in the verification link\n * as a querystring parameter, useful for continuing an OAuth flow for\n * example.\n * @param {String} [options.lang]\n * set the language for the 'Accept-Language' header\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.passwordForgotResendCode = function(email, passwordForgotToken, options) {\n var self = this;\n var data = {\n email: email\n };\n var requestOpts = {};\n\n required(email, 'email');\n required(passwordForgotToken, 'passwordForgotToken');\n\n if (options) {\n if (options.service) {\n data.service = options.service;\n }\n\n if (options.redirectTo) {\n data.redirectTo = options.redirectTo;\n }\n\n if (options.resume) {\n data.resume = options.resume;\n }\n\n if (options.lang) {\n requestOpts.headers = {\n 'Accept-Language': options.lang\n };\n }\n }\n\n return hawkCredentials(passwordForgotToken, 'passwordForgotToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/password/forgot/resend_code', 'POST', creds, data, requestOpts);\n });\n };\n\n /**\n * Submits the verification token to the server.\n * The API returns accountResetToken to the client.\n * HAWK-authenticated with the passwordForgotToken.\n *\n * @method passwordForgotVerifyCode\n * @param {String} code\n * @param {String} passwordForgotToken\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.passwordForgotVerifyCode = function(code, passwordForgotToken) {\n var self = this;\n required(code, 'reset code');\n required(passwordForgotToken, 'passwordForgotToken');\n\n return hawkCredentials(passwordForgotToken, 'passwordForgotToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/password/forgot/verify_code', 'POST', creds, {\n code: code\n });\n });\n };\n\n /**\n * Returns the status for the passwordForgotToken.\n * If the request returns a success response, the token has not yet been consumed.\n\n * @method passwordForgotStatus\n * @param {String} passwordForgotToken\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.passwordForgotStatus = function(passwordForgotToken) {\n var self = this;\n\n required(passwordForgotToken, 'passwordForgotToken');\n\n return hawkCredentials(passwordForgotToken, 'passwordForgotToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/password/forgot/status', 'GET', creds);\n });\n };\n\n /**\n * The API returns reset result to the client.\n * HAWK-authenticated with accountResetToken\n *\n * @method accountReset\n * @param {String} email\n * @param {String} newPassword\n * @param {String} accountResetToken\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.accountReset = function(email, newPassword, accountResetToken) {\n var self = this;\n var authPW;\n\n required(email, 'email');\n required(newPassword, 'new password');\n required(accountResetToken, 'accountResetToken');\n\n return credentials.setup(email, newPassword)\n .then(\n function (result) {\n authPW = sjcl.codec.hex.fromBits(result.authPW);\n\n return hawkCredentials(accountResetToken, 'accountResetToken', 2 * 32);\n }\n ).then(\n function (creds) {\n return self.request.send('/account/reset', 'POST', creds, {\n authPW: authPW\n });\n }\n );\n };\n\n /**\n * Get the base16 bundle of encrypted kA|wrapKb.\n *\n * @method accountKeys\n * @param {String} keyFetchToken\n * @param {String} oldUnwrapBKey\n * @return {Promise} A promise that will be fulfilled with JSON of {kA, kB} of the key bundle\n */\n FxAccountClient.prototype.accountKeys = function(keyFetchToken, oldUnwrapBKey) {\n var self = this;\n\n required(keyFetchToken, 'keyFetchToken');\n required(oldUnwrapBKey, 'oldUnwrapBKey');\n\n return hawkCredentials(keyFetchToken, 'keyFetchToken', 3 * 32)\n .then(function(creds) {\n var bundleKey = sjcl.codec.hex.fromBits(creds.bundleKey);\n\n return self.request.send('/account/keys', 'GET', creds)\n .then(\n function(payload) {\n\n return credentials.unbundleKeyFetchResponse(bundleKey, payload.bundle);\n });\n })\n .then(function(keys) {\n return {\n kB: sjcl.codec.hex.fromBits(\n credentials.xor(\n sjcl.codec.hex.toBits(keys.wrapKB),\n sjcl.codec.hex.toBits(oldUnwrapBKey)\n )\n ),\n kA: keys.kA\n };\n });\n };\n\n /**\n * Gets the collection of devices currently authenticated and syncing for the user.\n *\n * @method accountDevices\n * @param {String} sessionToken User session token\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.accountDevices = function(sessionToken) {\n var self = this;\n\n required(sessionToken, 'sessionToken');\n\n return hawkCredentials(sessionToken, 'sessionToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/account/devices', 'GET', creds);\n });\n };\n\n /**\n * This deletes the account completely. All stored data is erased.\n *\n * @method accountDestroy\n * @param {String} email Email input\n * @param {String} password Password input\n * @param {Object} [options={}] Options\n * @param {Boolean} [options.skipCaseError]\n * If `true`, the request will skip the incorrect case error\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.accountDestroy = function(email, password, options) {\n var self = this;\n options = options || {};\n\n required(email, 'email');\n required(password, 'password');\n\n return credentials.setup(email, password)\n .then(\n function (result) {\n var data = {\n email: result.emailUTF8,\n authPW: sjcl.codec.hex.fromBits(result.authPW)\n };\n\n return self.request.send('/account/destroy', 'POST', null, data)\n .then(\n function(response) {\n return response;\n },\n function(error) {\n // if incorrect email case error\n if (error && error.email && error.errno === ERRORS.INCORRECT_EMAIL_CASE && !options.skipCaseError) {\n options.skipCaseError = true;\n\n return self.accountDestroy(error.email, password, options);\n } else {\n throw error;\n }\n }\n );\n }\n );\n };\n\n /**\n * Gets the status of an account\n *\n * @method accountStatus\n * @param {String} uid User account id\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.accountStatus = function(uid) {\n required(uid, 'uid');\n\n return this.request.send('/account/status?uid=' + uid, 'GET');\n };\n\n /**\n * Destroys this session, by invalidating the sessionToken.\n *\n * @method sessionDestroy\n * @param {String} sessionToken User session token\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.sessionDestroy = function(sessionToken) {\n var self = this;\n\n required(sessionToken, 'sessionToken');\n\n return hawkCredentials(sessionToken, 'sessionToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/session/destroy', 'POST', creds);\n });\n };\n\n /**\n * Responds successfully if the session status is valid, requires the sessionToken.\n *\n * @method sessionStatus\n * @param {String} sessionToken User session token\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.sessionStatus = function(sessionToken) {\n var self = this;\n\n required(sessionToken, 'sessionToken');\n\n return hawkCredentials(sessionToken, 'sessionToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/session/status', 'GET', creds);\n });\n };\n\n /**\n * Sign a BrowserID public key\n *\n * @method certificateSign\n * @param {String} sessionToken User session token\n * @param {Object} publicKey The key to sign\n * @param {int} duration Time interval from now when the certificate will expire in milliseconds\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.certificateSign = function(sessionToken, publicKey, duration) {\n var self = this;\n var data = {\n publicKey: publicKey,\n duration: duration\n };\n\n required(sessionToken, 'sessionToken');\n required(publicKey, 'publicKey');\n required(duration, 'duration');\n\n return hawkCredentials(sessionToken, 'sessionToken', 2 * 32)\n .then(function(creds) {\n return self.request.send('/certificate/sign', 'POST', creds, data);\n });\n };\n\n /**\n * Change the password from one known value to another.\n *\n * @method passwordChange\n * @param {String} email\n * @param {String} oldPassword\n * @param {String} newPassword\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.passwordChange = function(email, oldPassword, newPassword) {\n var self = this;\n\n required(email, 'email');\n required(oldPassword, 'old password');\n required(newPassword, 'new password');\n\n return self._passwordChangeStart(email, oldPassword)\n .then(function (credentials) {\n\n var oldCreds = credentials;\n\n return self._passwordChangeKeys(oldCreds)\n .then(function (keys) {\n\n return self._passwordChangeFinish(email, newPassword, oldCreds, keys);\n });\n });\n\n };\n\n /**\n * First step to change the password.\n *\n * @method passwordChangeStart\n * @private\n * @param {String} email\n * @param {String} oldPassword\n * @param {Object} [options={}] Options\n * @param {Boolean} [options.skipCaseError]\n * If `true`, the request will skip the incorrect case error\n * @return {Promise} A promise that will be fulfilled with JSON of `xhr.responseText` and `oldUnwrapBKey`\n */\n FxAccountClient.prototype._passwordChangeStart = function(email, oldPassword, options) {\n var self = this;\n options = options || {};\n\n required(email, 'email');\n required(oldPassword, 'old password');\n\n return credentials.setup(email, oldPassword)\n .then(function (oldCreds) {\n var data = {\n email: oldCreds.emailUTF8,\n oldAuthPW: sjcl.codec.hex.fromBits(oldCreds.authPW)\n };\n\n return self.request.send('/password/change/start', 'POST', null, data)\n .then(\n function(passwordData) {\n passwordData.oldUnwrapBKey = sjcl.codec.hex.fromBits(oldCreds.unwrapBKey);\n return passwordData;\n },\n function(error) {\n // if incorrect email case error\n if (error && error.email && error.errno === ERRORS.INCORRECT_EMAIL_CASE && !options.skipCaseError) {\n options.skipCaseError = true;\n\n return self._passwordChangeStart(error.email, oldPassword, options);\n } else {\n throw error;\n }\n }\n );\n });\n };\n\n function checkCreds(creds) {\n required(creds, 'credentials');\n required(creds.oldUnwrapBKey, 'credentials.oldUnwrapBKey');\n required(creds.keyFetchToken, 'credentials.keyFetchToken');\n required(creds.passwordChangeToken, 'credentials.passwordChangeToken');\n }\n\n /**\n * Second step to change the password.\n *\n * @method _passwordChangeKeys\n * @private\n * @param {Object} oldCreds This object should consists of `oldUnwrapBKey`, `keyFetchToken` and `passwordChangeToken`.\n * @return {Promise} A promise that will be fulfilled with JSON of `xhr.responseText`\n */\n FxAccountClient.prototype._passwordChangeKeys = function(oldCreds) {\n checkCreds(oldCreds);\n\n return this.accountKeys(oldCreds.keyFetchToken, oldCreds.oldUnwrapBKey);\n };\n\n /**\n * Third step to change the password.\n *\n * @method _passwordChangeFinish\n * @private\n * @param {String} email\n * @param {String} newPassword\n * @param {Object} oldCreds This object should consists of `oldUnwrapBKey`, `keyFetchToken` and `passwordChangeToken`.\n * @return {Promise} A promise that will be fulfilled with JSON of `xhr.responseText`\n */\n FxAccountClient.prototype._passwordChangeFinish = function(email, newPassword, oldCreds, keys) {\n var self = this;\n\n required(email, 'email');\n required(newPassword, 'new password');\n checkCreds(oldCreds);\n required(keys, 'keys');\n required(keys.kB, 'keys.kB');\n\n var p1 = credentials.setup(email, newPassword);\n var p2 = hawkCredentials(oldCreds.passwordChangeToken, 'passwordChangeToken', 2 * 32);\n\n return P.all([p1, p2])\n .spread(function(newCreds, hawkCreds) {\n var newWrapKb = sjcl.codec.hex.fromBits(\n credentials.xor(\n sjcl.codec.hex.toBits(keys.kB),\n newCreds.unwrapBKey\n )\n );\n\n return self.request.send('/password/change/finish', 'POST', hawkCreds, {\n wrapKb: newWrapKb,\n authPW: sjcl.codec.hex.fromBits(newCreds.authPW)\n });\n });\n };\n\n /**\n * Get 32 bytes of random data. This should be combined with locally-sourced entropy when creating salts, etc.\n *\n * @method getRandomBytes\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n FxAccountClient.prototype.getRandomBytes = function() {\n\n return this.request.send('/get_random_bytes', 'POST');\n };\n\n return FxAccountClient;\n});\n\n\n\n","define('sjcl',[], function () {\"use strict\";var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return\"CORRUPT: \"+this.message};this.message=a},invalid:function(a){this.toString=function(){return\"INVALID: \"+this.message};this.message=a},bug:function(a){this.toString=function(){return\"BUG: \"+this.message};this.message=a},notReady:function(a){this.toString=function(){return\"NOT READY: \"+this.message};this.message=a}}};\n\"undefined\"!==typeof module&&module.exports&&(module.exports=sjcl);\nsjcl.cipher.aes=function(a){this.b[0][0][0]||this.g();var b,c,d,e,g=this.b[0][4],f=this.b[1];b=a.length;var h=1;if(4!==b&&6!==b&&8!==b)throw new sjcl.exception.invalid(\"invalid aes key size\");this.e=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(0===a%b||8===b&&4===a%b)c=g[c>>>24]<<24^g[c>>16&255]<<16^g[c>>8&255]<<8^g[c&255],0===a%b&&(c=c<<8^c>>>24^h<<24,h=h<<1^283*(h>>7));d[a]=d[a-b]^c}for(b=0;a;b++,a--)c=d[b&3?a:a-4],e[b]=4>=a||4>b?c:f[0][g[c>>>24]]^f[1][g[c>>16&255]]^f[2][g[c>>8&255]]^f[3][g[c&\n255]]};\nsjcl.cipher.aes.prototype={encrypt:function(a){return v(this,a,0)},decrypt:function(a){return v(this,a,1)},b:[[[],[],[],[],[]],[[],[],[],[],[]]],g:function(){var a=this.b[0],b=this.b[1],c=a[4],d=b[4],e,g,f,h=[],p=[],k,n,l,m;for(e=0;0x100>e;e++)p[(h[e]=e<<1^283*(e>>7))^e]=e;for(g=f=0;!c[g];g^=k||1,f=p[f]||1){l=f^f<<1^f<<2^f<<3^f<<4;l=l>>8^l&255^99;c[g]=l;d[l]=g;n=h[e=h[k=h[g]]];m=0x1010101*n^0x10001*e^0x101*k^0x1010100*g;n=0x101*h[l]^0x1010100*l;for(e=0;4>e;e++)a[e][g]=n=n<<24^n>>>8,b[e][l]=m=m<<24^m>>>8}for(e=\n0;5>e;e++)a[e]=a[e].slice(0),b[e]=b[e].slice(0)}};\nfunction v(a,b,c){if(4!==b.length)throw new sjcl.exception.invalid(\"invalid aes block size\");var d=a.e[c],e=b[0]^d[0],g=b[c?3:1]^d[1],f=b[2]^d[2];b=b[c?1:3]^d[3];var h,p,k,n=d.length/4-2,l,m=4,s=[0,0,0,0];h=a.b[c];a=h[0];var q=h[1],r=h[2],t=h[3],u=h[4];for(l=0;l>>24]^q[g>>16&255]^r[f>>8&255]^t[b&255]^d[m],p=a[g>>>24]^q[f>>16&255]^r[b>>8&255]^t[e&255]^d[m+1],k=a[f>>>24]^q[b>>16&255]^r[e>>8&255]^t[g&255]^d[m+2],b=a[b>>>24]^q[e>>16&255]^r[g>>8&255]^t[f&255]^d[m+3],m+=4,e=h,g=p,f=k;for(l=\n0;4>l;l++)s[c?3&-l:l]=u[e>>>24]<<24^u[g>>16&255]<<16^u[f>>8&255]<<8^u[b&255]^d[m++],h=e,e=g,g=f,f=b,b=h;return s}\nsjcl.bitArray={bitSlice:function(a,b,c){a=sjcl.bitArray.l(a.slice(b/32),32-(b&31)).slice(1);return void 0===c?a:sjcl.bitArray.clamp(a,c-b)},extract:function(a,b,c){var d=Math.floor(-b-c&31);return((b+c-1^b)&-32?a[b/32|0]<<32-d^a[b/32+1|0]>>>d:a[b/32|0]>>>d)&(1<>b-1,1));return a},partial:function(a,b,c){return 32===a?b:(c?b|0:b<<32-a)+0x10000000000*a},getPartial:function(a){return Math.round(a/0x10000000000)||32},equal:function(a,b){if(sjcl.bitArray.bitLength(a)!==sjcl.bitArray.bitLength(b))return!1;var c=0,d;for(d=0;d>>b),c=a[e]<<32-b;e=a.length?a[a.length-1]:0;a=sjcl.bitArray.getPartial(e);d.push(sjcl.bitArray.partial(b+a&31,32>>24),e<<=8;return decodeURIComponent(escape(b))},toBits:function(a){a=unescape(encodeURIComponent(a));var b=[],c,d=0;for(c=0;c>>e)>>>26),6>e?(f=a[c]<<6-e,e+=26,c++):(f<<=6,e-=6);for(;d.length&3&&!b;)d+=\"=\";return d},toBits:function(a,b){a=a.replace(/\\s|=/g,\"\");var c=[],d,e=0,g=sjcl.codec.base64.i,f=0,h;b&&(g=g.substr(0,62)+\"-_\");for(d=0;dh)throw new sjcl.exception.invalid(\"this isn't base64!\");26>>e),f=h<<32-e):(e+=6,f^=h<<32-e)}e&56&&c.push(sjcl.bitArray.partial(e&56,f,1));return c}};sjcl.codec.base64url={fromBits:function(a){return sjcl.codec.base64.fromBits(a,1,1)},toBits:function(a){return sjcl.codec.base64.toBits(a,1)}};sjcl.hash.sha256=function(a){this.e[0]||this.g();a?(this.f=a.f.slice(0),this.d=a.d.slice(0),this.a=a.a):this.reset()};sjcl.hash.sha256.hash=function(a){return(new sjcl.hash.sha256).update(a).finalize()};\nsjcl.hash.sha256.prototype={blockSize:512,reset:function(){this.f=this.k.slice(0);this.d=[];this.a=0;return this},update:function(a){\"string\"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));var b,c=this.d=sjcl.bitArray.concat(this.d,a);b=this.a;a=this.a=b+sjcl.bitArray.bitLength(a);for(b=512+b&-512;b<=a;b+=512)w(this,c.splice(0,16));return this},finalize:function(){var a,b=this.d,c=this.f,b=sjcl.bitArray.concat(b,[sjcl.bitArray.partial(1,1)]);for(a=b.length+2;a&15;a++)b.push(0);b.push(Math.floor(this.a/\n4294967296));for(b.push(this.a|0);b.length;)w(this,b.splice(0,16));this.reset();return c},k:[],e:[],g:function(){function a(a){return 0x100000000*(a-Math.floor(a))|0}var b=0,c=2,d;a:for(;64>b;c++){for(d=2;d*d<=c;d++)if(0===c%d)continue a;8>b&&(this.k[b]=a(Math.pow(c,0.5)));this.e[b]=a(Math.pow(c,1/3));b++}}};\nfunction w(a,b){var c,d,e,g=b.slice(0),f=a.f,h=a.e,p=f[0],k=f[1],n=f[2],l=f[3],m=f[4],s=f[5],q=f[6],r=f[7];for(c=0;64>c;c++)16>c?d=g[c]:(d=g[c+1&15],e=g[c+14&15],d=g[c&15]=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+g[c&15]+g[c+9&15]|0),d=d+r+(m>>>6^m>>>11^m>>>25^m<<26^m<<21^m<<7)+(q^m&(s^q))+h[c],r=q,q=s,s=m,m=l+d|0,l=n,n=k,k=p,p=d+(k&n^l&(k^n))+(k>>>2^k>>>13^k>>>22^k<<30^k<<19^k<<10)|0;f[0]=f[0]+p|0;f[1]=f[1]+k|0;f[2]=f[2]+n|0;f[3]=f[3]+l|0;f[4]=f[4]+m|0;f[5]=f[5]+s|0;f[6]=\nf[6]+q|0;f[7]=f[7]+r|0}sjcl.misc.hmac=function(a,b){this.j=b=b||sjcl.hash.sha256;var c=[[],[]],d,e=b.prototype.blockSize/32;this.c=[new b,new b];a.length>e&&(a=b.hash(a));for(d=0;dd||0>c)throw sjcl.exception.invalid(\"invalid params to pbkdf2\");\"string\"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));\"string\"===typeof b&&(b=sjcl.codec.utf8String.toBits(b));e=e||sjcl.misc.hmac;a=new e(a);var g,f,h,p,k=[],n=sjcl.bitArray;for(p=1;32*k.length<(d||1);p++){e=g=a.encrypt(n.concat(b,[p]));for(f=1;f\n MIT Licensed\n */\n\n\n// Declare namespace\n\n var hawk = {};\n\n hawk.client = {\n\n // Generate an Authorization header for a given request\n\n /*\n uri: 'http://example.com/resource?a=b'\n method: HTTP verb (e.g. 'GET', 'POST')\n options: {\n\n // Required\n\n credentials: {\n id: 'dh37fgj492je',\n key: 'aoijedoaijsdlaksjdl',\n algorithm: 'sha256' // 'sha1', 'sha256'\n },\n\n // Optional\n\n ext: 'application-specific', // Application specific data sent via the ext attribute\n timestamp: Date.now() / 1000, // A pre-calculated timestamp in seconds\n nonce: '2334f34f', // A pre-generated nonce\n localtimeOffsetMsec: 400, // Time offset to sync with server time (ignored if timestamp provided)\n payload: '{\"some\":\"payload\"}', // UTF-8 encoded string for body hash generation (ignored if hash provided)\n contentType: 'application/json', // Payload content-type (ignored if hash provided)\n hash: 'U4MKKSmiVxk37JCCrAVIjV=', // Pre-calculated payload hash\n app: '24s23423f34dx', // Oz application id\n dlg: '234sz34tww3sd' // Oz delegated-by application id\n }\n */\n\n header: function (uri, method, options) {\n\n var result = {\n field: '',\n artifacts: {}\n };\n\n // Validate inputs\n\n if (!uri || (typeof uri !== 'string' && typeof uri !== 'object') ||\n !method || typeof method !== 'string' ||\n !options || typeof options !== 'object') {\n\n result.err = 'Invalid argument type';\n return result;\n }\n\n // Application time\n\n var timestamp = options.timestamp || Math.floor((hawk.utils.now() + (options.localtimeOffsetMsec || 0)) / 1000);\n\n // Validate credentials\n\n var credentials = options.credentials;\n if (!credentials ||\n !credentials.id ||\n !credentials.key ||\n !credentials.algorithm) {\n\n result.err = 'Invalid credential object';\n return result;\n }\n\n if (hawk.utils.baseIndexOf(hawk.crypto.algorithms, credentials.algorithm) === -1) {\n result.err = 'Unknown algorithm';\n return result;\n }\n\n // Parse URI\n\n if (typeof uri === 'string') {\n uri = hawk.utils.parseUri(uri);\n }\n\n // Calculate signature\n\n var artifacts = {\n ts: timestamp,\n nonce: options.nonce || hawk.utils.randomString(6),\n method: method,\n resource: uri.relative,\n host: uri.hostname,\n port: uri.port,\n hash: options.hash,\n ext: options.ext,\n app: options.app,\n dlg: options.dlg\n };\n\n result.artifacts = artifacts;\n\n // Calculate payload hash\n\n if (!artifacts.hash &&\n options.hasOwnProperty('payload')) {\n\n artifacts.hash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, options.contentType);\n }\n\n var mac = hawk.crypto.calculateMac('header', credentials, artifacts);\n\n // Construct header\n\n var hasExt = artifacts.ext !== null && artifacts.ext !== undefined && artifacts.ext !== ''; // Other falsey values allowed\n var header = 'Hawk id=\"' + credentials.id +\n '\", ts=\"' + artifacts.ts +\n '\", nonce=\"' + artifacts.nonce +\n (artifacts.hash ? '\", hash=\"' + artifacts.hash : '') +\n (hasExt ? '\", ext=\"' + hawk.utils.escapeHeaderAttribute(artifacts.ext) : '') +\n '\", mac=\"' + mac + '\"';\n\n if (artifacts.app) {\n header += ', app=\"' + artifacts.app +\n (artifacts.dlg ? '\", dlg=\"' + artifacts.dlg : '') + '\"';\n }\n\n result.field = header;\n\n return result;\n },\n\n\n // Validate server response\n\n /*\n request: object created via 'new XMLHttpRequest()' after response received\n artifacts: object recieved from header().artifacts\n options: {\n payload: optional payload received\n required: specifies if a Server-Authorization header is required. Defaults to 'false'\n }\n */\n\n authenticate: function (request, credentials, artifacts, options) {\n\n options = options || {};\n\n if (request.getResponseHeader('www-authenticate')) {\n\n // Parse HTTP WWW-Authenticate header\n\n var attrsAuth = hawk.utils.parseAuthorizationHeader(request.getResponseHeader('www-authenticate'), ['ts', 'tsm', 'error']);\n if (!attrsAuth) {\n return false;\n }\n\n if (attrsAuth.ts) {\n var tsm = hawk.crypto.calculateTsMac(attrsAuth.ts, credentials);\n if (tsm !== attrsAuth.tsm) {\n return false;\n }\n\n hawk.utils.setNtpOffset(attrsAuth.ts - Math.floor((new Date()).getTime() / 1000)); // Keep offset at 1 second precision\n }\n }\n\n // Parse HTTP Server-Authorization header\n\n if (!request.getResponseHeader('server-authorization') &&\n !options.required) {\n\n return true;\n }\n\n var attributes = hawk.utils.parseAuthorizationHeader(request.getResponseHeader('server-authorization'), ['mac', 'ext', 'hash']);\n if (!attributes) {\n return false;\n }\n\n var modArtifacts = {\n ts: artifacts.ts,\n nonce: artifacts.nonce,\n method: artifacts.method,\n resource: artifacts.resource,\n host: artifacts.host,\n port: artifacts.port,\n hash: attributes.hash,\n ext: attributes.ext,\n app: artifacts.app,\n dlg: artifacts.dlg\n };\n\n var mac = hawk.crypto.calculateMac('response', credentials, modArtifacts);\n if (mac !== attributes.mac) {\n return false;\n }\n\n if (!options.hasOwnProperty('payload')) {\n return true;\n }\n\n if (!attributes.hash) {\n return false;\n }\n\n var calculatedHash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, request.getResponseHeader('content-type'));\n return (calculatedHash === attributes.hash);\n },\n\n message: function (host, port, message, options) {\n\n // Validate inputs\n\n if (!host || typeof host !== 'string' ||\n !port || typeof port !== 'number' ||\n message === null || message === undefined || typeof message !== 'string' ||\n !options || typeof options !== 'object') {\n\n return null;\n }\n\n // Application time\n\n var timestamp = options.timestamp || Math.floor((hawk.utils.now() + (options.localtimeOffsetMsec || 0)) / 1000);\n\n // Validate credentials\n\n var credentials = options.credentials;\n if (!credentials ||\n !credentials.id ||\n !credentials.key ||\n !credentials.algorithm) {\n\n // Invalid credential object\n return null;\n }\n\n if (hawk.crypto.algorithms.indexOf(credentials.algorithm) === -1) {\n return null;\n }\n\n // Calculate signature\n\n var artifacts = {\n ts: timestamp,\n nonce: options.nonce || hawk.utils.randomString(6),\n host: host,\n port: port,\n hash: hawk.crypto.calculatePayloadHash(message, credentials.algorithm)\n };\n\n // Construct authorization\n\n var result = {\n id: credentials.id,\n ts: artifacts.ts,\n nonce: artifacts.nonce,\n hash: artifacts.hash,\n mac: hawk.crypto.calculateMac('message', credentials, artifacts)\n };\n\n return result;\n },\n\n authenticateTimestamp: function (message, credentials, updateClock) { // updateClock defaults to true\n\n var tsm = hawk.crypto.calculateTsMac(message.ts, credentials);\n if (tsm !== message.tsm) {\n return false;\n }\n\n if (updateClock !== false) {\n hawk.utils.setNtpOffset(message.ts - Math.floor((new Date()).getTime() / 1000)); // Keep offset at 1 second precision\n }\n\n return true;\n }\n };\n\n\n hawk.crypto = {\n\n headerVersion: '1',\n\n algorithms: ['sha1', 'sha256'],\n\n calculateMac: function (type, credentials, options) {\n var normalized = hawk.crypto.generateNormalizedString(type, options);\n var hmac = new sjcl.misc.hmac(credentials.key, sjcl.hash.sha256);\n hmac.update(normalized);\n\n return sjcl.codec.base64.fromBits(hmac.digest());\n },\n\n generateNormalizedString: function (type, options) {\n\n var normalized = 'hawk.' + hawk.crypto.headerVersion + '.' + type + '\\n' +\n options.ts + '\\n' +\n options.nonce + '\\n' +\n (options.method || '').toUpperCase() + '\\n' +\n (options.resource || '') + '\\n' +\n options.host.toLowerCase() + '\\n' +\n options.port + '\\n' +\n (options.hash || '') + '\\n';\n\n if (options.ext) {\n normalized += options.ext.replace('\\\\', '\\\\\\\\').replace('\\n', '\\\\n');\n }\n\n normalized += '\\n';\n\n if (options.app) {\n normalized += options.app + '\\n' +\n (options.dlg || '') + '\\n';\n }\n\n return normalized;\n },\n\n calculatePayloadHash: function (payload, algorithm, contentType) {\n var hash = new sjcl.hash.sha256();\n hash.update('hawk.' + hawk.crypto.headerVersion + '.payload\\n')\n .update(hawk.utils.parseContentType(contentType) + '\\n')\n .update(payload || '')\n .update('\\n');\n\n return sjcl.codec.base64.fromBits(hash.finalize());\n },\n\n calculateTsMac: function (ts, credentials) {\n var hmac = new sjcl.misc.hmac(credentials.key, sjcl.hash.sha256);\n hmac.update('hawk.' + hawk.crypto.headerVersion + '.ts\\n' + ts + '\\n');\n\n return sjcl.codec.base64.fromBits(hmac.digest());\n }\n };\n\n\n hawk.utils = {\n\n storage: { // localStorage compatible interface\n _cache: {},\n setItem: function (key, value) {\n\n hawk.utils.storage._cache[key] = value;\n },\n getItem: function (key) {\n\n return hawk.utils.storage._cache[key];\n }\n },\n\n setStorage: function (storage) {\n\n var ntpOffset = hawk.utils.getNtpOffset() || 0;\n hawk.utils.storage = storage;\n hawk.utils.setNtpOffset(ntpOffset);\n },\n\n setNtpOffset: function (offset) {\n\n try {\n hawk.utils.storage.setItem('hawk_ntp_offset', offset);\n }\n catch (err) {\n console.error('[hawk] could not write to storage.');\n console.error(err);\n }\n },\n\n getNtpOffset: function () {\n\n return parseInt(hawk.utils.storage.getItem('hawk_ntp_offset') || '0', 10);\n },\n\n now: function () {\n\n return (new Date()).getTime() + hawk.utils.getNtpOffset();\n },\n\n escapeHeaderAttribute: function (attribute) {\n\n return attribute.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"');\n },\n\n parseContentType: function (header) {\n\n if (!header) {\n return '';\n }\n\n return header.split(';')[0].replace(/^\\s+|\\s+$/g, '').toLowerCase();\n },\n\n parseAuthorizationHeader: function (header, keys) {\n\n if (!header) {\n return null;\n }\n\n var headerParts = header.match(/^(\\w+)(?:\\s+(.*))?$/); // Header: scheme[ something]\n if (!headerParts) {\n return null;\n }\n\n var scheme = headerParts[1];\n if (scheme.toLowerCase() !== 'hawk') {\n return null;\n }\n\n var attributesString = headerParts[2];\n if (!attributesString) {\n return null;\n }\n\n var attributes = {};\n var verify = attributesString.replace(/(\\w+)=\"([^\"\\\\]*)\"\\s*(?:,\\s*|$)/g, function ($0, $1, $2) {\n\n // Check valid attribute names\n\n if (keys.indexOf($1) === -1) {\n return;\n }\n\n // Allowed attribute value characters: !#$%&'()*+,-./:;<=>?@[]^_`{|}~ and space, a-z, A-Z, 0-9\n\n if ($2.match(/^[ \\w\\!#\\$%&'\\(\\)\\*\\+,\\-\\.\\/\\:;<\\=>\\?@\\[\\]\\^`\\{\\|\\}~]+$/) === null) {\n return;\n }\n\n // Check for duplicates\n\n if (attributes.hasOwnProperty($1)) {\n return;\n }\n\n attributes[$1] = $2;\n return '';\n });\n\n if (verify !== '') {\n return null;\n }\n\n return attributes;\n },\n\n randomString: function (size) {\n\n var randomSource = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';\n var len = randomSource.length;\n\n var result = [];\n for (var i = 0; i < size; ++i) {\n result[i] = randomSource[Math.floor(Math.random() * len)];\n }\n\n return result.join('');\n },\n\n baseIndexOf: function(array, value, fromIndex) {\n var index = (fromIndex || 0) - 1,\n length = array ? array.length : 0;\n\n while (++index < length) {\n if (array[index] === value) {\n return index;\n }\n }\n return -1;\n },\n\n parseUri: function (input) {\n\n // Based on: parseURI 1.2.2\n // http://blog.stevenlevithan.com/archives/parseuri\n // (c) Steven Levithan \n // MIT License\n\n var keys = ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'hostname', 'port', 'resource', 'relative', 'pathname', 'directory', 'file', 'query', 'fragment'];\n\n var uriRegex = /^(?:([^:\\/?#]+):)?(?:\\/\\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?))?(((((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?)(?:#(.*))?)/;\n var uriByNumber = uriRegex.exec(input);\n var uri = {};\n\n var i = 15;\n while (i--) {\n uri[keys[i]] = uriByNumber[i] || '';\n }\n\n if (uri.port === null ||\n uri.port === '') {\n\n uri.port = (uri.protocol.toLowerCase() === 'http' ? '80' : (uri.protocol.toLowerCase() === 'https' ? '443' : ''));\n }\n\n return uri;\n }\n };\n\n\n return hawk;\n});\n\n","/*!\r\n * Copyright 2013 Robert Katić\r\n * Released under the MIT license\r\n * https://github.com/rkatic/p/blob/master/LICENSE\r\n *\r\n * High-priority-tasks code-portion based on https://github.com/kriskowal/asap\r\n */\r\n;(function( factory ){\r\n\t// CommonJS\r\n\tif ( typeof module !== \"undefined\" && module && module.exports ) {\r\n\t\tmodule.exports = factory();\r\n\r\n\t// RequireJS\r\n\t} else if ( typeof define === \"function\" && define.amd ) {\r\n\t\tdefine( 'p',factory );\r\n\r\n\t// global\r\n\t} else {\r\n\t\tP = factory();\r\n\t}\r\n})(function() {\r\n\t\"use strict\";\r\n\r\n\tvar\r\n\t\tisNodeJS = ot(typeof process) &&\r\n\t\t\t({}).toString.call(process) === \"[object process]\",\r\n\r\n\t\thasSetImmediate = ot(typeof setImmediate),\r\n\r\n\t\thead = { f: null, n: null }, tail = head,\r\n\t\tflushing = false,\r\n\r\n\t\trequestFlush =\r\n\t\t\tisNodeJS && requestFlushForNodeJS ||\r\n\t\t\tmakeRequestCallFromMutationObserver( flush ) ||\r\n\t\t\tmakeRequestCallFromTimer( flush ),\r\n\r\n\t\tpendingErrors = [],\r\n\t\trequestErrorThrow = makeRequestCallFromTimer( throwFristError ),\r\n\r\n\t\twrapTask,\r\n\t\tasapSafeTask,\r\n\r\n\t\tdomain,\r\n\r\n\t\tcall = ot.call,\r\n\t\tapply = ot.apply;\r\n\r\n\tfunction ot( type ) {\r\n\t\treturn type === \"object\" || type === \"function\";\r\n\t}\r\n\r\n\tfunction throwFristError() {\r\n\t\tif ( pendingErrors.length ) {\r\n\t\t\tthrow pendingErrors.shift();\r\n\t\t}\r\n\t}\r\n\r\n\tfunction flush() {\r\n\t\twhile ( head.n ) {\r\n\t\t\thead = head.n;\r\n\t\t\tvar f = head.f;\r\n\t\t\thead.f = null;\r\n\t\t\tf.call();\r\n\t\t}\r\n\t\tflushing = false;\r\n\t}\r\n\r\n\tvar runLater = function( f ) {\r\n\t\ttail = tail.n = { f: f, n: null };\r\n\t\tif ( !flushing ) {\r\n\t\t\tflushing = true;\r\n\t\t\trequestFlush();\r\n\t\t}\r\n\t};\r\n\r\n\tfunction requestFlushForNodeJS() {\r\n\t\tvar currentDomain = process.domain;\r\n\r\n\t\tif ( currentDomain ) {\r\n\t\t\tif ( !domain ) domain = (1,require)(\"domain\");\r\n\t\t\tdomain.active = process.domain = null;\r\n\t\t}\r\n\r\n\t\tif ( flushing && hasSetImmediate ) {\r\n\t\t\tsetImmediate( flush );\r\n\r\n\t\t} else {\r\n\t\t\tprocess.nextTick( flush );\r\n\t\t}\r\n\r\n\t\tif ( currentDomain ) {\r\n\t\t\tdomain.active = process.domain = currentDomain;\r\n\t\t}\r\n\t}\r\n\r\n\tfunction makeRequestCallFromMutationObserver( callback ) {\r\n\t\tvar observer =\r\n\t\t\tot(typeof MutationObserver) ? new MutationObserver( callback ) :\r\n\t\t\tot(typeof WebKitMutationObserver) ? new WebKitMutationObserver( callback ) :\r\n\t\t\tnull;\r\n\r\n\t\tif ( !observer ) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tvar toggle = 1;\r\n\t\tvar node = document.createTextNode(\"\");\r\n\t\tobserver.observe( node, {characterData: true} );\r\n\r\n\t\treturn function() {\r\n\t\t\ttoggle = -toggle;\r\n\t\t\tnode.data = toggle;\r\n\t\t};\r\n\t}\r\n\r\n\tfunction makeRequestCallFromTimer( callback ) {\r\n\t\treturn function() {\r\n\t\t\tvar timeoutHandle = setTimeout( handleTimer, 0 );\r\n\t\t\tvar intervalHandle = setInterval( handleTimer, 50 );\r\n\r\n\t\t\tfunction handleTimer() {\r\n\t\t\t\tclearTimeout( timeoutHandle );\r\n\t\t\t\tclearInterval( intervalHandle );\r\n\t\t\t\tcallback();\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n\r\n\tif ( isNodeJS ) {\r\n\t\twrapTask = function( task ) {\r\n\t\t\tvar d = process.domain;\r\n\r\n\t\t\treturn function() {\r\n\t\t\t\tif ( d ) {\r\n\t\t\t\t\tif ( d._disposed ) return;\r\n\t\t\t\t\td.enter();\r\n\t\t\t\t}\r\n\r\n\t\t\t\ttry {\r\n\t\t\t\t\ttask.call();\r\n\r\n\t\t\t\t} catch ( e ) {\r\n\t\t\t\t\trequestFlush();\r\n\t\t\t\t\tthrow e;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif ( d ) {\r\n\t\t\t\t\td.exit();\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t};\r\n\r\n\t\tasapSafeTask = function( task ) {\r\n\t\t\tvar d = process.domain;\r\n\t\t\trunLater(!d ? task : function() {\r\n\t\t\t\tif ( !d._disposed ) {\r\n\t\t\t\t\td.enter();\r\n\t\t\t\t\ttask.call();\r\n\t\t\t\t\td.exit();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t} else {\r\n\t\twrapTask = function( task ) {\r\n\t\t\treturn function() {\r\n\t\t\t\ttry {\r\n\t\t\t\t\ttask.call();\r\n\r\n\t\t\t\t} catch ( e ) {\r\n\t\t\t\t\tpendingErrors.push( e );\r\n\t\t\t\t\trequestErrorThrow();\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\tasapSafeTask = runLater;\r\n\t}\r\n\r\n\r\n\tfunction asap( task ) {\r\n\t\trunLater( wrapTask(task) );\r\n\t}\r\n\r\n\t//__________________________________________________________________________\r\n\r\n\r\n\tfunction forEach( arr, cb ) {\r\n\t\tfor ( var i = 0, l = arr.length; i < l; ++i ) {\r\n\t\t\tif ( i in arr ) {\r\n\t\t\t\tcb( arr[i], i );\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfunction reportError( error ) {\r\n\t\tasap(function() {\r\n\t\t\tif ( P.onerror ) {\r\n\t\t\t\tP.onerror.call( null, error );\r\n\r\n\t\t\t} else {\r\n\t\t\t\tthrow error;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tvar PENDING = 0;\r\n\tvar FULFILLED = 1;\r\n\tvar REJECTED = 2;\r\n\r\n\tfunction P( x ) {\r\n\t\treturn x instanceof Promise ?\r\n\t\t\tx :\r\n\t\t\tResolve( new Promise(), x );\r\n\t}\r\n\r\n\tfunction Settle( p, state, value, domain ) {\r\n\t\tif ( p._state ) {\r\n\t\t\treturn p;\r\n\t\t}\r\n\r\n\t\tp._state = state;\r\n\t\tp._value = value;\r\n\r\n\t\tif ( domain ) {\r\n\t\t\tp._domain = domain;\r\n\r\n\t\t} else if ( isNodeJS && state === REJECTED ) {\r\n\t\t\tp._domain = process.domain;\r\n\t\t}\r\n\r\n\t\tif ( p._pending.length ) {\r\n\t\t\tforEach( p._pending, runLater );\r\n\t\t}\r\n\t\tp._pending = null;\r\n\r\n\t\treturn p;\r\n\t}\r\n\r\n\tfunction OnSettled( p, f ) {\r\n\t\tp._pending.push( f );\r\n\t}\r\n\r\n\tfunction Propagate( p, p2 ) {\r\n\t\tSettle( p2, p._state, p._value, p._domain );\r\n\t}\r\n\r\n\tfunction Resolve( p, x ) {\r\n\t\tif ( p._state ) {\r\n\t\t\treturn p;\r\n\t\t}\r\n\r\n\t\tif ( x instanceof Promise ) {\r\n\t\t\tif ( x === p ) {\r\n\t\t\t\tSettle( p, REJECTED, new TypeError(\"You can't resolve a promise with itself\") );\r\n\r\n\t\t\t} else if ( x._state ) {\r\n\t\t\t\tPropagate( x, p );\r\n\r\n\t\t\t} else {\r\n\t\t\t\tOnSettled(x, function() {\r\n\t\t\t\t\tPropagate( x, p );\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t} else if ( x !== Object(x) ) {\r\n\t\t\tSettle( p, FULFILLED, x );\r\n\r\n\t\t} else {\r\n\t\t\tasapSafeTask(function() {\r\n\t\t\t\tvar r = resolverFor( p );\r\n\r\n\t\t\t\ttry {\r\n\t\t\t\t\tvar then = x.then;\r\n\r\n\t\t\t\t\tif ( typeof then === \"function\" ) {\r\n\t\t\t\t\t\tcall.call( then, x, r.resolve, r.reject );\r\n\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tSettle( p, FULFILLED, x );\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t} catch ( e ) {\r\n\t\t\t\t\tr.reject( e );\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn p;\r\n\t}\r\n\r\n\tfunction resolverFor( promise ) {\r\n\t\tvar done = false;\r\n\r\n\t\treturn {\r\n\t\t\tpromise: promise,\r\n\r\n\t\t\tresolve: function( y ) {\r\n\t\t\t\tif ( !done ) {\r\n\t\t\t\t\tdone = true;\r\n\t\t\t\t\tResolve( promise, y );\r\n\t\t\t\t}\r\n\t\t\t},\r\n\r\n\t\t\treject: function( reason ) {\r\n\t\t\t\tif ( !done ) {\r\n\t\t\t\t\tdone = true;\r\n\t\t\t\t\tSettle( promise, REJECTED, reason );\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n\r\n\tP.defer = defer;\r\n\tfunction defer() {\r\n\t\treturn resolverFor( new Promise() );\r\n\t}\r\n\r\n\tP.reject = reject;\r\n\tfunction reject( reason ) {\r\n\t\treturn Settle( new Promise(), REJECTED, reason );\r\n\t}\r\n\r\n\tfunction Promise() {\r\n\t\tthis._state = 0;\r\n\t\tthis._value = void 0;\r\n\t\tthis._domain = null;\r\n\t\tthis._pending = [];\r\n\t}\r\n\r\n\tPromise.prototype.then = function( onFulfilled, onRejected ) {\r\n\t\tvar cb = typeof onFulfilled === \"function\" ? onFulfilled : null;\r\n\t\tvar eb = typeof onRejected === \"function\" ? onRejected : null;\r\n\r\n\t\tvar p = this;\r\n\t\tvar p2 = new Promise();\r\n\r\n\t\tvar thenDomain = isNodeJS && process.domain;\r\n\r\n\t\tfunction onSettled() {\r\n\t\t\tvar func = p._state === FULFILLED ? cb : eb;\r\n\t\t\tif ( !func ) {\r\n\t\t\t\tPropagate( p, p2 );\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tvar x, catched = false;\r\n\t\t\tvar d = p._domain || thenDomain;\r\n\r\n\t\t\tif ( d ) {\r\n\t\t\t\tif ( d._disposed ) return;\r\n\t\t\t\td.enter();\r\n\t\t\t}\r\n\r\n\t\t\ttry {\r\n\t\t\t\tx = func( p._value );\r\n\r\n\t\t\t} catch ( e ) {\r\n\t\t\t\tcatched = true;\r\n\t\t\t\tSettle( p2, REJECTED, e );\r\n\t\t\t}\r\n\r\n\t\t\tif ( !catched ) {\r\n\t\t\t\tResolve( p2, x );\r\n\t\t\t}\r\n\r\n\t\t\tif ( d ) {\r\n\t\t\t\td.exit();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif ( p._state === PENDING ) {\r\n\t\t\tOnSettled( p, onSettled );\r\n\r\n\t\t} else {\r\n\t\t\trunLater( onSettled );\r\n\t\t}\r\n\r\n\t\treturn p2;\r\n\t};\r\n\r\n\tPromise.prototype.done = function( cb, eb ) {\r\n\t\tvar p = this;\r\n\r\n\t\tif ( cb || eb ) {\r\n\t\t\tp = p.then( cb, eb );\r\n\t\t}\r\n\r\n\t\tp.then( null, reportError );\r\n\t};\r\n\r\n\tPromise.prototype.fail = function( eb ) {\r\n\t\treturn this.then( null, eb );\r\n\t};\r\n\r\n\tPromise.prototype.spread = function( cb, eb ) {\r\n\t\treturn this.then(cb && function( array ) {\r\n\t\t\treturn all( array, [] ).then(function( values ) {\r\n\t\t\t\treturn apply.call( cb, void 0, values );\r\n\t\t\t}, eb);\r\n\t\t}, eb);\r\n\t};\r\n\r\n\tPromise.prototype.timeout = function( ms, msg ) {\r\n\t\tvar p = this;\r\n\t\tvar p2 = new Promise();\r\n\r\n\t\tif ( p._state !== PENDING ) {\r\n\t\t\tPropagate( p, p2 );\r\n\r\n\t\t} else {\r\n\t\t\tvar timeoutId = setTimeout(function() {\r\n\t\t\t\tSettle( p2, REJECTED,\r\n\t\t\t\t\tnew Error(msg || \"Timed out after \" + ms + \" ms\") );\r\n\t\t\t}, ms);\r\n\r\n\t\t\tOnSettled(p, function() {\r\n\t\t\t\tclearTimeout( timeoutId );\r\n\t\t\t\tPropagate( p, p2 );\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn p2;\r\n\t};\r\n\r\n\tPromise.prototype.delay = function( ms ) {\r\n\t\tvar d = defer();\r\n\r\n\t\tthis.then(function( value ) {\r\n\t\t\tsetTimeout(function() {\r\n\t\t\t\td.resolve( value );\r\n\t\t\t}, ms);\r\n\t\t}, d.reject);\r\n\r\n\t\treturn d.promise;\r\n\t};\r\n\r\n\tPromise.prototype.inspect = function() {\r\n\t\tswitch ( this._state ) {\r\n\t\t\tcase PENDING: return { state: \"pending\" };\r\n\t\t\tcase FULFILLED: return { state: \"fulfilled\", value: this._value };\r\n\t\t\tcase REJECTED: return { state: \"rejected\", reason: this._value };\r\n\t\t\tdefault: throw new TypeError(\"invalid state\");\r\n\t\t}\r\n\t};\r\n\r\n\tfunction valuesHandler( f ) {\r\n\t\tfunction onFulfilled( values ) {\r\n\t\t\treturn f( values, [] );\r\n\t\t}\r\n\r\n\t\tfunction handleValues( values ) {\r\n\t\t\treturn P( values ).then( onFulfilled );\r\n\t\t}\r\n\r\n\t\thandleValues._ = f;\r\n\t\treturn handleValues;\r\n\t}\r\n\r\n\tP.allSettled = valuesHandler( allSettled );\r\n\tfunction allSettled( input, output ) {\r\n\t\tvar waiting = 0;\r\n\t\tvar promise = new Promise();\r\n\t\tforEach( input, function( x, index ) {\r\n\t\t\tvar p = P( x );\r\n\t\t\tif ( p._state === PENDING ) {\r\n\t\t\t\t++waiting;\r\n\t\t\t\tOnSettled(p, function() {\r\n\t\t\t\t\toutput[ index ] = p.inspect();\r\n\t\t\t\t\tif ( --waiting === 0 ) {\r\n\t\t\t\t\t\tSettle( promise, FULFILLED, output );\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t} else {\r\n\t\t\t\toutput[ index ] = p.inspect();\r\n\t\t\t}\r\n\t\t});\r\n\t\tif ( waiting === 0 ) {\r\n\t\t\tSettle( promise, FULFILLED, output );\r\n\t\t}\r\n\t\treturn promise;\r\n\t}\r\n\r\n\tP.all = valuesHandler( all );\r\n\tfunction all( input, output ) {\r\n\t\tvar waiting = 0;\r\n\t\tvar d = defer();\r\n\t\tforEach( input, function( x, index ) {\r\n\t\t\tvar p = P( x );\r\n\t\t\tif ( p._state === FULFILLED ) {\r\n\t\t\t\toutput[ index ] = p._value;\r\n\r\n\t\t\t} else {\r\n\t\t\t\t++waiting;\r\n\t\t\t\tp.then(function( value ) {\r\n\t\t\t\t\toutput[ index ] = value;\r\n\t\t\t\t\tif ( --waiting === 0 ) {\r\n\t\t\t\t\t\td.resolve( output );\r\n\t\t\t\t\t}\r\n\t\t\t\t}, d.reject);\r\n\t\t\t}\r\n\t\t});\r\n\t\tif ( waiting === 0 ) {\r\n\t\t\td.resolve( output );\r\n\t\t}\r\n\t\treturn d.promise;\r\n\t}\r\n\r\n\tP.promised = promised;\r\n\tfunction promised( f ) {\r\n\t\tfunction onFulfilled( thisAndArgs ) {\r\n\t\t\treturn apply.apply( f, thisAndArgs );\r\n\t\t}\r\n\r\n\t\treturn function() {\r\n\t\t\tvar allArgs = all( arguments, [] );\r\n\t\t\treturn all( [this, allArgs], [] ).then( onFulfilled );\r\n\t\t};\r\n\t}\r\n\r\n\tP.onerror = null;\r\n\r\n\tP.nextTick = asap;\r\n\r\n\treturn P;\r\n});\r\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/lib/errors',[], function () {\n return {\n INVALID_TIMESTAMP: 111,\n INCORRECT_EMAIL_CASE: 120\n };\n});\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/lib/request',['./hawk', 'p', './errors'], function (hawk, P, ERRORS) {\n 'use strict';\n /* global XMLHttpRequest */\n\n /**\n * @class Request\n * @constructor\n * @param {String} baseUri Base URI\n * @param {Object} xhr XMLHttpRequest constructor\n * @param {Object} [options={}] Options\n * @param {Number} [options.localtimeOffsetMsec]\n * Local time offset with the remote auth server's clock\n */\n function Request (baseUri, xhr, options) {\n if (!options) {\n options = {};\n }\n this.baseUri = baseUri;\n this._localtimeOffsetMsec = options.localtimeOffsetMsec;\n this.xhr = xhr || XMLHttpRequest;\n this.timeout = options.timeout || 30 * 1000;\n }\n\n /**\n * @method send\n * @param {String} path Request path\n * @param {String} method HTTP Method\n * @param {Object} credentials HAWK Headers\n * @param {Object} jsonPayload JSON Payload\n * @param {Object} [options={}] Options\n * @param {String} [options.retrying]\n * Flag indicating if the request is a retry\n * @param {Array} [options.headers]\n * A set of extra headers to add to the request\n * @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request\n */\n Request.prototype.send = function request(path, method, credentials, jsonPayload, options) {\n var deferred = P.defer();\n var xhr = new this.xhr();\n var uri = this.baseUri + path;\n var payload = null;\n var self = this;\n options = options || {};\n\n if (jsonPayload) {\n payload = JSON.stringify(jsonPayload);\n }\n\n try {\n xhr.open(method, uri);\n } catch (e) {\n deferred.reject({ error: 'Unknown error', message: e.toString(), errno: 999 });\n }\n\n xhr.timeout = this.timeout;\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n var result = xhr.responseText;\n try {\n result = JSON.parse(xhr.responseText);\n } catch (e) { }\n\n if (result.errno) {\n // Try to recover from a timeskew error and not already tried\n if (result.errno === ERRORS.INVALID_TIMESTAMP && !options.retrying) {\n var serverTime = result.serverTime;\n self._localtimeOffsetMsec = (serverTime * 1000) - new Date().getTime();\n\n // add to options that the request is retrying\n options.retrying = true;\n\n return self.send(path, method, credentials, jsonPayload, options)\n .then(deferred.resolve, deferred.reject);\n\n } else {\n return deferred.reject(result);\n }\n }\n\n if (typeof xhr.status === 'undefined' || xhr.status !== 200) {\n if (result.length === 0) {\n return deferred.reject({ error: 'Timeout error', errno: 999 });\n } else {\n return deferred.reject({ error: 'Unknown error', message: result, errno: 999, code: xhr.status });\n }\n }\n\n deferred.resolve(result);\n }\n };\n\n // calculate Hawk header if credentials are supplied\n if (credentials) {\n var hawkHeader = hawk.client.header(uri, method, {\n credentials: credentials,\n payload: payload,\n contentType: 'application/json',\n localtimeOffsetMsec: this._localtimeOffsetMsec || 0\n });\n xhr.setRequestHeader('authorization', hawkHeader.field);\n }\n\n xhr.setRequestHeader('Content-Type', 'application/json');\n\n if (options && options.headers) {\n // set extra headers for this request\n for (var header in options.headers) {\n xhr.setRequestHeader(header, options.headers[header]);\n }\n }\n\n xhr.send(payload);\n\n return deferred.promise;\n };\n\n return Request;\n\n});\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/lib/hkdf',['sjcl', 'p'], function (sjcl, P) {\n 'use strict';\n\n /**\n * hkdf - The HMAC-based Key Derivation Function\n * based on https://github.com/mozilla/node-hkdf\n *\n * @class hkdf\n * @param {bitArray} ikm Initial keying material\n * @param {bitArray} info Key derivation data\n * @param {bitArray} salt Salt\n * @param {integer} length Length of the derived key in bytes\n * @return promise object- It will resolve with `output` data\n */\n function hkdf(ikm, info, salt, length) {\n\n var mac = new sjcl.misc.hmac(salt, sjcl.hash.sha256);\n mac.update(ikm);\n\n // compute the PRK\n var prk = mac.digest();\n\n // hash length is 32 because only sjcl.hash.sha256 is used at this moment\n var hashLength = 32;\n var num_blocks = Math.ceil(length / hashLength);\n var prev = sjcl.codec.hex.toBits('');\n var output = '';\n\n for (var i = 0; i < num_blocks; i++) {\n var hmac = new sjcl.misc.hmac(prk, sjcl.hash.sha256);\n\n var input = sjcl.bitArray.concat(\n sjcl.bitArray.concat(prev, info),\n sjcl.codec.utf8String.toBits((String.fromCharCode(i + 1)))\n );\n\n hmac.update(input);\n\n prev = hmac.digest();\n output += sjcl.codec.hex.fromBits(prev);\n }\n\n var truncated = sjcl.bitArray.clamp(sjcl.codec.hex.toBits(output), length * 8);\n\n return P(truncated);\n }\n\n return hkdf;\n\n});\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/lib/pbkdf2',['sjcl', 'p'], function (sjcl, P) {\n 'use strict';\n\n /**\n * @class pbkdf2\n * @constructor\n */\n var pbkdf2 = {\n /**\n * @method derive\n * @param {bitArray} input The password hex buffer.\n * @param {bitArray} salt The salt string buffer.\n * @return {int} iterations the derived key bit array.\n */\n derive: function(input, salt, iterations, len) {\n var result = sjcl.misc.pbkdf2(input, salt, iterations, len, sjcl.misc.hmac);\n return P(result);\n }\n };\n\n return pbkdf2;\n\n});\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/lib/credentials',['./request', 'sjcl', 'p', './hkdf', './pbkdf2'], function (Request, sjcl, P, hkdf, pbkdf2) {\n 'use strict';\n\n // Key wrapping and stretching configuration.\n var NAMESPACE = 'identity.mozilla.com/picl/v1/';\n var PBKDF2_ROUNDS = 1000;\n var STRETCHED_PASS_LENGTH_BYTES = 32 * 8;\n\n var HKDF_SALT = sjcl.codec.hex.toBits('00');\n var HKDF_LENGTH = 32;\n\n /**\n * Key Wrapping with a name\n *\n * @method kw\n * @static\n * @param {String} name The name of the salt\n * @return {bitArray} the salt combination with the namespace\n */\n function kw(name) {\n return sjcl.codec.utf8String.toBits(NAMESPACE + name);\n }\n\n /**\n * Key Wrapping with a name and an email\n *\n * @method kwe\n * @static\n * @param {String} name The name of the salt\n * @param {String} email The email of the user.\n * @return {bitArray} the salt combination with the namespace\n */\n function kwe(name, email) {\n return sjcl.codec.utf8String.toBits(NAMESPACE + name + ':' + email);\n }\n\n /**\n * @class credentials\n * @constructor\n */\n return {\n /**\n * Setup credentials\n *\n * @method setup\n * @param {String} emailInput\n * @param {String} passwordInput\n * @return {Promise} A promise that will be fulfilled with `result` of generated credentials\n */\n setup: function (emailInput, passwordInput) {\n var result = {};\n var email = kwe('quickStretch', emailInput);\n var password = sjcl.codec.utf8String.toBits(passwordInput);\n\n result.emailUTF8 = emailInput;\n result.passwordUTF8 = passwordInput;\n\n return pbkdf2.derive(password, email, PBKDF2_ROUNDS, STRETCHED_PASS_LENGTH_BYTES)\n .then(\n function (quickStretchedPW) {\n result.quickStretchedPW = quickStretchedPW;\n\n return hkdf(quickStretchedPW, kw('authPW'), HKDF_SALT, HKDF_LENGTH)\n .then(\n function (authPW) {\n result.authPW = authPW;\n\n return hkdf(quickStretchedPW, kw('unwrapBkey'), HKDF_SALT, HKDF_LENGTH);\n }\n );\n }\n )\n .then(\n function (unwrapBKey) {\n result.unwrapBKey = unwrapBKey;\n return result;\n }\n );\n },\n /**\n * Wrap\n *\n * @method wrap\n * @param {bitArray} bitArray1\n * @param {bitArray} bitArray2\n * @return {bitArray} wrap result of the two bitArrays\n */\n xor: function (bitArray1, bitArray2) {\n var result = [];\n\n for (var i = 0; i < bitArray1.length; i++) {\n result[i] = bitArray1[i] ^ bitArray2[i];\n }\n\n return result;\n },\n /**\n * Unbundle the WrapKB\n * @param {String} key Bundle Key in hex\n * @param {String} bundle Key bundle in hex\n * @returns {*}\n */\n unbundleKeyFetchResponse: function (key, bundle) {\n var self = this;\n var bitBundle = sjcl.codec.hex.toBits(bundle);\n\n return this.deriveBundleKeys(key, 'account/keys')\n .then(\n function (keys) {\n var ciphertext = sjcl.bitArray.bitSlice(bitBundle, 0, 8 * 64);\n var expectedHmac = sjcl.bitArray.bitSlice(bitBundle, 8 * -32);\n var hmac = new sjcl.misc.hmac(keys.hmacKey, sjcl.hash.sha256);\n hmac.update(ciphertext);\n\n if (!sjcl.bitArray.equal(hmac.digest(), expectedHmac)) {\n throw new Error('Bad HMac');\n }\n\n var keyAWrapB = self.xor(sjcl.bitArray.bitSlice(bitBundle, 0, 8 * 64), keys.xorKey);\n\n return {\n kA: sjcl.codec.hex.fromBits(sjcl.bitArray.bitSlice(keyAWrapB, 0, 8 * 32)),\n wrapKB: sjcl.codec.hex.fromBits(sjcl.bitArray.bitSlice(keyAWrapB, 8 * 32))\n };\n }\n );\n },\n /**\n * Derive the HMAC and XOR keys required to encrypt a given size of payload.\n * @param {String} key Hex Bundle Key\n * @param {String} keyInfo Bundle Key Info\n * @returns {Object} hmacKey, xorKey\n */\n deriveBundleKeys: function(key, keyInfo) {\n var bitKeyInfo = kw(keyInfo);\n var salt = sjcl.codec.hex.toBits('');\n key = sjcl.codec.hex.toBits(key);\n\n return hkdf(key, bitKeyInfo, salt, 3 * 32)\n .then(\n function (keyMaterial) {\n\n return {\n hmacKey: sjcl.bitArray.bitSlice(keyMaterial, 0, 8 * 32),\n xorKey: sjcl.bitArray.bitSlice(keyMaterial, 8 * 32)\n };\n }\n );\n }\n };\n\n});\n\n","/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\ndefine('client/lib/hawkCredentials',['sjcl', './hkdf'], function (sjcl, hkdf) {\n 'use strict';\n\n var PREFIX_NAME = 'identity.mozilla.com/picl/v1/';\n var bitSlice = sjcl.bitArray.bitSlice;\n var salt = sjcl.codec.hex.toBits('');\n\n /**\n * @class hawkCredentials\n * @method deriveHawkCredentials\n * @param {String} tokenHex\n * @param {String} context\n * @param {int} size\n * @returns {Promise}\n */\n function deriveHawkCredentials(tokenHex, context, size) {\n var token = sjcl.codec.hex.toBits(tokenHex);\n var info = sjcl.codec.utf8String.toBits(PREFIX_NAME + context);\n\n return hkdf(token, info, salt, size || 3 * 32)\n .then(function(out) {\n var authKey = bitSlice(out, 8 * 32, 8 * 64);\n var bundleKey = bitSlice(out, 8 * 64);\n\n return {\n algorithm: 'sha256',\n id: sjcl.codec.hex.fromBits(bitSlice(out, 0, 8 * 32)),\n key: authKey,\n bundleKey: bundleKey\n };\n });\n }\n\n return deriveHawkCredentials;\n});\n\n"]} \ No newline at end of file