diff --git a/dist/amazon-cognito-identity.js b/dist/amazon-cognito-identity.js index b3dbb267..a5b95e57 100644 --- a/dist/amazon-cognito-identity.js +++ b/dist/amazon-cognito-identity.js @@ -1488,7 +1488,7 @@ return /******/ (function(modules) { // webpackBootstrap this.signInUserSession = null; this.authenticationFlowType = 'USER_SRP_AUTH'; - this.storage = data.Storage || new _StorageHelper2.default().getStorage(); + this.storage = this.pool.getStorage(); } /** @@ -3369,8 +3369,7 @@ return /******/ (function(modules) { // webpackBootstrap var cognitoUser = { Username: username, - Pool: _this, - Storage: _this.storage + Pool: _this }; var returnData = { @@ -3396,8 +3395,7 @@ return /******/ (function(modules) { // webpackBootstrap if (lastAuthUser) { var cognitoUser = { Username: lastAuthUser, - Pool: this, - Storage: this.storage + Pool: this }; return new _CognitoUser2.default(cognitoUser); @@ -3406,6 +3404,16 @@ return /******/ (function(modules) { // webpackBootstrap return null; }; + /** + * This is used to return the storage + * @returns {object} the storage + */ + + + CognitoUserPool.prototype.getStorage = function getStorage() { + return this.storage; + }; + return CognitoUserPool; }(); diff --git a/dist/amazon-cognito-identity.min.js b/dist/amazon-cognito-identity.min.js index 8f6b57f9..a499fd2b 100644 --- a/dist/amazon-cognito-identity.min.js +++ b/dist/amazon-cognito-identity.min.js @@ -30,7 +30,7 @@ * for the specific language governing permissions and * limitations under the License. */ -var i=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.RefreshToken;n(this,e),this.token=i||""}return e.prototype.getToken=function(){return this.token},e}();t.default=i},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var o=n(1),r=n(3),a=i(r),u=n(2),c=i(u),l=n(4),h=i(l),f=n(5),d=i(f),p=n(6),g=i(p),v=n(9),m=i(v),S=n(10),y=i(S),C=n(8),w=i(C),A=n(11),T=i(A),U=function(){function e(t){if(s(this,e),null==t||null==t.Username||null==t.Pool)throw new Error("Username and pool information are required.");this.username=t.Username||"",this.pool=t.Pool,this.Session=null,this.client=t.Pool.client,this.signInUserSession=null,this.authenticationFlowType="USER_SRP_AUTH",this.storage=t.Storage||(new T.default).getStorage()}return e.prototype.getSignInUserSession=function(){return this.signInUserSession},e.prototype.getUsername=function(){return this.username},e.prototype.getAuthenticationFlowType=function(){return this.authenticationFlowType},e.prototype.setAuthenticationFlowType=function(e){this.authenticationFlowType=e},e.prototype.authenticateUser=function(e,t){var n=this,i=new c.default(this.pool.getUserPoolId().split("_")[1]),s=new y.default,r=void 0,u=void 0,l={};null!=this.deviceKey&&(l.DEVICE_KEY=this.deviceKey),l.USERNAME=this.username,l.SRP_A=i.getLargeAValue().toString(16),"CUSTOM_AUTH"===this.authenticationFlowType&&(l.CHALLENGE_NAME="SRP_A"),this.client.makeUnauthenticatedRequest("initiateAuth",{AuthFlow:this.authenticationFlowType,ClientId:this.pool.getClientId(),AuthParameters:l,ClientMetadata:e.getValidationData()},function(c,l){if(c)return t.onFailure(c);var h=l.ChallengeParameters;n.username=h.USER_ID_FOR_SRP,r=new a.default(h.SRP_B,16),u=new a.default(h.SALT,16),n.getCachedDeviceKeyAndPassword();var f=i.getPasswordAuthenticationKey(n.username,e.getPassword(),r,u),d=s.getNowString(),p=o.util.crypto.hmac(f,o.util.buffer.concat([new o.util.Buffer(n.pool.getUserPoolId().split("_")[1],"utf8"),new o.util.Buffer(n.username,"utf8"),new o.util.Buffer(h.SECRET_BLOCK,"base64"),new o.util.Buffer(d,"utf8")]),"base64","sha256"),g={};g.USERNAME=n.username,g.PASSWORD_CLAIM_SECRET_BLOCK=h.SECRET_BLOCK,g.TIMESTAMP=d,g.PASSWORD_CLAIM_SIGNATURE=p,null!=n.deviceKey&&(g.DEVICE_KEY=n.deviceKey);var v=function e(t,i){return n.client.makeUnauthenticatedRequest("respondToAuthChallenge",t,function(s,o){return s&&"ResourceNotFoundException"===s.code&&s.message.toLowerCase().indexOf("device")!==-1?(g.DEVICE_KEY=null,n.deviceKey=null,n.randomPassword=null,n.deviceGroupKey=null,n.clearCachedDeviceKeyAndPassword(),e(t,i)):i(s,o)})};v({ChallengeName:"PASSWORD_VERIFIER",ClientId:n.pool.getClientId(),ChallengeResponses:g,Session:l.Session},function(e,s){if(e)return t.onFailure(e);var o=s.ChallengeName;if("NEW_PASSWORD_REQUIRED"===o){n.Session=s.Session;var r=null,a=null,u=[],c=i.getNewPasswordRequiredChallengeUserAttributePrefix();if(s.ChallengeParameters&&(r=JSON.parse(s.ChallengeParameters.userAttributes),a=JSON.parse(s.ChallengeParameters.requiredAttributes)),a)for(var l=0;l0&&void 0!==arguments[0]?arguments[0]:{},i=t.RefreshToken;n(this,e),this.token=i||""}return e.prototype.getToken=function(){return this.token},e}();t.default=i},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var o=n(1),r=n(3),a=i(r),u=n(2),c=i(u),l=n(4),h=i(l),f=n(5),d=i(f),p=n(6),g=i(p),v=n(9),m=i(v),S=n(10),y=i(S),C=n(8),w=i(C),A=n(11),T=(i(A),function(){function e(t){if(s(this,e),null==t||null==t.Username||null==t.Pool)throw new Error("Username and pool information are required.");this.username=t.Username||"",this.pool=t.Pool,this.Session=null,this.client=t.Pool.client,this.signInUserSession=null,this.authenticationFlowType="USER_SRP_AUTH",this.storage=this.pool.getStorage()}return e.prototype.getSignInUserSession=function(){return this.signInUserSession},e.prototype.getUsername=function(){return this.username},e.prototype.getAuthenticationFlowType=function(){return this.authenticationFlowType},e.prototype.setAuthenticationFlowType=function(e){this.authenticationFlowType=e},e.prototype.authenticateUser=function(e,t){var n=this,i=new c.default(this.pool.getUserPoolId().split("_")[1]),s=new y.default,r=void 0,u=void 0,l={};null!=this.deviceKey&&(l.DEVICE_KEY=this.deviceKey),l.USERNAME=this.username,l.SRP_A=i.getLargeAValue().toString(16),"CUSTOM_AUTH"===this.authenticationFlowType&&(l.CHALLENGE_NAME="SRP_A"),this.client.makeUnauthenticatedRequest("initiateAuth",{AuthFlow:this.authenticationFlowType,ClientId:this.pool.getClientId(),AuthParameters:l,ClientMetadata:e.getValidationData()},function(c,l){if(c)return t.onFailure(c);var h=l.ChallengeParameters;n.username=h.USER_ID_FOR_SRP,r=new a.default(h.SRP_B,16),u=new a.default(h.SALT,16),n.getCachedDeviceKeyAndPassword();var f=i.getPasswordAuthenticationKey(n.username,e.getPassword(),r,u),d=s.getNowString(),p=o.util.crypto.hmac(f,o.util.buffer.concat([new o.util.Buffer(n.pool.getUserPoolId().split("_")[1],"utf8"),new o.util.Buffer(n.username,"utf8"),new o.util.Buffer(h.SECRET_BLOCK,"base64"),new o.util.Buffer(d,"utf8")]),"base64","sha256"),g={};g.USERNAME=n.username,g.PASSWORD_CLAIM_SECRET_BLOCK=h.SECRET_BLOCK,g.TIMESTAMP=d,g.PASSWORD_CLAIM_SIGNATURE=p,null!=n.deviceKey&&(g.DEVICE_KEY=n.deviceKey);var v=function e(t,i){return n.client.makeUnauthenticatedRequest("respondToAuthChallenge",t,function(s,o){return s&&"ResourceNotFoundException"===s.code&&s.message.toLowerCase().indexOf("device")!==-1?(g.DEVICE_KEY=null,n.deviceKey=null,n.randomPassword=null,n.deviceGroupKey=null,n.clearCachedDeviceKeyAndPassword(),e(t,i)):i(s,o)})};v({ChallengeName:"PASSWORD_VERIFIER",ClientId:n.pool.getClientId(),ChallengeResponses:g,Session:l.Session},function(e,s){if(e)return t.onFailure(e);var o=s.ChallengeName;if("NEW_PASSWORD_REQUIRED"===o){n.Session=s.Session;var r=null,a=null,u=[],c=i.getNewPasswordRequiredChallengeUserAttributePrefix();if(s.ChallengeParameters&&(r=JSON.parse(s.ChallengeParameters.userAttributes),a=JSON.parse(s.ChallengeParameters.requiredAttributes)),a)for(var l=0;l= 0) {\n\t var v = x * this[i++] + w[j] + c;\n\t c = Math.floor(v / 0x4000000);\n\t w[j++] = v & 0x3ffffff;\n\t }\n\t return c;\n\t}\n\t\n\tBigInteger.prototype.am = am1;\n\t\n\t// Bits per digit\n\tvar dbits = 26;\n\t\n\tBigInteger.prototype.DB = dbits;\n\tBigInteger.prototype.DM = (1 << dbits) - 1;\n\tBigInteger.prototype.DV = 1 << dbits;\n\t\n\tvar BI_FP = 52;\n\tBigInteger.prototype.FV = Math.pow(2, BI_FP);\n\tBigInteger.prototype.F1 = BI_FP - dbits;\n\tBigInteger.prototype.F2 = 2 * dbits - BI_FP;\n\t\n\t// Digit conversions\n\tvar BI_RM = \"0123456789abcdefghijklmnopqrstuvwxyz\";\n\tvar BI_RC = new Array();\n\tvar rr, vv;\n\trr = \"0\".charCodeAt(0);\n\tfor (vv = 0; vv <= 9; ++vv) {\n\t BI_RC[rr++] = vv;\n\t}rr = \"a\".charCodeAt(0);\n\tfor (vv = 10; vv < 36; ++vv) {\n\t BI_RC[rr++] = vv;\n\t}rr = \"A\".charCodeAt(0);\n\tfor (vv = 10; vv < 36; ++vv) {\n\t BI_RC[rr++] = vv;\n\t}function int2char(n) {\n\t return BI_RM.charAt(n);\n\t}\n\tfunction intAt(s, i) {\n\t var c = BI_RC[s.charCodeAt(i)];\n\t return c == null ? -1 : c;\n\t}\n\t\n\t// (protected) copy this to r\n\tfunction bnpCopyTo(r) {\n\t for (var i = this.t - 1; i >= 0; --i) {\n\t r[i] = this[i];\n\t }r.t = this.t;\n\t r.s = this.s;\n\t}\n\t\n\t// (protected) set from integer value x, -DV <= x < DV\n\tfunction bnpFromInt(x) {\n\t this.t = 1;\n\t this.s = x < 0 ? -1 : 0;\n\t if (x > 0) this[0] = x;else if (x < -1) this[0] = x + this.DV;else this.t = 0;\n\t}\n\t\n\t// return bigint initialized to value\n\tfunction nbv(i) {\n\t var r = nbi();\n\t\n\t r.fromInt(i);\n\t\n\t return r;\n\t}\n\t\n\t// (protected) set from string and radix\n\tfunction bnpFromString(s, b) {\n\t var k;\n\t if (b == 16) k = 4;else if (b == 8) k = 3;else if (b == 2) k = 1;else if (b == 32) k = 5;else if (b == 4) k = 2;else throw new Error(\"Only radix 2, 4, 8, 16, 32 are supported\");\n\t this.t = 0;\n\t this.s = 0;\n\t var i = s.length,\n\t mi = false,\n\t sh = 0;\n\t while (--i >= 0) {\n\t var x = intAt(s, i);\n\t if (x < 0) {\n\t if (s.charAt(i) == \"-\") mi = true;\n\t continue;\n\t }\n\t mi = false;\n\t if (sh == 0) this[this.t++] = x;else if (sh + k > this.DB) {\n\t this[this.t - 1] |= (x & (1 << this.DB - sh) - 1) << sh;\n\t this[this.t++] = x >> this.DB - sh;\n\t } else this[this.t - 1] |= x << sh;\n\t sh += k;\n\t if (sh >= this.DB) sh -= this.DB;\n\t }\n\t this.clamp();\n\t if (mi) BigInteger.ZERO.subTo(this, this);\n\t}\n\t\n\t// (protected) clamp off excess high words\n\tfunction bnpClamp() {\n\t var c = this.s & this.DM;\n\t while (this.t > 0 && this[this.t - 1] == c) {\n\t --this.t;\n\t }\n\t}\n\t\n\t// (public) return string representation in given radix\n\tfunction bnToString(b) {\n\t if (this.s < 0) return \"-\" + this.negate().toString();\n\t var k;\n\t if (b == 16) k = 4;else if (b == 8) k = 3;else if (b == 2) k = 1;else if (b == 32) k = 5;else if (b == 4) k = 2;else throw new Error(\"Only radix 2, 4, 8, 16, 32 are supported\");\n\t var km = (1 << k) - 1,\n\t d,\n\t m = false,\n\t r = \"\",\n\t i = this.t;\n\t var p = this.DB - i * this.DB % k;\n\t if (i-- > 0) {\n\t if (p < this.DB && (d = this[i] >> p) > 0) {\n\t m = true;\n\t r = int2char(d);\n\t }\n\t while (i >= 0) {\n\t if (p < k) {\n\t d = (this[i] & (1 << p) - 1) << k - p;\n\t d |= this[--i] >> (p += this.DB - k);\n\t } else {\n\t d = this[i] >> (p -= k) & km;\n\t if (p <= 0) {\n\t p += this.DB;\n\t --i;\n\t }\n\t }\n\t if (d > 0) m = true;\n\t if (m) r += int2char(d);\n\t }\n\t }\n\t return m ? r : \"0\";\n\t}\n\t\n\t// (public) -this\n\tfunction bnNegate() {\n\t var r = nbi();\n\t\n\t BigInteger.ZERO.subTo(this, r);\n\t\n\t return r;\n\t}\n\t\n\t// (public) |this|\n\tfunction bnAbs() {\n\t return this.s < 0 ? this.negate() : this;\n\t}\n\t\n\t// (public) return + if this > a, - if this < a, 0 if equal\n\tfunction bnCompareTo(a) {\n\t var r = this.s - a.s;\n\t if (r != 0) return r;\n\t var i = this.t;\n\t r = i - a.t;\n\t if (r != 0) return this.s < 0 ? -r : r;\n\t while (--i >= 0) {\n\t if ((r = this[i] - a[i]) != 0) return r;\n\t }return 0;\n\t}\n\t\n\t// returns bit length of the integer x\n\tfunction nbits(x) {\n\t var r = 1,\n\t t;\n\t if ((t = x >>> 16) != 0) {\n\t x = t;\n\t r += 16;\n\t }\n\t if ((t = x >> 8) != 0) {\n\t x = t;\n\t r += 8;\n\t }\n\t if ((t = x >> 4) != 0) {\n\t x = t;\n\t r += 4;\n\t }\n\t if ((t = x >> 2) != 0) {\n\t x = t;\n\t r += 2;\n\t }\n\t if ((t = x >> 1) != 0) {\n\t x = t;\n\t r += 1;\n\t }\n\t return r;\n\t}\n\t\n\t// (public) return the number of bits in \"this\"\n\tfunction bnBitLength() {\n\t if (this.t <= 0) return 0;\n\t return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.DM);\n\t}\n\t\n\t// (protected) r = this << n*DB\n\tfunction bnpDLShiftTo(n, r) {\n\t var i;\n\t for (i = this.t - 1; i >= 0; --i) {\n\t r[i + n] = this[i];\n\t }for (i = n - 1; i >= 0; --i) {\n\t r[i] = 0;\n\t }r.t = this.t + n;\n\t r.s = this.s;\n\t}\n\t\n\t// (protected) r = this >> n*DB\n\tfunction bnpDRShiftTo(n, r) {\n\t for (var i = n; i < this.t; ++i) {\n\t r[i - n] = this[i];\n\t }r.t = Math.max(this.t - n, 0);\n\t r.s = this.s;\n\t}\n\t\n\t// (protected) r = this << n\n\tfunction bnpLShiftTo(n, r) {\n\t var bs = n % this.DB;\n\t var cbs = this.DB - bs;\n\t var bm = (1 << cbs) - 1;\n\t var ds = Math.floor(n / this.DB),\n\t c = this.s << bs & this.DM,\n\t i;\n\t for (i = this.t - 1; i >= 0; --i) {\n\t r[i + ds + 1] = this[i] >> cbs | c;\n\t c = (this[i] & bm) << bs;\n\t }\n\t for (i = ds - 1; i >= 0; --i) {\n\t r[i] = 0;\n\t }r[ds] = c;\n\t r.t = this.t + ds + 1;\n\t r.s = this.s;\n\t r.clamp();\n\t}\n\t\n\t// (protected) r = this >> n\n\tfunction bnpRShiftTo(n, r) {\n\t r.s = this.s;\n\t var ds = Math.floor(n / this.DB);\n\t if (ds >= this.t) {\n\t r.t = 0;\n\t return;\n\t }\n\t var bs = n % this.DB;\n\t var cbs = this.DB - bs;\n\t var bm = (1 << bs) - 1;\n\t r[0] = this[ds] >> bs;\n\t for (var i = ds + 1; i < this.t; ++i) {\n\t r[i - ds - 1] |= (this[i] & bm) << cbs;\n\t r[i - ds] = this[i] >> bs;\n\t }\n\t if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;\n\t r.t = this.t - ds;\n\t r.clamp();\n\t}\n\t\n\t// (protected) r = this - a\n\tfunction bnpSubTo(a, r) {\n\t var i = 0,\n\t c = 0,\n\t m = Math.min(a.t, this.t);\n\t while (i < m) {\n\t c += this[i] - a[i];\n\t r[i++] = c & this.DM;\n\t c >>= this.DB;\n\t }\n\t if (a.t < this.t) {\n\t c -= a.s;\n\t while (i < this.t) {\n\t c += this[i];\n\t r[i++] = c & this.DM;\n\t c >>= this.DB;\n\t }\n\t c += this.s;\n\t } else {\n\t c += this.s;\n\t while (i < a.t) {\n\t c -= a[i];\n\t r[i++] = c & this.DM;\n\t c >>= this.DB;\n\t }\n\t c -= a.s;\n\t }\n\t r.s = c < 0 ? -1 : 0;\n\t if (c < -1) r[i++] = this.DV + c;else if (c > 0) r[i++] = c;\n\t r.t = i;\n\t r.clamp();\n\t}\n\t\n\t// (protected) r = this * a, r != this,a (HAC 14.12)\n\t// \"this\" should be the larger one if appropriate.\n\tfunction bnpMultiplyTo(a, r) {\n\t var x = this.abs(),\n\t y = a.abs();\n\t var i = x.t;\n\t r.t = i + y.t;\n\t while (--i >= 0) {\n\t r[i] = 0;\n\t }for (i = 0; i < y.t; ++i) {\n\t r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);\n\t }r.s = 0;\n\t r.clamp();\n\t if (this.s != a.s) BigInteger.ZERO.subTo(r, r);\n\t}\n\t\n\t// (protected) r = this^2, r != this (HAC 14.16)\n\tfunction bnpSquareTo(r) {\n\t var x = this.abs();\n\t var i = r.t = 2 * x.t;\n\t while (--i >= 0) {\n\t r[i] = 0;\n\t }for (i = 0; i < x.t - 1; ++i) {\n\t var c = x.am(i, x[i], r, 2 * i, 0, 1);\n\t if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {\n\t r[i + x.t] -= x.DV;\n\t r[i + x.t + 1] = 1;\n\t }\n\t }\n\t if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);\n\t r.s = 0;\n\t r.clamp();\n\t}\n\t\n\t// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)\n\t// r != q, this != m. q or r may be null.\n\tfunction bnpDivRemTo(m, q, r) {\n\t var pm = m.abs();\n\t if (pm.t <= 0) return;\n\t var pt = this.abs();\n\t if (pt.t < pm.t) {\n\t if (q != null) q.fromInt(0);\n\t if (r != null) this.copyTo(r);\n\t return;\n\t }\n\t if (r == null) r = nbi();\n\t var y = nbi(),\n\t ts = this.s,\n\t ms = m.s;\n\t var nsh = this.DB - nbits(pm[pm.t - 1]);\n\t // normalize modulus\n\t if (nsh > 0) {\n\t pm.lShiftTo(nsh, y);\n\t pt.lShiftTo(nsh, r);\n\t } else {\n\t pm.copyTo(y);\n\t pt.copyTo(r);\n\t }\n\t var ys = y.t;\n\t var y0 = y[ys - 1];\n\t if (y0 == 0) return;\n\t var yt = y0 * (1 << this.F1) + (ys > 1 ? y[ys - 2] >> this.F2 : 0);\n\t var d1 = this.FV / yt,\n\t d2 = (1 << this.F1) / yt,\n\t e = 1 << this.F2;\n\t var i = r.t,\n\t j = i - ys,\n\t t = q == null ? nbi() : q;\n\t y.dlShiftTo(j, t);\n\t if (r.compareTo(t) >= 0) {\n\t r[r.t++] = 1;\n\t r.subTo(t, r);\n\t }\n\t BigInteger.ONE.dlShiftTo(ys, t);\n\t t.subTo(y, y);\n\t // \"negative\" y so we can replace sub with am later\n\t while (y.t < ys) {\n\t y[y.t++] = 0;\n\t }while (--j >= 0) {\n\t // Estimate quotient digit\n\t var qd = r[--i] == y0 ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);\n\t if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) {\n\t // Try it out\n\t y.dlShiftTo(j, t);\n\t r.subTo(t, r);\n\t while (r[i] < --qd) {\n\t r.subTo(t, r);\n\t }\n\t }\n\t }\n\t if (q != null) {\n\t r.drShiftTo(ys, q);\n\t if (ts != ms) BigInteger.ZERO.subTo(q, q);\n\t }\n\t r.t = ys;\n\t r.clamp();\n\t if (nsh > 0) r.rShiftTo(nsh, r);\n\t // Denormalize remainder\n\t if (ts < 0) BigInteger.ZERO.subTo(r, r);\n\t}\n\t\n\t// (public) this mod a\n\tfunction bnMod(a) {\n\t var r = nbi();\n\t this.abs().divRemTo(a, null, r);\n\t if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);\n\t return r;\n\t}\n\t\n\t// (protected) return \"-1/this % 2^DB\"; useful for Mont. reduction\n\t// justification:\n\t// xy == 1 (mod m)\n\t// xy = 1+km\n\t// xy(2-xy) = (1+km)(1-km)\n\t// x[y(2-xy)] = 1-k^2m^2\n\t// x[y(2-xy)] == 1 (mod m^2)\n\t// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2\n\t// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.\n\t// JS multiply \"overflows\" differently from C/C++, so care is needed here.\n\tfunction bnpInvDigit() {\n\t if (this.t < 1) return 0;\n\t var x = this[0];\n\t if ((x & 1) == 0) return 0;\n\t var y = x & 3;\n\t // y == 1/x mod 2^2\n\t y = y * (2 - (x & 0xf) * y) & 0xf;\n\t // y == 1/x mod 2^4\n\t y = y * (2 - (x & 0xff) * y) & 0xff;\n\t // y == 1/x mod 2^8\n\t y = y * (2 - ((x & 0xffff) * y & 0xffff)) & 0xffff;\n\t // y == 1/x mod 2^16\n\t // last step - calculate inverse mod DV directly;\n\t // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints\n\t y = y * (2 - x * y % this.DV) % this.DV;\n\t // y == 1/x mod 2^dbits\n\t // we really want the negative inverse, and -DV < y < DV\n\t return y > 0 ? this.DV - y : -y;\n\t}\n\t\n\tfunction bnEquals(a) {\n\t return this.compareTo(a) == 0;\n\t}\n\t\n\t// (protected) r = this + a\n\tfunction bnpAddTo(a, r) {\n\t var i = 0,\n\t c = 0,\n\t m = Math.min(a.t, this.t);\n\t while (i < m) {\n\t c += this[i] + a[i];\n\t r[i++] = c & this.DM;\n\t c >>= this.DB;\n\t }\n\t if (a.t < this.t) {\n\t c += a.s;\n\t while (i < this.t) {\n\t c += this[i];\n\t r[i++] = c & this.DM;\n\t c >>= this.DB;\n\t }\n\t c += this.s;\n\t } else {\n\t c += this.s;\n\t while (i < a.t) {\n\t c += a[i];\n\t r[i++] = c & this.DM;\n\t c >>= this.DB;\n\t }\n\t c += a.s;\n\t }\n\t r.s = c < 0 ? -1 : 0;\n\t if (c > 0) r[i++] = c;else if (c < -1) r[i++] = this.DV + c;\n\t r.t = i;\n\t r.clamp();\n\t}\n\t\n\t// (public) this + a\n\tfunction bnAdd(a) {\n\t var r = nbi();\n\t\n\t this.addTo(a, r);\n\t\n\t return r;\n\t}\n\t\n\t// (public) this - a\n\tfunction bnSubtract(a) {\n\t var r = nbi();\n\t\n\t this.subTo(a, r);\n\t\n\t return r;\n\t}\n\t\n\t// (public) this * a\n\tfunction bnMultiply(a) {\n\t var r = nbi();\n\t\n\t this.multiplyTo(a, r);\n\t\n\t return r;\n\t}\n\t\n\t// (public) this / a\n\tfunction bnDivide(a) {\n\t var r = nbi();\n\t\n\t this.divRemTo(a, r, null);\n\t\n\t return r;\n\t}\n\t\n\t// Montgomery reduction\n\tfunction Montgomery(m) {\n\t this.m = m;\n\t this.mp = m.invDigit();\n\t this.mpl = this.mp & 0x7fff;\n\t this.mph = this.mp >> 15;\n\t this.um = (1 << m.DB - 15) - 1;\n\t this.mt2 = 2 * m.t;\n\t}\n\t\n\t// xR mod m\n\tfunction montConvert(x) {\n\t var r = nbi();\n\t x.abs().dlShiftTo(this.m.t, r);\n\t r.divRemTo(this.m, null, r);\n\t if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);\n\t return r;\n\t}\n\t\n\t// x/R mod m\n\tfunction montRevert(x) {\n\t var r = nbi();\n\t x.copyTo(r);\n\t this.reduce(r);\n\t return r;\n\t}\n\t\n\t// x = x/R mod m (HAC 14.32)\n\tfunction montReduce(x) {\n\t while (x.t <= this.mt2) {\n\t // pad x so am has enough room later\n\t x[x.t++] = 0;\n\t }for (var i = 0; i < this.m.t; ++i) {\n\t // faster way of calculating u0 = x[i]*mp mod DV\n\t var j = x[i] & 0x7fff;\n\t var u0 = j * this.mpl + ((j * this.mph + (x[i] >> 15) * this.mpl & this.um) << 15) & x.DM;\n\t // use am to combine the multiply-shift-add into one call\n\t j = i + this.m.t;\n\t x[j] += this.m.am(0, u0, x, i, 0, this.m.t);\n\t // propagate carry\n\t while (x[j] >= x.DV) {\n\t x[j] -= x.DV;\n\t x[++j]++;\n\t }\n\t }\n\t x.clamp();\n\t x.drShiftTo(this.m.t, x);\n\t if (x.compareTo(this.m) >= 0) x.subTo(this.m, x);\n\t}\n\t\n\t// r = \"x^2/R mod m\"; x != r\n\tfunction montSqrTo(x, r) {\n\t x.squareTo(r);\n\t\n\t this.reduce(r);\n\t}\n\t\n\t// r = \"xy/R mod m\"; x,y != r\n\tfunction montMulTo(x, y, r) {\n\t x.multiplyTo(y, r);\n\t\n\t this.reduce(r);\n\t}\n\t\n\tMontgomery.prototype.convert = montConvert;\n\tMontgomery.prototype.revert = montRevert;\n\tMontgomery.prototype.reduce = montReduce;\n\tMontgomery.prototype.mulTo = montMulTo;\n\tMontgomery.prototype.sqrTo = montSqrTo;\n\t\n\t// (public) this^e % m (HAC 14.85)\n\tfunction bnModPow(e, m) {\n\t var i = e.bitLength(),\n\t k,\n\t r = nbv(1),\n\t z = new Montgomery(m);\n\t if (i <= 0) return r;else if (i < 18) k = 1;else if (i < 48) k = 3;else if (i < 144) k = 4;else if (i < 768) k = 5;else k = 6;\n\t\n\t // precomputation\n\t var g = new Array(),\n\t n = 3,\n\t k1 = k - 1,\n\t km = (1 << k) - 1;\n\t g[1] = z.convert(this);\n\t if (k > 1) {\n\t var g2 = nbi();\n\t z.sqrTo(g[1], g2);\n\t while (n <= km) {\n\t g[n] = nbi();\n\t z.mulTo(g2, g[n - 2], g[n]);\n\t n += 2;\n\t }\n\t }\n\t\n\t var j = e.t - 1,\n\t w,\n\t is1 = true,\n\t r2 = nbi(),\n\t t;\n\t i = nbits(e[j]) - 1;\n\t while (j >= 0) {\n\t if (i >= k1) w = e[j] >> i - k1 & km;else {\n\t w = (e[j] & (1 << i + 1) - 1) << k1 - i;\n\t if (j > 0) w |= e[j - 1] >> this.DB + i - k1;\n\t }\n\t\n\t n = k;\n\t while ((w & 1) == 0) {\n\t w >>= 1;\n\t --n;\n\t }\n\t if ((i -= n) < 0) {\n\t i += this.DB;\n\t --j;\n\t }\n\t if (is1) {\n\t // ret == 1, don't bother squaring or multiplying it\n\t g[w].copyTo(r);\n\t is1 = false;\n\t } else {\n\t while (n > 1) {\n\t z.sqrTo(r, r2);\n\t z.sqrTo(r2, r);\n\t n -= 2;\n\t }\n\t if (n > 0) z.sqrTo(r, r2);else {\n\t t = r;\n\t r = r2;\n\t r2 = t;\n\t }\n\t z.mulTo(r2, g[w], r);\n\t }\n\t\n\t while (j >= 0 && (e[j] & 1 << i) == 0) {\n\t z.sqrTo(r, r2);\n\t t = r;\n\t r = r2;\n\t r2 = t;\n\t if (--i < 0) {\n\t i = this.DB - 1;\n\t --j;\n\t }\n\t }\n\t }\n\t return z.revert(r);\n\t}\n\t\n\t// protected\n\tBigInteger.prototype.copyTo = bnpCopyTo;\n\tBigInteger.prototype.fromInt = bnpFromInt;\n\tBigInteger.prototype.fromString = bnpFromString;\n\tBigInteger.prototype.clamp = bnpClamp;\n\tBigInteger.prototype.dlShiftTo = bnpDLShiftTo;\n\tBigInteger.prototype.drShiftTo = bnpDRShiftTo;\n\tBigInteger.prototype.lShiftTo = bnpLShiftTo;\n\tBigInteger.prototype.rShiftTo = bnpRShiftTo;\n\tBigInteger.prototype.subTo = bnpSubTo;\n\tBigInteger.prototype.multiplyTo = bnpMultiplyTo;\n\tBigInteger.prototype.squareTo = bnpSquareTo;\n\tBigInteger.prototype.divRemTo = bnpDivRemTo;\n\tBigInteger.prototype.invDigit = bnpInvDigit;\n\tBigInteger.prototype.addTo = bnpAddTo;\n\t\n\t// public\n\tBigInteger.prototype.toString = bnToString;\n\tBigInteger.prototype.negate = bnNegate;\n\tBigInteger.prototype.abs = bnAbs;\n\tBigInteger.prototype.compareTo = bnCompareTo;\n\tBigInteger.prototype.bitLength = bnBitLength;\n\tBigInteger.prototype.mod = bnMod;\n\tBigInteger.prototype.equals = bnEquals;\n\tBigInteger.prototype.add = bnAdd;\n\tBigInteger.prototype.subtract = bnSubtract;\n\tBigInteger.prototype.multiply = bnMultiply;\n\tBigInteger.prototype.divide = bnDivide;\n\tBigInteger.prototype.modPow = bnModPow;\n\t\n\t// \"constants\"\n\tBigInteger.ZERO = nbv(0);\n\tBigInteger.ONE = nbv(1);\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tvar _global = __webpack_require__(1);\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } } /*\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar CognitoAccessToken = function () {\n\t /**\n\t * Constructs a new CognitoAccessToken object\n\t * @param {string=} AccessToken The JWT access token.\n\t */\n\t function CognitoAccessToken() {\n\t var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n\t AccessToken = _ref.AccessToken;\n\t\n\t _classCallCheck(this, CognitoAccessToken);\n\t\n\t // Assign object\n\t this.jwtToken = AccessToken || '';\n\t }\n\t\n\t /**\n\t * @returns {string} the record's token.\n\t */\n\t\n\t\n\t CognitoAccessToken.prototype.getJwtToken = function getJwtToken() {\n\t return this.jwtToken;\n\t };\n\t\n\t /**\n\t * @returns {int} the token's expiration (exp member).\n\t */\n\t\n\t\n\t CognitoAccessToken.prototype.getExpiration = function getExpiration() {\n\t var payload = this.jwtToken.split('.')[1];\n\t var expiration = JSON.parse(_global.util.base64.decode(payload).toString('utf8'));\n\t return expiration.exp;\n\t };\n\t\n\t return CognitoAccessToken;\n\t}();\n\t\n\texports.default = CognitoAccessToken;\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tvar _global = __webpack_require__(1);\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } } /*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar CognitoIdToken = function () {\n\t /**\n\t * Constructs a new CognitoIdToken object\n\t * @param {string=} IdToken The JWT Id token\n\t */\n\t function CognitoIdToken() {\n\t var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n\t IdToken = _ref.IdToken;\n\t\n\t _classCallCheck(this, CognitoIdToken);\n\t\n\t // Assign object\n\t this.jwtToken = IdToken || '';\n\t }\n\t\n\t /**\n\t * @returns {string} the record's token.\n\t */\n\t\n\t\n\t CognitoIdToken.prototype.getJwtToken = function getJwtToken() {\n\t return this.jwtToken;\n\t };\n\t\n\t /**\n\t * @returns {int} the token's expiration (exp member).\n\t */\n\t\n\t\n\t CognitoIdToken.prototype.getExpiration = function getExpiration() {\n\t var payload = this.jwtToken.split('.')[1];\n\t var expiration = JSON.parse(_global.util.base64.decode(payload).toString('utf8'));\n\t return expiration.exp;\n\t };\n\t\n\t return CognitoIdToken;\n\t}();\n\t\n\texports.default = CognitoIdToken;\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar CognitoRefreshToken = function () {\n\t /**\n\t * Constructs a new CognitoRefreshToken object\n\t * @param {string=} RefreshToken The JWT refresh token.\n\t */\n\t function CognitoRefreshToken() {\n\t var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n\t RefreshToken = _ref.RefreshToken;\n\t\n\t _classCallCheck(this, CognitoRefreshToken);\n\t\n\t // Assign object\n\t this.token = RefreshToken || '';\n\t }\n\t\n\t /**\n\t * @returns {string} the record's token.\n\t */\n\t\n\t\n\t CognitoRefreshToken.prototype.getToken = function getToken() {\n\t return this.token;\n\t };\n\t\n\t return CognitoRefreshToken;\n\t}();\n\t\n\texports.default = CognitoRefreshToken;\n\n/***/ }),\n/* 7 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tvar _global = __webpack_require__(1);\n\t\n\tvar _BigInteger = __webpack_require__(3);\n\t\n\tvar _BigInteger2 = _interopRequireDefault(_BigInteger);\n\t\n\tvar _AuthenticationHelper = __webpack_require__(2);\n\t\n\tvar _AuthenticationHelper2 = _interopRequireDefault(_AuthenticationHelper);\n\t\n\tvar _CognitoAccessToken = __webpack_require__(4);\n\t\n\tvar _CognitoAccessToken2 = _interopRequireDefault(_CognitoAccessToken);\n\t\n\tvar _CognitoIdToken = __webpack_require__(5);\n\t\n\tvar _CognitoIdToken2 = _interopRequireDefault(_CognitoIdToken);\n\t\n\tvar _CognitoRefreshToken = __webpack_require__(6);\n\t\n\tvar _CognitoRefreshToken2 = _interopRequireDefault(_CognitoRefreshToken);\n\t\n\tvar _CognitoUserSession = __webpack_require__(9);\n\t\n\tvar _CognitoUserSession2 = _interopRequireDefault(_CognitoUserSession);\n\t\n\tvar _DateHelper = __webpack_require__(10);\n\t\n\tvar _DateHelper2 = _interopRequireDefault(_DateHelper);\n\t\n\tvar _CognitoUserAttribute = __webpack_require__(8);\n\t\n\tvar _CognitoUserAttribute2 = _interopRequireDefault(_CognitoUserAttribute);\n\t\n\tvar _StorageHelper = __webpack_require__(11);\n\t\n\tvar _StorageHelper2 = _interopRequireDefault(_StorageHelper);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } } /*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/**\n\t * @callback nodeCallback\n\t * @template T result\n\t * @param {*} err The operation failure reason, or null.\n\t * @param {T} result The operation result.\n\t */\n\t\n\t/**\n\t * @callback onFailure\n\t * @param {*} err Failure reason.\n\t */\n\t\n\t/**\n\t * @callback onSuccess\n\t * @template T result\n\t * @param {T} result The operation result.\n\t */\n\t\n\t/**\n\t * @callback mfaRequired\n\t * @param {*} details MFA challenge details.\n\t */\n\t\n\t/**\n\t * @callback customChallenge\n\t * @param {*} details Custom challenge details.\n\t */\n\t\n\t/**\n\t * @callback inputVerificationCode\n\t * @param {*} data Server response.\n\t */\n\t\n\t/**\n\t * @callback authSuccess\n\t * @param {CognitoUserSession} session The new session.\n\t * @param {bool=} userConfirmationNecessary User must be confirmed.\n\t */\n\t\n\t/** @class */\n\tvar CognitoUser = function () {\n\t /**\n\t * Constructs a new CognitoUser object\n\t * @param {object} data Creation options\n\t * @param {string} data.Username The user's username.\n\t * @param {CognitoUserPool} data.Pool Pool containing the user.\n\t * @param {object} data.Storage Optional storage object.\n\t */\n\t function CognitoUser(data) {\n\t _classCallCheck(this, CognitoUser);\n\t\n\t if (data == null || data.Username == null || data.Pool == null) {\n\t throw new Error('Username and pool information are required.');\n\t }\n\t\n\t this.username = data.Username || '';\n\t this.pool = data.Pool;\n\t this.Session = null;\n\t\n\t this.client = data.Pool.client;\n\t\n\t this.signInUserSession = null;\n\t this.authenticationFlowType = 'USER_SRP_AUTH';\n\t\n\t this.storage = data.Storage || new _StorageHelper2.default().getStorage();\n\t }\n\t\n\t /**\n\t * @returns {CognitoUserSession} the current session for this user\n\t */\n\t\n\t\n\t CognitoUser.prototype.getSignInUserSession = function getSignInUserSession() {\n\t return this.signInUserSession;\n\t };\n\t\n\t /**\n\t * @returns {string} the user's username\n\t */\n\t\n\t\n\t CognitoUser.prototype.getUsername = function getUsername() {\n\t return this.username;\n\t };\n\t\n\t /**\n\t * @returns {String} the authentication flow type\n\t */\n\t\n\t\n\t CognitoUser.prototype.getAuthenticationFlowType = function getAuthenticationFlowType() {\n\t return this.authenticationFlowType;\n\t };\n\t\n\t /**\n\t * sets authentication flow type\n\t * @param {string} authenticationFlowType New value.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.setAuthenticationFlowType = function setAuthenticationFlowType(authenticationFlowType) {\n\t this.authenticationFlowType = authenticationFlowType;\n\t };\n\t\n\t /**\n\t * This is used for authenticating the user. it calls the AuthenticationHelper for SRP related\n\t * stuff\n\t * @param {AuthenticationDetails} authDetails Contains the authentication data\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {newPasswordRequired} callback.newPasswordRequired new\n\t * password and any required attributes are required to continue\n\t * @param {mfaRequired} callback.mfaRequired MFA code\n\t * required to continue.\n\t * @param {customChallenge} callback.customChallenge Custom challenge\n\t * response required to continue.\n\t * @param {authSuccess} callback.onSuccess Called on success with the new session.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.authenticateUser = function authenticateUser(authDetails, callback) {\n\t var _this = this;\n\t\n\t var authenticationHelper = new _AuthenticationHelper2.default(this.pool.getUserPoolId().split('_')[1]);\n\t var dateHelper = new _DateHelper2.default();\n\t\n\t var serverBValue = void 0;\n\t var salt = void 0;\n\t var authParameters = {};\n\t\n\t if (this.deviceKey != null) {\n\t authParameters.DEVICE_KEY = this.deviceKey;\n\t }\n\t\n\t authParameters.USERNAME = this.username;\n\t authParameters.SRP_A = authenticationHelper.getLargeAValue().toString(16);\n\t\n\t if (this.authenticationFlowType === 'CUSTOM_AUTH') {\n\t authParameters.CHALLENGE_NAME = 'SRP_A';\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('initiateAuth', {\n\t AuthFlow: this.authenticationFlowType,\n\t ClientId: this.pool.getClientId(),\n\t AuthParameters: authParameters,\n\t ClientMetadata: authDetails.getValidationData()\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t\n\t var challengeParameters = data.ChallengeParameters;\n\t\n\t _this.username = challengeParameters.USER_ID_FOR_SRP;\n\t serverBValue = new _BigInteger2.default(challengeParameters.SRP_B, 16);\n\t salt = new _BigInteger2.default(challengeParameters.SALT, 16);\n\t _this.getCachedDeviceKeyAndPassword();\n\t\n\t var hkdf = authenticationHelper.getPasswordAuthenticationKey(_this.username, authDetails.getPassword(), serverBValue, salt);\n\t\n\t var dateNow = dateHelper.getNowString();\n\t\n\t var signatureString = _global.util.crypto.hmac(hkdf, _global.util.buffer.concat([new _global.util.Buffer(_this.pool.getUserPoolId().split('_')[1], 'utf8'), new _global.util.Buffer(_this.username, 'utf8'), new _global.util.Buffer(challengeParameters.SECRET_BLOCK, 'base64'), new _global.util.Buffer(dateNow, 'utf8')]), 'base64', 'sha256');\n\t\n\t var challengeResponses = {};\n\t\n\t challengeResponses.USERNAME = _this.username;\n\t challengeResponses.PASSWORD_CLAIM_SECRET_BLOCK = challengeParameters.SECRET_BLOCK;\n\t challengeResponses.TIMESTAMP = dateNow;\n\t challengeResponses.PASSWORD_CLAIM_SIGNATURE = signatureString;\n\t\n\t if (_this.deviceKey != null) {\n\t challengeResponses.DEVICE_KEY = _this.deviceKey;\n\t }\n\t\n\t var respondToAuthChallenge = function respondToAuthChallenge(challenge, challengeCallback) {\n\t return _this.client.makeUnauthenticatedRequest('respondToAuthChallenge', challenge, function (errChallenge, dataChallenge) {\n\t if (errChallenge && errChallenge.code === 'ResourceNotFoundException' && errChallenge.message.toLowerCase().indexOf('device') !== -1) {\n\t challengeResponses.DEVICE_KEY = null;\n\t _this.deviceKey = null;\n\t _this.randomPassword = null;\n\t _this.deviceGroupKey = null;\n\t _this.clearCachedDeviceKeyAndPassword();\n\t return respondToAuthChallenge(challenge, challengeCallback);\n\t }\n\t return challengeCallback(errChallenge, dataChallenge);\n\t });\n\t };\n\t\n\t respondToAuthChallenge({\n\t ChallengeName: 'PASSWORD_VERIFIER',\n\t ClientId: _this.pool.getClientId(),\n\t ChallengeResponses: challengeResponses,\n\t Session: data.Session\n\t }, function (errAuthenticate, dataAuthenticate) {\n\t if (errAuthenticate) {\n\t return callback.onFailure(errAuthenticate);\n\t }\n\t\n\t var challengeName = dataAuthenticate.ChallengeName;\n\t if (challengeName === 'NEW_PASSWORD_REQUIRED') {\n\t _this.Session = dataAuthenticate.Session;\n\t var userAttributes = null;\n\t var rawRequiredAttributes = null;\n\t var requiredAttributes = [];\n\t var userAttributesPrefix = authenticationHelper.getNewPasswordRequiredChallengeUserAttributePrefix();\n\t\n\t if (dataAuthenticate.ChallengeParameters) {\n\t userAttributes = JSON.parse(dataAuthenticate.ChallengeParameters.userAttributes);\n\t rawRequiredAttributes = JSON.parse(dataAuthenticate.ChallengeParameters.requiredAttributes);\n\t }\n\t\n\t if (rawRequiredAttributes) {\n\t for (var i = 0; i < rawRequiredAttributes.length; i++) {\n\t requiredAttributes[i] = rawRequiredAttributes[i].substr(userAttributesPrefix.length);\n\t }\n\t }\n\t return callback.newPasswordRequired(userAttributes, requiredAttributes);\n\t }\n\t return _this.authenticateUserInternal(dataAuthenticate, authenticationHelper, callback);\n\t });\n\t return undefined;\n\t });\n\t };\n\t\n\t /**\n\t * PRIVATE ONLY: This is an internal only method and should not\n\t * be directly called by the consumers.\n\t * @param {object} dataAuthenticate authentication data\n\t * @param {object} authenticationHelper helper created\n\t * @param {callback} callback passed on from caller\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.authenticateUserInternal = function authenticateUserInternal(dataAuthenticate, authenticationHelper, callback) {\n\t var _this2 = this;\n\t\n\t var challengeName = dataAuthenticate.ChallengeName;\n\t var challengeParameters = dataAuthenticate.ChallengeParameters;\n\t\n\t if (challengeName === 'SMS_MFA') {\n\t this.Session = dataAuthenticate.Session;\n\t return callback.mfaRequired(challengeName, challengeParameters);\n\t }\n\t\n\t if (challengeName === 'CUSTOM_CHALLENGE') {\n\t this.Session = dataAuthenticate.Session;\n\t return callback.customChallenge(challengeParameters);\n\t }\n\t\n\t if (challengeName === 'DEVICE_SRP_AUTH') {\n\t this.getDeviceResponse(callback);\n\t return undefined;\n\t }\n\t\n\t this.signInUserSession = this.getCognitoUserSession(dataAuthenticate.AuthenticationResult);\n\t this.cacheTokens();\n\t\n\t var newDeviceMetadata = dataAuthenticate.AuthenticationResult.NewDeviceMetadata;\n\t if (newDeviceMetadata == null) {\n\t return callback.onSuccess(this.signInUserSession);\n\t }\n\t\n\t authenticationHelper.generateHashDevice(dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey, dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey);\n\t\n\t var deviceSecretVerifierConfig = {\n\t Salt: new _global.util.Buffer(authenticationHelper.getSaltDevices(), 'hex').toString('base64'),\n\t PasswordVerifier: new _global.util.Buffer(authenticationHelper.getVerifierDevices(), 'hex').toString('base64')\n\t };\n\t\n\t this.verifierDevices = deviceSecretVerifierConfig.PasswordVerifier;\n\t this.deviceGroupKey = newDeviceMetadata.DeviceGroupKey;\n\t this.randomPassword = authenticationHelper.getRandomPassword();\n\t\n\t this.client.makeUnauthenticatedRequest('confirmDevice', {\n\t DeviceKey: newDeviceMetadata.DeviceKey,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t DeviceSecretVerifierConfig: deviceSecretVerifierConfig,\n\t DeviceName: navigator.userAgent\n\t }, function (errConfirm, dataConfirm) {\n\t if (errConfirm) {\n\t return callback.onFailure(errConfirm);\n\t }\n\t\n\t _this2.deviceKey = dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey;\n\t _this2.cacheDeviceKeyAndPassword();\n\t if (dataConfirm.UserConfirmationNecessary === true) {\n\t return callback.onSuccess(_this2.signInUserSession, dataConfirm.UserConfirmationNecessary);\n\t }\n\t return callback.onSuccess(_this2.signInUserSession);\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This method is user to complete the NEW_PASSWORD_REQUIRED challenge.\n\t * Pass the new password with any new user attributes to be updated.\n\t * User attribute keys must be of format userAttributes..\n\t * @param {string} newPassword new password for this user\n\t * @param {object} requiredAttributeData map with values for all required attributes\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {mfaRequired} callback.mfaRequired MFA code required to continue.\n\t * @param {customChallenge} callback.customChallenge Custom challenge\n\t * response required to continue.\n\t * @param {authSuccess} callback.onSuccess Called on success with the new session.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.completeNewPasswordChallenge = function completeNewPasswordChallenge(newPassword, requiredAttributeData, callback) {\n\t var _this3 = this;\n\t\n\t if (!newPassword) {\n\t return callback.onFailure(new Error('New password is required.'));\n\t }\n\t var authenticationHelper = new _AuthenticationHelper2.default(this.pool.getUserPoolId().split('_')[1]);\n\t var userAttributesPrefix = authenticationHelper.getNewPasswordRequiredChallengeUserAttributePrefix();\n\t\n\t var finalUserAttributes = {};\n\t if (requiredAttributeData) {\n\t Object.keys(requiredAttributeData).forEach(function (key) {\n\t finalUserAttributes[userAttributesPrefix + key] = requiredAttributeData[key];\n\t });\n\t }\n\t\n\t finalUserAttributes.NEW_PASSWORD = newPassword;\n\t finalUserAttributes.USERNAME = this.username;\n\t this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n\t ChallengeName: 'NEW_PASSWORD_REQUIRED',\n\t ClientId: this.pool.getClientId(),\n\t ChallengeResponses: finalUserAttributes,\n\t Session: this.Session\n\t }, function (errAuthenticate, dataAuthenticate) {\n\t if (errAuthenticate) {\n\t return callback.onFailure(errAuthenticate);\n\t }\n\t return _this3.authenticateUserInternal(dataAuthenticate, authenticationHelper, callback);\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to get a session using device authentication. It is called at the end of user\n\t * authentication\n\t *\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {authSuccess} callback.onSuccess Called on success with the new session.\n\t * @returns {void}\n\t * @private\n\t */\n\t\n\t\n\t CognitoUser.prototype.getDeviceResponse = function getDeviceResponse(callback) {\n\t var _this4 = this;\n\t\n\t var authenticationHelper = new _AuthenticationHelper2.default(this.deviceGroupKey);\n\t var dateHelper = new _DateHelper2.default();\n\t\n\t var authParameters = {};\n\t\n\t authParameters.USERNAME = this.username;\n\t authParameters.DEVICE_KEY = this.deviceKey;\n\t authParameters.SRP_A = authenticationHelper.getLargeAValue().toString(16);\n\t\n\t this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n\t ChallengeName: 'DEVICE_SRP_AUTH',\n\t ClientId: this.pool.getClientId(),\n\t ChallengeResponses: authParameters\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t\n\t var challengeParameters = data.ChallengeParameters;\n\t\n\t var serverBValue = new _BigInteger2.default(challengeParameters.SRP_B, 16);\n\t var salt = new _BigInteger2.default(challengeParameters.SALT, 16);\n\t\n\t var hkdf = authenticationHelper.getPasswordAuthenticationKey(_this4.deviceKey, _this4.randomPassword, serverBValue, salt);\n\t\n\t var dateNow = dateHelper.getNowString();\n\t\n\t var signatureString = _global.util.crypto.hmac(hkdf, _global.util.buffer.concat([new _global.util.Buffer(_this4.deviceGroupKey, 'utf8'), new _global.util.Buffer(_this4.deviceKey, 'utf8'), new _global.util.Buffer(challengeParameters.SECRET_BLOCK, 'base64'), new _global.util.Buffer(dateNow, 'utf8')]), 'base64', 'sha256');\n\t\n\t var challengeResponses = {};\n\t\n\t challengeResponses.USERNAME = _this4.username;\n\t challengeResponses.PASSWORD_CLAIM_SECRET_BLOCK = challengeParameters.SECRET_BLOCK;\n\t challengeResponses.TIMESTAMP = dateNow;\n\t challengeResponses.PASSWORD_CLAIM_SIGNATURE = signatureString;\n\t challengeResponses.DEVICE_KEY = _this4.deviceKey;\n\t\n\t _this4.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n\t ChallengeName: 'DEVICE_PASSWORD_VERIFIER',\n\t ClientId: _this4.pool.getClientId(),\n\t ChallengeResponses: challengeResponses,\n\t Session: data.Session\n\t }, function (errAuthenticate, dataAuthenticate) {\n\t if (errAuthenticate) {\n\t return callback.onFailure(errAuthenticate);\n\t }\n\t\n\t _this4.signInUserSession = _this4.getCognitoUserSession(dataAuthenticate.AuthenticationResult);\n\t _this4.cacheTokens();\n\t\n\t return callback.onSuccess(_this4.signInUserSession);\n\t });\n\t return undefined;\n\t });\n\t };\n\t\n\t /**\n\t * This is used for a certain user to confirm the registration by using a confirmation code\n\t * @param {string} confirmationCode Code entered by user.\n\t * @param {bool} forceAliasCreation Allow migrating from an existing email / phone number.\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.confirmRegistration = function confirmRegistration(confirmationCode, forceAliasCreation, callback) {\n\t this.client.makeUnauthenticatedRequest('confirmSignUp', {\n\t ClientId: this.pool.getClientId(),\n\t ConfirmationCode: confirmationCode,\n\t Username: this.username,\n\t ForceAliasCreation: forceAliasCreation\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t return callback(null, 'SUCCESS');\n\t });\n\t };\n\t\n\t /**\n\t * This is used by the user once he has the responses to a custom challenge\n\t * @param {string} answerChallenge The custom challange answer.\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {customChallenge} callback.customChallenge\n\t * Custom challenge response required to continue.\n\t * @param {authSuccess} callback.onSuccess Called on success with the new session.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.sendCustomChallengeAnswer = function sendCustomChallengeAnswer(answerChallenge, callback) {\n\t var _this5 = this;\n\t\n\t var challengeResponses = {};\n\t challengeResponses.USERNAME = this.username;\n\t challengeResponses.ANSWER = answerChallenge;\n\t\n\t this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n\t ChallengeName: 'CUSTOM_CHALLENGE',\n\t ChallengeResponses: challengeResponses,\n\t ClientId: this.pool.getClientId(),\n\t Session: this.Session\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t\n\t var challengeName = data.ChallengeName;\n\t\n\t if (challengeName === 'CUSTOM_CHALLENGE') {\n\t _this5.Session = data.Session;\n\t return callback.customChallenge(data.ChallengeParameters);\n\t }\n\t\n\t _this5.signInUserSession = _this5.getCognitoUserSession(data.AuthenticationResult);\n\t _this5.cacheTokens();\n\t return callback.onSuccess(_this5.signInUserSession);\n\t });\n\t };\n\t\n\t /**\n\t * This is used by the user once he has an MFA code\n\t * @param {string} confirmationCode The MFA code entered by the user.\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {authSuccess} callback.onSuccess Called on success with the new session.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.sendMFACode = function sendMFACode(confirmationCode, callback) {\n\t var _this6 = this;\n\t\n\t var challengeResponses = {};\n\t challengeResponses.USERNAME = this.username;\n\t challengeResponses.SMS_MFA_CODE = confirmationCode;\n\t\n\t if (this.deviceKey != null) {\n\t challengeResponses.DEVICE_KEY = this.deviceKey;\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n\t ChallengeName: 'SMS_MFA',\n\t ChallengeResponses: challengeResponses,\n\t ClientId: this.pool.getClientId(),\n\t Session: this.Session\n\t }, function (err, dataAuthenticate) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t\n\t var challengeName = dataAuthenticate.ChallengeName;\n\t\n\t if (challengeName === 'DEVICE_SRP_AUTH') {\n\t _this6.getDeviceResponse(callback);\n\t return undefined;\n\t }\n\t\n\t _this6.signInUserSession = _this6.getCognitoUserSession(dataAuthenticate.AuthenticationResult);\n\t _this6.cacheTokens();\n\t\n\t if (dataAuthenticate.AuthenticationResult.NewDeviceMetadata == null) {\n\t return callback.onSuccess(_this6.signInUserSession);\n\t }\n\t\n\t var authenticationHelper = new _AuthenticationHelper2.default(_this6.pool.getUserPoolId().split('_')[1]);\n\t authenticationHelper.generateHashDevice(dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey, dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey);\n\t\n\t var deviceSecretVerifierConfig = {\n\t Salt: new _global.util.Buffer(authenticationHelper.getSaltDevices(), 'hex').toString('base64'),\n\t PasswordVerifier: new _global.util.Buffer(authenticationHelper.getVerifierDevices(), 'hex').toString('base64')\n\t };\n\t\n\t _this6.verifierDevices = deviceSecretVerifierConfig.PasswordVerifier;\n\t _this6.deviceGroupKey = dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey;\n\t _this6.randomPassword = authenticationHelper.getRandomPassword();\n\t\n\t _this6.client.makeUnauthenticatedRequest('confirmDevice', {\n\t DeviceKey: dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey,\n\t AccessToken: _this6.signInUserSession.getAccessToken().getJwtToken(),\n\t DeviceSecretVerifierConfig: deviceSecretVerifierConfig,\n\t DeviceName: navigator.userAgent\n\t }, function (errConfirm, dataConfirm) {\n\t if (errConfirm) {\n\t return callback.onFailure(errConfirm);\n\t }\n\t\n\t _this6.deviceKey = dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey;\n\t _this6.cacheDeviceKeyAndPassword();\n\t if (dataConfirm.UserConfirmationNecessary === true) {\n\t return callback.onSuccess(_this6.signInUserSession, dataConfirm.UserConfirmationNecessary);\n\t }\n\t return callback.onSuccess(_this6.signInUserSession);\n\t });\n\t return undefined;\n\t });\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to change the current password\n\t * @param {string} oldUserPassword The current password.\n\t * @param {string} newUserPassword The requested new password.\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.changePassword = function changePassword(oldUserPassword, newUserPassword, callback) {\n\t if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('changePassword', {\n\t PreviousPassword: oldUserPassword,\n\t ProposedPassword: newUserPassword,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t return callback(null, 'SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to enable MFA for himself\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.enableMFA = function enableMFA(callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t var mfaOptions = [];\n\t var mfaEnabled = {\n\t DeliveryMedium: 'SMS',\n\t AttributeName: 'phone_number'\n\t };\n\t mfaOptions.push(mfaEnabled);\n\t\n\t this.client.makeUnauthenticatedRequest('setUserSettings', {\n\t MFAOptions: mfaOptions,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t return callback(null, 'SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to disable MFA for himself\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.disableMFA = function disableMFA(callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t var mfaOptions = [];\n\t\n\t this.client.makeUnauthenticatedRequest('setUserSettings', {\n\t MFAOptions: mfaOptions,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t return callback(null, 'SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to delete himself\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.deleteUser = function deleteUser(callback) {\n\t var _this7 = this;\n\t\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('deleteUser', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t _this7.clearCachedTokens();\n\t return callback(null, 'SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * @typedef {CognitoUserAttribute | { Name:string, Value:string }} AttributeArg\n\t */\n\t /**\n\t * This is used by an authenticated user to change a list of attributes\n\t * @param {AttributeArg[]} attributes A list of the new user attributes.\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.updateAttributes = function updateAttributes(attributes, callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('updateUserAttributes', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t UserAttributes: attributes\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t return callback(null, 'SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to get a list of attributes\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.getUserAttributes = function getUserAttributes(callback) {\n\t if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('getUser', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err, userData) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t\n\t var attributeList = [];\n\t\n\t for (var i = 0; i < userData.UserAttributes.length; i++) {\n\t var attribute = {\n\t Name: userData.UserAttributes[i].Name,\n\t Value: userData.UserAttributes[i].Value\n\t };\n\t var userAttribute = new _CognitoUserAttribute2.default(attribute);\n\t attributeList.push(userAttribute);\n\t }\n\t\n\t return callback(null, attributeList);\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to get the MFAOptions\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.getMFAOptions = function getMFAOptions(callback) {\n\t if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('getUser', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err, userData) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t\n\t return callback(null, userData.MFAOptions);\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to delete a list of attributes\n\t * @param {string[]} attributeList Names of the attributes to delete.\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.deleteAttributes = function deleteAttributes(attributeList, callback) {\n\t if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('deleteUserAttributes', {\n\t UserAttributeNames: attributeList,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t return callback(null, 'SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by a user to resend a confirmation code\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.resendConfirmationCode = function resendConfirmationCode(callback) {\n\t this.client.makeUnauthenticatedRequest('resendConfirmationCode', {\n\t ClientId: this.pool.getClientId(),\n\t Username: this.username\n\t }, function (err) {\n\t if (err, result) {\n\t return callback(err, null);\n\t }\n\t return callback(null, result);\n\t });\n\t };\n\t\n\t /**\n\t * This is used to get a session, either from the session object\n\t * or from the local storage, or by using a refresh token\n\t *\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.getSession = function getSession(callback) {\n\t if (this.username == null) {\n\t return callback(new Error('Username is null. Cannot retrieve a new session'), null);\n\t }\n\t\n\t if (this.signInUserSession != null && this.signInUserSession.isValid()) {\n\t return callback(null, this.signInUserSession);\n\t }\n\t\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId() + '.' + this.username;\n\t var idTokenKey = keyPrefix + '.idToken';\n\t var accessTokenKey = keyPrefix + '.accessToken';\n\t var refreshTokenKey = keyPrefix + '.refreshToken';\n\t\n\t if (this.storage.getItem(idTokenKey)) {\n\t var idToken = new _CognitoIdToken2.default({\n\t IdToken: this.storage.getItem(idTokenKey)\n\t });\n\t var accessToken = new _CognitoAccessToken2.default({\n\t AccessToken: this.storage.getItem(accessTokenKey)\n\t });\n\t var refreshToken = new _CognitoRefreshToken2.default({\n\t RefreshToken: this.storage.getItem(refreshTokenKey)\n\t });\n\t\n\t var sessionData = {\n\t IdToken: idToken,\n\t AccessToken: accessToken,\n\t RefreshToken: refreshToken\n\t };\n\t var cachedSession = new _CognitoUserSession2.default(sessionData);\n\t if (cachedSession.isValid()) {\n\t this.signInUserSession = cachedSession;\n\t return callback(null, this.signInUserSession);\n\t }\n\t\n\t if (refreshToken.getToken() == null) {\n\t return callback(new Error('Cannot retrieve a new session. Please authenticate.'), null);\n\t }\n\t\n\t this.refreshSession(refreshToken, callback);\n\t } else {\n\t callback(new Error('Local storage is missing an ID Token, Please authenticate'), null);\n\t }\n\t\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This uses the refreshToken to retrieve a new session\n\t * @param {CognitoRefreshToken} refreshToken A previous session's refresh token.\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.refreshSession = function refreshSession(refreshToken, callback) {\n\t var _this8 = this;\n\t\n\t var authParameters = {};\n\t authParameters.REFRESH_TOKEN = refreshToken.getToken();\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId();\n\t var lastUserKey = keyPrefix + '.LastAuthUser';\n\t\n\t if (this.storage.getItem(lastUserKey)) {\n\t this.username = this.storage.getItem(lastUserKey);\n\t var deviceKeyKey = keyPrefix + '.' + this.username + '.deviceKey';\n\t this.deviceKey = this.storage.getItem(deviceKeyKey);\n\t authParameters.DEVICE_KEY = this.deviceKey;\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('initiateAuth', {\n\t ClientId: this.pool.getClientId(),\n\t AuthFlow: 'REFRESH_TOKEN_AUTH',\n\t AuthParameters: authParameters\n\t }, function (err, authResult) {\n\t if (err) {\n\t if (err.code === 'NotAuthorizedException') {\n\t _this8.clearCachedTokens();\n\t }\n\t return callback(err, null);\n\t }\n\t if (authResult) {\n\t var authenticationResult = authResult.AuthenticationResult;\n\t if (!Object.prototype.hasOwnProperty.call(authenticationResult, 'RefreshToken')) {\n\t authenticationResult.RefreshToken = refreshToken.getToken();\n\t }\n\t _this8.signInUserSession = _this8.getCognitoUserSession(authenticationResult);\n\t _this8.cacheTokens();\n\t return callback(null, _this8.signInUserSession);\n\t }\n\t return undefined;\n\t });\n\t };\n\t\n\t /**\n\t * This is used to save the session tokens to local storage\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.cacheTokens = function cacheTokens() {\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId();\n\t var idTokenKey = keyPrefix + '.' + this.username + '.idToken';\n\t var accessTokenKey = keyPrefix + '.' + this.username + '.accessToken';\n\t var refreshTokenKey = keyPrefix + '.' + this.username + '.refreshToken';\n\t var lastUserKey = keyPrefix + '.LastAuthUser';\n\t\n\t this.storage.setItem(idTokenKey, this.signInUserSession.getIdToken().getJwtToken());\n\t this.storage.setItem(accessTokenKey, this.signInUserSession.getAccessToken().getJwtToken());\n\t this.storage.setItem(refreshTokenKey, this.signInUserSession.getRefreshToken().getToken());\n\t this.storage.setItem(lastUserKey, this.username);\n\t };\n\t\n\t /**\n\t * This is used to cache the device key and device group and device password\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.cacheDeviceKeyAndPassword = function cacheDeviceKeyAndPassword() {\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId() + '.' + this.username;\n\t var deviceKeyKey = keyPrefix + '.deviceKey';\n\t var randomPasswordKey = keyPrefix + '.randomPasswordKey';\n\t var deviceGroupKeyKey = keyPrefix + '.deviceGroupKey';\n\t\n\t this.storage.setItem(deviceKeyKey, this.deviceKey);\n\t this.storage.setItem(randomPasswordKey, this.randomPassword);\n\t this.storage.setItem(deviceGroupKeyKey, this.deviceGroupKey);\n\t };\n\t\n\t /**\n\t * This is used to get current device key and device group and device password\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.getCachedDeviceKeyAndPassword = function getCachedDeviceKeyAndPassword() {\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId() + '.' + this.username;\n\t var deviceKeyKey = keyPrefix + '.deviceKey';\n\t var randomPasswordKey = keyPrefix + '.randomPasswordKey';\n\t var deviceGroupKeyKey = keyPrefix + '.deviceGroupKey';\n\t\n\t if (this.storage.getItem(deviceKeyKey)) {\n\t this.deviceKey = this.storage.getItem(deviceKeyKey);\n\t this.randomPassword = this.storage.getItem(randomPasswordKey);\n\t this.deviceGroupKey = this.storage.getItem(deviceGroupKeyKey);\n\t }\n\t };\n\t\n\t /**\n\t * This is used to clear the device key info from local storage\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.clearCachedDeviceKeyAndPassword = function clearCachedDeviceKeyAndPassword() {\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId() + '.' + this.username;\n\t var deviceKeyKey = keyPrefix + '.deviceKey';\n\t var randomPasswordKey = keyPrefix + '.randomPasswordKey';\n\t var deviceGroupKeyKey = keyPrefix + '.deviceGroupKey';\n\t\n\t this.storage.removeItem(deviceKeyKey);\n\t this.storage.removeItem(randomPasswordKey);\n\t this.storage.removeItem(deviceGroupKeyKey);\n\t };\n\t\n\t /**\n\t * This is used to clear the session tokens from local storage\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.clearCachedTokens = function clearCachedTokens() {\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId();\n\t var idTokenKey = keyPrefix + '.' + this.username + '.idToken';\n\t var accessTokenKey = keyPrefix + '.' + this.username + '.accessToken';\n\t var refreshTokenKey = keyPrefix + '.' + this.username + '.refreshToken';\n\t var lastUserKey = keyPrefix + '.LastAuthUser';\n\t\n\t this.storage.removeItem(idTokenKey);\n\t this.storage.removeItem(accessTokenKey);\n\t this.storage.removeItem(refreshTokenKey);\n\t this.storage.removeItem(lastUserKey);\n\t };\n\t\n\t /**\n\t * This is used to build a user session from tokens retrieved in the authentication result\n\t * @param {object} authResult Successful auth response from server.\n\t * @returns {CognitoUserSession} The new user session.\n\t * @private\n\t */\n\t\n\t\n\t CognitoUser.prototype.getCognitoUserSession = function getCognitoUserSession(authResult) {\n\t var idToken = new _CognitoIdToken2.default(authResult);\n\t var accessToken = new _CognitoAccessToken2.default(authResult);\n\t var refreshToken = new _CognitoRefreshToken2.default(authResult);\n\t\n\t var sessionData = {\n\t IdToken: idToken,\n\t AccessToken: accessToken,\n\t RefreshToken: refreshToken\n\t };\n\t\n\t return new _CognitoUserSession2.default(sessionData);\n\t };\n\t\n\t /**\n\t * This is used to initiate a forgot password request\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {inputVerificationCode?} callback.inputVerificationCode\n\t * Optional callback raised instead of onSuccess with response data.\n\t * @param {onSuccess?} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.forgotPassword = function forgotPassword(callback) {\n\t this.client.makeUnauthenticatedRequest('forgotPassword', {\n\t ClientId: this.pool.getClientId(),\n\t Username: this.username\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t if (typeof callback.inputVerificationCode === 'function') {\n\t return callback.inputVerificationCode(data);\n\t }\n\t return callback.onSuccess();\n\t });\n\t };\n\t\n\t /**\n\t * This is used to confirm a new password using a confirmationCode\n\t * @param {string} confirmationCode Code entered by user.\n\t * @param {string} newPassword Confirm new password.\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.confirmPassword = function confirmPassword(confirmationCode, newPassword, callback) {\n\t this.client.makeUnauthenticatedRequest('confirmForgotPassword', {\n\t ClientId: this.pool.getClientId(),\n\t Username: this.username,\n\t ConfirmationCode: confirmationCode,\n\t Password: newPassword\n\t }, function (err) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess();\n\t });\n\t };\n\t\n\t /**\n\t * This is used to initiate an attribute confirmation request\n\t * @param {string} attributeName User attribute that needs confirmation.\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {inputVerificationCode} callback.inputVerificationCode Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.getAttributeVerificationCode = function getAttributeVerificationCode(attributeName, callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('getUserAttributeVerificationCode', {\n\t AttributeName: attributeName,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t if (typeof callback.inputVerificationCode === 'function') {\n\t return callback.inputVerificationCode(data);\n\t }\n\t return callback.onSuccess();\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to confirm an attribute using a confirmation code\n\t * @param {string} attributeName Attribute being confirmed.\n\t * @param {string} confirmationCode Code entered by user.\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.verifyAttribute = function verifyAttribute(attributeName, confirmationCode, callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('verifyUserAttribute', {\n\t AttributeName: attributeName,\n\t Code: confirmationCode,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess('SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to get the device information using the current device key\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess<*>} callback.onSuccess Called on success with device data.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.getDevice = function getDevice(callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('getDevice', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t DeviceKey: this.deviceKey\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess(data);\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to forget a specific device\n\t * @param {string} deviceKey Device key.\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.forgetSpecificDevice = function forgetSpecificDevice(deviceKey, callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('forgetDevice', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t DeviceKey: deviceKey\n\t }, function (err) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess('SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to forget the current device\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.forgetDevice = function forgetDevice(callback) {\n\t var _this9 = this;\n\t\n\t this.forgetSpecificDevice(this.deviceKey, {\n\t onFailure: callback.onFailure,\n\t onSuccess: function onSuccess(result) {\n\t _this9.deviceKey = null;\n\t _this9.deviceGroupKey = null;\n\t _this9.randomPassword = null;\n\t _this9.clearCachedDeviceKeyAndPassword();\n\t return callback.onSuccess(result);\n\t }\n\t });\n\t };\n\t\n\t /**\n\t * This is used to set the device status as remembered\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.setDeviceStatusRemembered = function setDeviceStatusRemembered(callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('updateDeviceStatus', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t DeviceKey: this.deviceKey,\n\t DeviceRememberedStatus: 'remembered'\n\t }, function (err) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess('SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to set the device status as not remembered\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.setDeviceStatusNotRemembered = function setDeviceStatusNotRemembered(callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('updateDeviceStatus', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t DeviceKey: this.deviceKey,\n\t DeviceRememberedStatus: 'not_remembered'\n\t }, function (err) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess('SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to list all devices for a user\n\t *\n\t * @param {int} limit the number of devices returned in a call\n\t * @param {string} paginationToken the pagination token in case any was returned before\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess<*>} callback.onSuccess Called on success with device list.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.listDevices = function listDevices(limit, paginationToken, callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('listDevices', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t Limit: limit,\n\t PaginationToken: paginationToken\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess(data);\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to globally revoke all tokens issued to a user\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.globalSignOut = function globalSignOut(callback) {\n\t var _this10 = this;\n\t\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('globalSignOut', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t _this10.clearCachedTokens();\n\t return callback.onSuccess('SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used for the user to signOut of the application and clear the cached tokens.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.signOut = function signOut() {\n\t this.signInUserSession = null;\n\t this.clearCachedTokens();\n\t };\n\t\n\t return CognitoUser;\n\t}();\n\t\n\texports.default = CognitoUser;\n\n/***/ }),\n/* 8 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar CognitoUserAttribute = function () {\n\t /**\n\t * Constructs a new CognitoUserAttribute object\n\t * @param {string=} Name The record's name\n\t * @param {string=} Value The record's value\n\t */\n\t function CognitoUserAttribute() {\n\t var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n\t Name = _ref.Name,\n\t Value = _ref.Value;\n\t\n\t _classCallCheck(this, CognitoUserAttribute);\n\t\n\t this.Name = Name || '';\n\t this.Value = Value || '';\n\t }\n\t\n\t /**\n\t * @returns {string} the record's value.\n\t */\n\t\n\t\n\t CognitoUserAttribute.prototype.getValue = function getValue() {\n\t return this.Value;\n\t };\n\t\n\t /**\n\t * Sets the record's value.\n\t * @param {string} value The new value.\n\t * @returns {CognitoUserAttribute} The record for method chaining.\n\t */\n\t\n\t\n\t CognitoUserAttribute.prototype.setValue = function setValue(value) {\n\t this.Value = value;\n\t return this;\n\t };\n\t\n\t /**\n\t * @returns {string} the record's name.\n\t */\n\t\n\t\n\t CognitoUserAttribute.prototype.getName = function getName() {\n\t return this.Name;\n\t };\n\t\n\t /**\n\t * Sets the record's name\n\t * @param {string} name The new name.\n\t * @returns {CognitoUserAttribute} The record for method chaining.\n\t */\n\t\n\t\n\t CognitoUserAttribute.prototype.setName = function setName(name) {\n\t this.Name = name;\n\t return this;\n\t };\n\t\n\t /**\n\t * @returns {string} a string representation of the record.\n\t */\n\t\n\t\n\t CognitoUserAttribute.prototype.toString = function toString() {\n\t return JSON.stringify(this);\n\t };\n\t\n\t /**\n\t * @returns {object} a flat object representing the record.\n\t */\n\t\n\t\n\t CognitoUserAttribute.prototype.toJSON = function toJSON() {\n\t return {\n\t Name: this.Name,\n\t Value: this.Value\n\t };\n\t };\n\t\n\t return CognitoUserAttribute;\n\t}();\n\t\n\texports.default = CognitoUserAttribute;\n\n/***/ }),\n/* 9 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar CognitoUserSession = function () {\n\t /**\n\t * Constructs a new CognitoUserSession object\n\t * @param {string} IdToken The session's Id token.\n\t * @param {string=} RefreshToken The session's refresh token.\n\t * @param {string} AccessToken The session's access token.\n\t */\n\t function CognitoUserSession() {\n\t var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n\t IdToken = _ref.IdToken,\n\t RefreshToken = _ref.RefreshToken,\n\t AccessToken = _ref.AccessToken;\n\t\n\t _classCallCheck(this, CognitoUserSession);\n\t\n\t if (AccessToken == null || IdToken == null) {\n\t throw new Error('Id token and Access Token must be present.');\n\t }\n\t\n\t this.idToken = IdToken;\n\t this.refreshToken = RefreshToken;\n\t this.accessToken = AccessToken;\n\t }\n\t\n\t /**\n\t * @returns {CognitoIdToken} the session's Id token\n\t */\n\t\n\t\n\t CognitoUserSession.prototype.getIdToken = function getIdToken() {\n\t return this.idToken;\n\t };\n\t\n\t /**\n\t * @returns {CognitoRefreshToken} the session's refresh token\n\t */\n\t\n\t\n\t CognitoUserSession.prototype.getRefreshToken = function getRefreshToken() {\n\t return this.refreshToken;\n\t };\n\t\n\t /**\n\t * @returns {CognitoAccessToken} the session's access token\n\t */\n\t\n\t\n\t CognitoUserSession.prototype.getAccessToken = function getAccessToken() {\n\t return this.accessToken;\n\t };\n\t\n\t /**\n\t * Checks to see if the session is still valid based on session expiry information found\n\t * in tokens and the current time\n\t * @returns {boolean} if the session is still valid\n\t */\n\t\n\t\n\t CognitoUserSession.prototype.isValid = function isValid() {\n\t var now = Math.floor(new Date() / 1000);\n\t\n\t return now < this.accessToken.getExpiration() && now < this.idToken.getExpiration();\n\t };\n\t\n\t return CognitoUserSession;\n\t}();\n\t\n\texports.default = CognitoUserSession;\n\n/***/ }),\n/* 10 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\tvar monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n\tvar weekNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];\n\t\n\t/** @class */\n\t\n\tvar DateHelper = function () {\n\t function DateHelper() {\n\t _classCallCheck(this, DateHelper);\n\t }\n\t\n\t /**\n\t * @returns {string} The current time in \"ddd MMM D HH:mm:ss UTC YYYY\" format.\n\t */\n\t DateHelper.prototype.getNowString = function getNowString() {\n\t var now = new Date();\n\t\n\t var weekDay = weekNames[now.getUTCDay()];\n\t var month = monthNames[now.getUTCMonth()];\n\t var day = now.getUTCDate();\n\t\n\t var hours = now.getUTCHours();\n\t if (hours < 10) {\n\t hours = '0' + hours;\n\t }\n\t\n\t var minutes = now.getUTCMinutes();\n\t if (minutes < 10) {\n\t minutes = '0' + minutes;\n\t }\n\t\n\t var seconds = now.getUTCSeconds();\n\t if (seconds < 10) {\n\t seconds = '0' + seconds;\n\t }\n\t\n\t var year = now.getUTCFullYear();\n\t\n\t // ddd MMM D HH:mm:ss UTC YYYY\n\t var dateNow = weekDay + ' ' + month + ' ' + day + ' ' + hours + ':' + minutes + ':' + seconds + ' UTC ' + year;\n\t\n\t return dateNow;\n\t };\n\t\n\t return DateHelper;\n\t}();\n\t\n\texports.default = DateHelper;\n\n/***/ }),\n/* 11 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\tvar dataMemory = {};\n\t\n\t/** @class */\n\t\n\tvar MemoryStorage = function () {\n\t function MemoryStorage() {\n\t _classCallCheck(this, MemoryStorage);\n\t }\n\t\n\t /**\n\t * This is used to set a specific item in storage\n\t * @param {string} key - the key for the item\n\t * @param {object} value - the value\n\t * @returns {string} value that was set\n\t */\n\t MemoryStorage.setItem = function setItem(key, value) {\n\t dataMemory[key] = value;\n\t return dataMemory[key];\n\t };\n\t\n\t /**\n\t * This is used to get a specific key from storage\n\t * @param {string} key - the key for the item\n\t * This is used to clear the storage\n\t * @returns {string} the data item\n\t */\n\t\n\t\n\t MemoryStorage.getItem = function getItem(key) {\n\t return Object.prototype.hasOwnProperty.call(dataMemory, key) ? dataMemory[key] : undefined;\n\t };\n\t\n\t /**\n\t * This is used to remove an item from storage\n\t * @param {string} key - the key being set\n\t * @returns {string} value - value that was deleted\n\t */\n\t\n\t\n\t MemoryStorage.removeItem = function removeItem(key) {\n\t return delete dataMemory[key];\n\t };\n\t\n\t /**\n\t * This is used to clear the storage\n\t * @returns {string} nothing\n\t */\n\t\n\t\n\t MemoryStorage.clear = function clear() {\n\t dataMemory = {};\n\t return dataMemory;\n\t };\n\t\n\t return MemoryStorage;\n\t}();\n\t\n\t/** @class */\n\t\n\t\n\tvar StorageHelper = function () {\n\t\n\t /**\n\t * This is used to get a storage object\n\t * @returns {object} the storage\n\t */\n\t function StorageHelper() {\n\t _classCallCheck(this, StorageHelper);\n\t\n\t try {\n\t this.storageWindow = window.localStorage;\n\t this.storageWindow.setItem('aws.cognito.test-ls', 1);\n\t this.storageWindow.removeItem('aws.cognito.test-ls');\n\t } catch (exception) {\n\t this.storageWindow = MemoryStorage;\n\t }\n\t }\n\t\n\t /**\n\t * This is used to return the storage\n\t * @returns {object} the storage\n\t */\n\t\n\t\n\t StorageHelper.prototype.getStorage = function getStorage() {\n\t return this.storageWindow;\n\t };\n\t\n\t return StorageHelper;\n\t}();\n\t\n\texports.default = StorageHelper;\n\n/***/ }),\n/* 12 */\n/***/ (function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_12__;\n\n/***/ }),\n/* 13 */\n/***/ (function(module, exports) {\n\n\t\"use strict\";\n\t\n\texports.__esModule = true;\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar AuthenticationDetails = function () {\n\t /**\n\t * Constructs a new AuthenticationDetails object\n\t * @param {object=} data Creation options.\n\t * @param {string} data.Username User being authenticated.\n\t * @param {string} data.Password Plain-text password to authenticate with.\n\t * @param {(AttributeArg[])?} data.ValidationData Application extra metadata.\n\t */\n\t function AuthenticationDetails(data) {\n\t _classCallCheck(this, AuthenticationDetails);\n\t\n\t var _ref = data || {},\n\t ValidationData = _ref.ValidationData,\n\t Username = _ref.Username,\n\t Password = _ref.Password;\n\t\n\t this.validationData = ValidationData || [];\n\t this.username = Username;\n\t this.password = Password;\n\t }\n\t\n\t /**\n\t * @returns {string} the record's username\n\t */\n\t\n\t\n\t AuthenticationDetails.prototype.getUsername = function getUsername() {\n\t return this.username;\n\t };\n\t\n\t /**\n\t * @returns {string} the record's password\n\t */\n\t\n\t\n\t AuthenticationDetails.prototype.getPassword = function getPassword() {\n\t return this.password;\n\t };\n\t\n\t /**\n\t * @returns {Array} the record's validationData\n\t */\n\t\n\t\n\t AuthenticationDetails.prototype.getValidationData = function getValidationData() {\n\t return this.validationData;\n\t };\n\t\n\t return AuthenticationDetails;\n\t}();\n\t\n\texports.default = AuthenticationDetails;\n\n/***/ }),\n/* 14 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tvar _cognitoidentityserviceprovider = __webpack_require__(12);\n\t\n\tvar _cognitoidentityserviceprovider2 = _interopRequireDefault(_cognitoidentityserviceprovider);\n\t\n\tvar _CognitoUser = __webpack_require__(7);\n\t\n\tvar _CognitoUser2 = _interopRequireDefault(_CognitoUser);\n\t\n\tvar _StorageHelper = __webpack_require__(11);\n\t\n\tvar _StorageHelper2 = _interopRequireDefault(_StorageHelper);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } } /*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar CognitoUserPool = function () {\n\t /**\n\t * Constructs a new CognitoUserPool object\n\t * @param {object} data Creation options.\n\t * @param {string} data.UserPoolId Cognito user pool id.\n\t * @param {string} data.ClientId User pool application client id.\n\t * @param {object} data.Storage Optional storage object.\n\t */\n\t function CognitoUserPool(data) {\n\t _classCallCheck(this, CognitoUserPool);\n\t\n\t var _ref = data || {},\n\t UserPoolId = _ref.UserPoolId,\n\t ClientId = _ref.ClientId;\n\t\n\t if (!UserPoolId || !ClientId) {\n\t throw new Error('Both UserPoolId and ClientId are required.');\n\t }\n\t if (!/^[\\w-]+_.+$/.test(UserPoolId)) {\n\t throw new Error('Invalid UserPoolId format.');\n\t }\n\t var region = UserPoolId.split('_')[0];\n\t\n\t this.userPoolId = UserPoolId;\n\t this.clientId = ClientId;\n\t\n\t this.client = new _cognitoidentityserviceprovider2.default({ apiVersion: '2016-04-19', region: region });\n\t\n\t this.storage = data.Storage || new _StorageHelper2.default().getStorage();\n\t }\n\t\n\t /**\n\t * @returns {string} the user pool id\n\t */\n\t\n\t\n\t CognitoUserPool.prototype.getUserPoolId = function getUserPoolId() {\n\t return this.userPoolId;\n\t };\n\t\n\t /**\n\t * @returns {string} the client id\n\t */\n\t\n\t\n\t CognitoUserPool.prototype.getClientId = function getClientId() {\n\t return this.clientId;\n\t };\n\t\n\t /**\n\t * @typedef {object} SignUpResult\n\t * @property {CognitoUser} user New user.\n\t * @property {bool} userConfirmed If the user is already confirmed.\n\t */\n\t /**\n\t * method for signing up a user\n\t * @param {string} username User's username.\n\t * @param {string} password Plain-text initial password entered by user.\n\t * @param {(AttributeArg[])=} userAttributes New user attributes.\n\t * @param {(AttributeArg[])=} validationData Application metadata.\n\t * @param {nodeCallback} callback Called on error or with the new user.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUserPool.prototype.signUp = function signUp(username, password, userAttributes, validationData, callback) {\n\t var _this = this;\n\t\n\t this.client.makeUnauthenticatedRequest('signUp', {\n\t ClientId: this.clientId,\n\t Username: username,\n\t Password: password,\n\t UserAttributes: userAttributes,\n\t ValidationData: validationData\n\t }, function (err, data) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t\n\t var cognitoUser = {\n\t Username: username,\n\t Pool: _this,\n\t Storage: _this.storage\n\t };\n\t\n\t var returnData = {\n\t user: new _CognitoUser2.default(cognitoUser),\n\t userConfirmed: data.UserConfirmed\n\t };\n\t\n\t return callback(null, returnData);\n\t });\n\t };\n\t\n\t /**\n\t * method for getting the current user of the application from the local storage\n\t *\n\t * @returns {CognitoUser} the user retrieved from storage\n\t */\n\t\n\t\n\t CognitoUserPool.prototype.getCurrentUser = function getCurrentUser() {\n\t var lastUserKey = 'CognitoIdentityServiceProvider.' + this.clientId + '.LastAuthUser';\n\t\n\t var lastAuthUser = this.storage.getItem(lastUserKey);\n\t if (lastAuthUser) {\n\t var cognitoUser = {\n\t Username: lastAuthUser,\n\t Pool: this,\n\t Storage: this.storage\n\t };\n\t\n\t return new _CognitoUser2.default(cognitoUser);\n\t }\n\t\n\t return null;\n\t };\n\t\n\t return CognitoUserPool;\n\t}();\n\t\n\texports.default = CognitoUserPool;\n\n/***/ }),\n/* 15 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tvar _AuthenticationDetails = __webpack_require__(13);\n\t\n\tObject.defineProperty(exports, 'AuthenticationDetails', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_AuthenticationDetails).default;\n\t }\n\t});\n\t\n\tvar _AuthenticationHelper = __webpack_require__(2);\n\t\n\tObject.defineProperty(exports, 'AuthenticationHelper', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_AuthenticationHelper).default;\n\t }\n\t});\n\t\n\tvar _CognitoAccessToken = __webpack_require__(4);\n\t\n\tObject.defineProperty(exports, 'CognitoAccessToken', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoAccessToken).default;\n\t }\n\t});\n\t\n\tvar _CognitoIdToken = __webpack_require__(5);\n\t\n\tObject.defineProperty(exports, 'CognitoIdToken', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoIdToken).default;\n\t }\n\t});\n\t\n\tvar _CognitoRefreshToken = __webpack_require__(6);\n\t\n\tObject.defineProperty(exports, 'CognitoRefreshToken', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoRefreshToken).default;\n\t }\n\t});\n\t\n\tvar _CognitoUser = __webpack_require__(7);\n\t\n\tObject.defineProperty(exports, 'CognitoUser', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoUser).default;\n\t }\n\t});\n\t\n\tvar _CognitoUserAttribute = __webpack_require__(8);\n\t\n\tObject.defineProperty(exports, 'CognitoUserAttribute', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoUserAttribute).default;\n\t }\n\t});\n\t\n\tvar _CognitoUserPool = __webpack_require__(14);\n\t\n\tObject.defineProperty(exports, 'CognitoUserPool', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoUserPool).default;\n\t }\n\t});\n\t\n\tvar _CognitoUserSession = __webpack_require__(9);\n\t\n\tObject.defineProperty(exports, 'CognitoUserSession', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoUserSession).default;\n\t }\n\t});\n\t\n\tvar _DateHelper = __webpack_require__(10);\n\t\n\tObject.defineProperty(exports, 'DateHelper', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_DateHelper).default;\n\t }\n\t});\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/***/ })\n/******/ ])\n});\n;\n\n\n// WEBPACK FOOTER //\n// amazon-cognito-identity.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap b2ad5b6a1fa064617640","import CognitoIdentityServiceProvider from 'aws-sdk/clients/cognitoidentityserviceprovider';\nimport * as enhancements from './src';\n\nexport * from './src';\n\nObject.keys(enhancements).forEach(key => {\n CognitoIdentityServiceProvider[key] = enhancements[key];\n});\n\n// The version of crypto-browserify included by aws-sdk only\n// checks for window.crypto, not window.msCrypto as used by\n// IE 11 – so we set it explicitly here\nif (typeof window !== 'undefined' && !window.crypto && window.msCrypto) {\n window.crypto = window.msCrypto;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./enhance.js","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":[\"AWSCognito\"],\"commonjs2\":\"aws-sdk/global\",\"commonjs\":\"aws-sdk/global\",\"amd\":\"aws-sdk/global\"}\n// module id = 1\n// module chunks = 0","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { util } from 'aws-sdk/global';\n\nimport BigInteger from './BigInteger';\n\nconst initN = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1'\n + '29024E088A67CC74020BBEA63B139B22514A08798E3404DD'\n + 'EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245'\n + 'E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED'\n + 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D'\n + 'C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F'\n + '83655D23DCA3AD961C62F356208552BB9ED529077096966D'\n + '670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B'\n + 'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9'\n + 'DE2BCBF6955817183995497CEA956AE515D2261898FA0510'\n + '15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64'\n + 'ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7'\n + 'ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B'\n + 'F12FFA06D98A0864D87602733EC86A64521F2B18177B200C'\n + 'BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31'\n + '43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF';\n\nconst newPasswordRequiredChallengeUserAttributePrefix = 'userAttributes.';\n\n/** @class */\nexport default class AuthenticationHelper {\n /**\n * Constructs a new AuthenticationHelper object\n * @param {string} PoolName Cognito user pool name.\n */\n constructor(PoolName) {\n this.N = new BigInteger(initN, 16);\n this.g = new BigInteger('2', 16);\n this.k = new BigInteger(this.hexHash(`00${this.N.toString(16)}0${this.g.toString(16)}`), 16);\n\n this.smallAValue = this.generateRandomSmallA();\n this.largeAValue = this.calculateA(this.smallAValue);\n\n this.infoBits = new util.Buffer('Caldera Derived Key', 'utf8');\n\n this.poolName = PoolName;\n }\n\n /**\n * @returns {BigInteger} small A, a random number\n */\n getSmallAValue() {\n return this.smallAValue;\n }\n\n /**\n * @returns {BigInteger} large A, a value generated from small A\n */\n getLargeAValue() {\n return this.largeAValue;\n }\n\n /**\n * helper function to generate a random big integer\n * @returns {BigInteger} a random value.\n * @private\n */\n generateRandomSmallA() {\n const hexRandom = util.crypto.lib.randomBytes(128).toString('hex');\n\n const randomBigInt = new BigInteger(hexRandom, 16);\n const smallABigInt = randomBigInt.mod(this.N);\n\n return smallABigInt;\n }\n\n /**\n * helper function to generate a random string\n * @returns {string} a random value.\n * @private\n */\n generateRandomString() {\n return util.crypto.lib.randomBytes(40).toString('base64');\n }\n\n /**\n * @returns {string} Generated random value included in password hash.\n */\n getRandomPassword() {\n return this.randomPassword;\n }\n\n /**\n * @returns {string} Generated random value included in devices hash.\n */\n getSaltDevices() {\n return this.SaltToHashDevices;\n }\n\n /**\n * @returns {string} Value used to verify devices.\n */\n getVerifierDevices() {\n return this.verifierDevices;\n }\n\n /**\n * Generate salts and compute verifier.\n * @param {string} deviceGroupKey Devices to generate verifier for.\n * @param {string} username User to generate verifier for.\n * @returns {void}\n */\n generateHashDevice(deviceGroupKey, username) {\n this.randomPassword = this.generateRandomString();\n const combinedString = `${deviceGroupKey}${username}:${this.randomPassword}`;\n const hashedString = this.hash(combinedString);\n\n const hexRandom = util.crypto.lib.randomBytes(16).toString('hex');\n this.SaltToHashDevices = this.padHex(new BigInteger(hexRandom, 16));\n\n const verifierDevicesNotPadded = this.g.modPow(\n new BigInteger(this.hexHash(this.SaltToHashDevices + hashedString), 16),\n this.N);\n\n this.verifierDevices = this.padHex(verifierDevicesNotPadded);\n }\n\n /**\n * Calculate the client's public value A = g^a%N\n * with the generated random number a\n * @param {BigInteger} a Randomly generated small A.\n * @returns {BigInteger} Computed large A.\n * @private\n */\n calculateA(a) {\n const A = this.g.modPow(a, this.N);\n\n if (A.mod(this.N).equals(BigInteger.ZERO)) {\n throw new Error('Illegal paramater. A mod N cannot be 0.');\n }\n return A;\n }\n\n /**\n * Calculate the client's value U which is the hash of A and B\n * @param {BigInteger} A Large A value.\n * @param {BigInteger} B Server B value.\n * @returns {BigInteger} Computed U value.\n * @private\n */\n calculateU(A, B) {\n this.UHexHash = this.hexHash(this.padHex(A) + this.padHex(B));\n const finalU = new BigInteger(this.UHexHash, 16);\n\n return finalU;\n }\n\n /**\n * Calculate a hash from a bitArray\n * @param {Buffer} buf Value to hash.\n * @returns {String} Hex-encoded hash.\n * @private\n */\n hash(buf) {\n const hashHex = util.crypto.sha256(buf, 'hex');\n return (new Array(64 - hashHex.length).join('0')) + hashHex;\n }\n\n /**\n * Calculate a hash from a hex string\n * @param {String} hexStr Value to hash.\n * @returns {String} Hex-encoded hash.\n * @private\n */\n hexHash(hexStr) {\n return this.hash(new util.Buffer(hexStr, 'hex'));\n }\n\n /**\n * Standard hkdf algorithm\n * @param {Buffer} ikm Input key material.\n * @param {Buffer} salt Salt value.\n * @returns {Buffer} Strong key material.\n * @private\n */\n computehkdf(ikm, salt) {\n const prk = util.crypto.hmac(salt, ikm, 'buffer', 'sha256');\n const infoBitsUpdate = util.buffer.concat([\n this.infoBits,\n new util.Buffer(String.fromCharCode(1), 'utf8'),\n ]);\n const hmac = util.crypto.hmac(prk, infoBitsUpdate, 'buffer', 'sha256');\n return hmac.slice(0, 16);\n }\n\n /**\n * Calculates the final hkdf based on computed S value, and computed U value and the key\n * @param {String} username Username.\n * @param {String} password Password.\n * @param {BigInteger} serverBValue Server B value.\n * @param {BigInteger} salt Generated salt.\n * @returns {Buffer} Computed HKDF value.\n */\n getPasswordAuthenticationKey(username, password, serverBValue, salt) {\n if (serverBValue.mod(this.N).equals(BigInteger.ZERO)) {\n throw new Error('B cannot be zero.');\n }\n\n this.UValue = this.calculateU(this.largeAValue, serverBValue);\n\n if (this.UValue.equals(BigInteger.ZERO)) {\n throw new Error('U cannot be zero.');\n }\n\n const usernamePassword = `${this.poolName}${username}:${password}`;\n const usernamePasswordHash = this.hash(usernamePassword);\n\n const xValue = new BigInteger(this.hexHash(this.padHex(salt) + usernamePasswordHash), 16);\n\n const gModPowXN = this.g.modPow(xValue, this.N);\n const intValue2 = serverBValue.subtract(this.k.multiply(gModPowXN));\n const sValue = intValue2.modPow(\n this.smallAValue.add(this.UValue.multiply(xValue)),\n this.N\n ).mod(this.N);\n\n const hkdf = this.computehkdf(\n new util.Buffer(this.padHex(sValue), 'hex'),\n new util.Buffer(this.padHex(this.UValue.toString(16)), 'hex'));\n\n return hkdf;\n }\n\n /**\n * Return constant newPasswordRequiredChallengeUserAttributePrefix\n * @return {newPasswordRequiredChallengeUserAttributePrefix} constant prefix value\n */\n getNewPasswordRequiredChallengeUserAttributePrefix() {\n return newPasswordRequiredChallengeUserAttributePrefix;\n }\n\n /**\n * Converts a BigInteger (or hex string) to hex format padded with zeroes for hashing\n * @param {BigInteger|String} bigInt Number or string to pad.\n * @returns {String} Padded hex string.\n */\n padHex(bigInt) {\n let hashStr = bigInt.toString(16);\n if (hashStr.length % 2 === 1) {\n hashStr = `0${hashStr}`;\n } else if ('89ABCDEFabcdef'.indexOf(hashStr[0]) !== -1) {\n hashStr = `00${hashStr}`;\n }\n return hashStr;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/AuthenticationHelper.js","// A small implementation of BigInteger based on http://www-cs-students.stanford.edu/~tjw/jsbn/\n//\n// All public methods have been removed except the following:\n// new BigInteger(a, b) (only radix 2, 4, 8, 16 and 32 supported)\n// toString (only radix 2, 4, 8, 16 and 32 supported)\n// negate\n// abs\n// compareTo\n// bitLength\n// mod\n// equals\n// add\n// subtract\n// multiply\n// divide\n// modPow\n\nexport default BigInteger;\n\n/*\n * Copyright (c) 2003-2005 Tom Wu\n * All Rights Reserved.\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS-IS\" AND WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY\n * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.\n *\n * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,\n * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER\n * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF\n * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT\n * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n *\n * In addition, the following condition applies:\n *\n * All redistributions must retain an intact copy of this copyright notice\n * and disclaimer.\n */\n\n// (public) Constructor\nfunction BigInteger(a, b) {\n if (a != null) this.fromString(a, b);\n}\n\n// return new, unset BigInteger\nfunction nbi() {\n return new BigInteger(null);\n}\n\n// am: Compute w_j += (x*this_i), propagate carries,\n// c is initial carry, returns final carry.\n// c < 3*dvalue, x < 2*dvalue, this_i < dvalue\n// We need to select the fastest one that works in this environment.\n// am1: use a single mult and divide to get the high bits,\n// max digit bits should be 26 because\n// max internal value = 2*dvalue^2-2*dvalue (< 2^53)\nfunction am1(i, x, w, j, c, n) {\n while (--n >= 0) {\n var v = x * this[i++] + w[j] + c;\n c = Math.floor(v / 0x4000000);\n w[j++] = v & 0x3ffffff;\n }\n return c;\n}\n\nBigInteger.prototype.am = am1;\n\n// Bits per digit\nvar dbits = 26;\n\nBigInteger.prototype.DB = dbits;\nBigInteger.prototype.DM = (1 << dbits) - 1;\nBigInteger.prototype.DV = 1 << dbits;\n\nvar BI_FP = 52;\nBigInteger.prototype.FV = Math.pow(2, BI_FP);\nBigInteger.prototype.F1 = BI_FP - dbits;\nBigInteger.prototype.F2 = 2 * dbits - BI_FP;\n\n// Digit conversions\nvar BI_RM = \"0123456789abcdefghijklmnopqrstuvwxyz\";\nvar BI_RC = new Array();\nvar rr, vv;\nrr = \"0\".charCodeAt(0);\nfor (vv = 0; vv <= 9; ++vv)\n BI_RC[rr++] = vv;\nrr = \"a\".charCodeAt(0);\nfor (vv = 10; vv < 36; ++vv)\n BI_RC[rr++] = vv;\nrr = \"A\".charCodeAt(0);\nfor (vv = 10; vv < 36; ++vv)\n BI_RC[rr++] = vv;\n\nfunction int2char(n) {\n return BI_RM.charAt(n);\n}\nfunction intAt(s, i) {\n var c = BI_RC[s.charCodeAt(i)];\n return c == null ? -1 : c;\n}\n\n// (protected) copy this to r\nfunction bnpCopyTo(r) {\n for (var i = this.t - 1; i >= 0; --i)\n r[i] = this[i];\n r.t = this.t;\n r.s = this.s;\n}\n\n// (protected) set from integer value x, -DV <= x < DV\nfunction bnpFromInt(x) {\n this.t = 1;\n this.s = x < 0 ? -1 : 0;\n if (x > 0) this[0] = x;\n else if (x < -1) this[0] = x + this.DV;\n else this.t = 0;\n}\n\n// return bigint initialized to value\nfunction nbv(i) {\n var r = nbi();\n\n r.fromInt(i);\n\n return r;\n}\n\n// (protected) set from string and radix\nfunction bnpFromString(s, b) {\n var k;\n if (b == 16) k = 4;\n else if (b == 8) k = 3;\n else if (b == 2) k = 1;\n else if (b == 32) k = 5;\n else if (b == 4) k = 2;\n else throw new Error(\"Only radix 2, 4, 8, 16, 32 are supported\");\n this.t = 0;\n this.s = 0;\n var i = s.length, mi = false, sh = 0;\n while (--i >= 0) {\n var x = intAt(s, i);\n if (x < 0) {\n if (s.charAt(i) == \"-\") mi = true;\n continue;\n }\n mi = false;\n if (sh == 0) this[this.t++] = x;\n else if (sh + k > this.DB) {\n this[this.t - 1] |= (x & (1 << this.DB - sh) - 1) << sh;\n this[this.t++] = x >> this.DB - sh;\n } else this[this.t - 1] |= x << sh;\n sh += k;\n if (sh >= this.DB) sh -= this.DB;\n }\n this.clamp();\n if (mi) BigInteger.ZERO.subTo(this, this);\n}\n\n// (protected) clamp off excess high words\nfunction bnpClamp() {\n var c = this.s & this.DM;\n while (this.t > 0 && this[this.t - 1] == c)\n --this.t;\n}\n\n// (public) return string representation in given radix\nfunction bnToString(b) {\n if (this.s < 0) return \"-\" + this.negate().toString();\n var k;\n if (b == 16) k = 4;\n else if (b == 8) k = 3;\n else if (b == 2) k = 1;\n else if (b == 32) k = 5;\n else if (b == 4) k = 2;\n else throw new Error(\"Only radix 2, 4, 8, 16, 32 are supported\");\n var km = (1 << k) - 1, d, m = false, r = \"\", i = this.t;\n var p = this.DB - i * this.DB % k;\n if (i-- > 0) {\n if (p < this.DB && (d = this[i] >> p) > 0) {\n m = true;\n r = int2char(d);\n }\n while (i >= 0) {\n if (p < k) {\n d = (this[i] & (1 << p) - 1) << k - p;\n d |= this[--i] >> (p += this.DB - k);\n } else {\n d = this[i] >> (p -= k) & km;\n if (p <= 0) {\n p += this.DB;\n --i;\n }\n }\n if (d > 0) m = true;\n if (m) r += int2char(d);\n }\n }\n return m ? r : \"0\";\n}\n\n// (public) -this\nfunction bnNegate() {\n var r = nbi();\n\n BigInteger.ZERO.subTo(this, r);\n\n return r;\n}\n\n// (public) |this|\nfunction bnAbs() {\n return this.s < 0 ? this.negate() : this;\n}\n\n// (public) return + if this > a, - if this < a, 0 if equal\nfunction bnCompareTo(a) {\n var r = this.s - a.s;\n if (r != 0) return r;\n var i = this.t;\n r = i - a.t;\n if (r != 0) return this.s < 0 ? -r : r;\n while (--i >= 0)\n if ((r = this[i] - a[i]) != 0) return r;\n return 0;\n}\n\n// returns bit length of the integer x\nfunction nbits(x) {\n var r = 1, t;\n if ((t = x >>> 16) != 0) {\n x = t;\n r += 16;\n }\n if ((t = x >> 8) != 0) {\n x = t;\n r += 8;\n }\n if ((t = x >> 4) != 0) {\n x = t;\n r += 4;\n }\n if ((t = x >> 2) != 0) {\n x = t;\n r += 2;\n }\n if ((t = x >> 1) != 0) {\n x = t;\n r += 1;\n }\n return r;\n}\n\n// (public) return the number of bits in \"this\"\nfunction bnBitLength() {\n if (this.t <= 0) return 0;\n return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.DM);\n}\n\n// (protected) r = this << n*DB\nfunction bnpDLShiftTo(n, r) {\n var i;\n for (i = this.t - 1; i >= 0; --i)\n r[i + n] = this[i];\n for (i = n - 1; i >= 0; --i)\n r[i] = 0;\n r.t = this.t + n;\n r.s = this.s;\n}\n\n// (protected) r = this >> n*DB\nfunction bnpDRShiftTo(n, r) {\n for (var i = n; i < this.t; ++i)\n r[i - n] = this[i];\n r.t = Math.max(this.t - n, 0);\n r.s = this.s;\n}\n\n// (protected) r = this << n\nfunction bnpLShiftTo(n, r) {\n var bs = n % this.DB;\n var cbs = this.DB - bs;\n var bm = (1 << cbs) - 1;\n var ds = Math.floor(n / this.DB), c = this.s << bs & this.DM, i;\n for (i = this.t - 1; i >= 0; --i) {\n r[i + ds + 1] = this[i] >> cbs | c;\n c = (this[i] & bm) << bs;\n }\n for (i = ds - 1; i >= 0; --i)\n r[i] = 0;\n r[ds] = c;\n r.t = this.t + ds + 1;\n r.s = this.s;\n r.clamp();\n}\n\n// (protected) r = this >> n\nfunction bnpRShiftTo(n, r) {\n r.s = this.s;\n var ds = Math.floor(n / this.DB);\n if (ds >= this.t) {\n r.t = 0;\n return;\n }\n var bs = n % this.DB;\n var cbs = this.DB - bs;\n var bm = (1 << bs) - 1;\n r[0] = this[ds] >> bs;\n for (var i = ds + 1; i < this.t; ++i) {\n r[i - ds - 1] |= (this[i] & bm) << cbs;\n r[i - ds] = this[i] >> bs;\n }\n if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;\n r.t = this.t - ds;\n r.clamp();\n}\n\n// (protected) r = this - a\nfunction bnpSubTo(a, r) {\n var i = 0, c = 0, m = Math.min(a.t, this.t);\n while (i < m) {\n c += this[i] - a[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n if (a.t < this.t) {\n c -= a.s;\n while (i < this.t) {\n c += this[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n c += this.s;\n } else {\n c += this.s;\n while (i < a.t) {\n c -= a[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n c -= a.s;\n }\n r.s = c < 0 ? -1 : 0;\n if (c < -1) r[i++] = this.DV + c;\n else if (c > 0) r[i++] = c;\n r.t = i;\n r.clamp();\n}\n\n// (protected) r = this * a, r != this,a (HAC 14.12)\n// \"this\" should be the larger one if appropriate.\nfunction bnpMultiplyTo(a, r) {\n var x = this.abs(), y = a.abs();\n var i = x.t;\n r.t = i + y.t;\n while (--i >= 0)\n r[i] = 0;\n for (i = 0; i < y.t; ++i)\n r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);\n r.s = 0;\n r.clamp();\n if (this.s != a.s) BigInteger.ZERO.subTo(r, r);\n}\n\n// (protected) r = this^2, r != this (HAC 14.16)\nfunction bnpSquareTo(r) {\n var x = this.abs();\n var i = r.t = 2 * x.t;\n while (--i >= 0)\n r[i] = 0;\n for (i = 0; i < x.t - 1; ++i) {\n var c = x.am(i, x[i], r, 2 * i, 0, 1);\n if (\n (r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >=\n x.DV\n ) {\n r[i + x.t] -= x.DV;\n r[i + x.t + 1] = 1;\n }\n }\n if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);\n r.s = 0;\n r.clamp();\n}\n\n// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)\n// r != q, this != m. q or r may be null.\nfunction bnpDivRemTo(m, q, r) {\n var pm = m.abs();\n if (pm.t <= 0) return;\n var pt = this.abs();\n if (pt.t < pm.t) {\n if (q != null) q.fromInt(0);\n if (r != null) this.copyTo(r);\n return;\n }\n if (r == null) r = nbi();\n var y = nbi(), ts = this.s, ms = m.s;\n var nsh = this.DB - nbits(pm[pm.t - 1]);\n // normalize modulus\n if (nsh > 0) {\n pm.lShiftTo(nsh, y);\n pt.lShiftTo(nsh, r);\n } else {\n pm.copyTo(y);\n pt.copyTo(r);\n }\n var ys = y.t;\n var y0 = y[ys - 1];\n if (y0 == 0) return;\n var yt = y0 * (1 << this.F1) + (ys > 1 ? y[ys - 2] >> this.F2 : 0);\n var d1 = this.FV / yt, d2 = (1 << this.F1) / yt, e = 1 << this.F2;\n var i = r.t, j = i - ys, t = q == null ? nbi() : q;\n y.dlShiftTo(j, t);\n if (r.compareTo(t) >= 0) {\n r[r.t++] = 1;\n r.subTo(t, r);\n }\n BigInteger.ONE.dlShiftTo(ys, t);\n t.subTo(y, y);\n // \"negative\" y so we can replace sub with am later\n while (y.t < ys)\n y[y.t++] = 0;\n while (--j >= 0) {\n // Estimate quotient digit\n var qd = r[--i] == y0\n ? this.DM\n : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);\n if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) {\n // Try it out\n y.dlShiftTo(j, t);\n r.subTo(t, r);\n while (r[i] < --qd) r.subTo(t, r);\n }\n }\n if (q != null) {\n r.drShiftTo(ys, q);\n if (ts != ms) BigInteger.ZERO.subTo(q, q);\n }\n r.t = ys;\n r.clamp();\n if (nsh > 0) r.rShiftTo(nsh, r);\n // Denormalize remainder\n if (ts < 0) BigInteger.ZERO.subTo(r, r);\n}\n\n// (public) this mod a\nfunction bnMod(a) {\n var r = nbi();\n this.abs().divRemTo(a, null, r);\n if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);\n return r;\n}\n\n// (protected) return \"-1/this % 2^DB\"; useful for Mont. reduction\n// justification:\n// xy == 1 (mod m)\n// xy = 1+km\n// xy(2-xy) = (1+km)(1-km)\n// x[y(2-xy)] = 1-k^2m^2\n// x[y(2-xy)] == 1 (mod m^2)\n// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2\n// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.\n// JS multiply \"overflows\" differently from C/C++, so care is needed here.\nfunction bnpInvDigit() {\n if (this.t < 1) return 0;\n var x = this[0];\n if ((x & 1) == 0) return 0;\n var y = x & 3;\n // y == 1/x mod 2^2\n y = y * (2 - (x & 0xf) * y) & 0xf;\n // y == 1/x mod 2^4\n y = y * (2 - (x & 0xff) * y) & 0xff;\n // y == 1/x mod 2^8\n y = y * (2 - ((x & 0xffff) * y & 0xffff)) & 0xffff;\n // y == 1/x mod 2^16\n // last step - calculate inverse mod DV directly;\n // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints\n y = y * (2 - x * y % this.DV) % this.DV;\n // y == 1/x mod 2^dbits\n // we really want the negative inverse, and -DV < y < DV\n return y > 0 ? this.DV - y : -y;\n}\n\nfunction bnEquals(a) {\n return this.compareTo(a) == 0;\n}\n\n// (protected) r = this + a\nfunction bnpAddTo(a, r) {\n var i = 0, c = 0, m = Math.min(a.t, this.t);\n while (i < m) {\n c += this[i] + a[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n if (a.t < this.t) {\n c += a.s;\n while (i < this.t) {\n c += this[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n c += this.s;\n } else {\n c += this.s;\n while (i < a.t) {\n c += a[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n c += a.s;\n }\n r.s = c < 0 ? -1 : 0;\n if (c > 0) r[i++] = c;\n else if (c < -1) r[i++] = this.DV + c;\n r.t = i;\n r.clamp();\n}\n\n// (public) this + a\nfunction bnAdd(a) {\n var r = nbi();\n\n this.addTo(a, r);\n\n return r;\n}\n\n// (public) this - a\nfunction bnSubtract(a) {\n var r = nbi();\n\n this.subTo(a, r);\n\n return r;\n}\n\n// (public) this * a\nfunction bnMultiply(a) {\n var r = nbi();\n\n this.multiplyTo(a, r);\n\n return r;\n}\n\n// (public) this / a\nfunction bnDivide(a) {\n var r = nbi();\n\n this.divRemTo(a, r, null);\n\n return r;\n}\n\n// Montgomery reduction\nfunction Montgomery(m) {\n this.m = m;\n this.mp = m.invDigit();\n this.mpl = this.mp & 0x7fff;\n this.mph = this.mp >> 15;\n this.um = (1 << m.DB - 15) - 1;\n this.mt2 = 2 * m.t;\n}\n\n// xR mod m\nfunction montConvert(x) {\n var r = nbi();\n x.abs().dlShiftTo(this.m.t, r);\n r.divRemTo(this.m, null, r);\n if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);\n return r;\n}\n\n// x/R mod m\nfunction montRevert(x) {\n var r = nbi();\n x.copyTo(r);\n this.reduce(r);\n return r;\n}\n\n// x = x/R mod m (HAC 14.32)\nfunction montReduce(x) {\n while (x.t <= this.mt2)\n // pad x so am has enough room later\n x[x.t++] = 0;\n for (var i = 0; i < this.m.t; ++i) {\n // faster way of calculating u0 = x[i]*mp mod DV\n var j = x[i] & 0x7fff;\n var u0 = j * this.mpl +\n ((j * this.mph + (x[i] >> 15) * this.mpl & this.um) << 15) &\n x.DM;\n // use am to combine the multiply-shift-add into one call\n j = i + this.m.t;\n x[j] += this.m.am(0, u0, x, i, 0, this.m.t);\n // propagate carry\n while (x[j] >= x.DV) {\n x[j] -= x.DV;\n x[++j]++;\n }\n }\n x.clamp();\n x.drShiftTo(this.m.t, x);\n if (x.compareTo(this.m) >= 0) x.subTo(this.m, x);\n}\n\n// r = \"x^2/R mod m\"; x != r\nfunction montSqrTo(x, r) {\n x.squareTo(r);\n\n this.reduce(r);\n}\n\n// r = \"xy/R mod m\"; x,y != r\nfunction montMulTo(x, y, r) {\n x.multiplyTo(y, r);\n\n this.reduce(r);\n}\n\nMontgomery.prototype.convert = montConvert;\nMontgomery.prototype.revert = montRevert;\nMontgomery.prototype.reduce = montReduce;\nMontgomery.prototype.mulTo = montMulTo;\nMontgomery.prototype.sqrTo = montSqrTo;\n\n// (public) this^e % m (HAC 14.85)\nfunction bnModPow(e, m) {\n var i = e.bitLength(), k, r = nbv(1), z = new Montgomery(m);\n if (i <= 0) return r;\n else if (i < 18) k = 1;\n else if (i < 48) k = 3;\n else if (i < 144) k = 4;\n else if (i < 768) k = 5;\n else k = 6;\n\n // precomputation\n var g = new Array(), n = 3, k1 = k - 1, km = (1 << k) - 1;\n g[1] = z.convert(this);\n if (k > 1) {\n var g2 = nbi();\n z.sqrTo(g[1], g2);\n while (n <= km) {\n g[n] = nbi();\n z.mulTo(g2, g[n - 2], g[n]);\n n += 2;\n }\n }\n\n var j = e.t - 1, w, is1 = true, r2 = nbi(), t;\n i = nbits(e[j]) - 1;\n while (j >= 0) {\n if (i >= k1) w = e[j] >> i - k1 & km;\n else {\n w = (e[j] & (1 << i + 1) - 1) << k1 - i;\n if (j > 0) w |= e[j - 1] >> this.DB + i - k1;\n }\n\n n = k;\n while ((w & 1) == 0) {\n w >>= 1;\n --n;\n }\n if ((i -= n) < 0) {\n i += this.DB;\n --j;\n }\n if (is1) {\n // ret == 1, don't bother squaring or multiplying it\n g[w].copyTo(r);\n is1 = false;\n } else {\n while (n > 1) {\n z.sqrTo(r, r2);\n z.sqrTo(r2, r);\n n -= 2;\n }\n if (n > 0) z.sqrTo(r, r2);\n else {\n t = r;\n r = r2;\n r2 = t;\n }\n z.mulTo(r2, g[w], r);\n }\n\n while (j >= 0 && (e[j] & 1 << i) == 0) {\n z.sqrTo(r, r2);\n t = r;\n r = r2;\n r2 = t;\n if (--i < 0) {\n i = this.DB - 1;\n --j;\n }\n }\n }\n return z.revert(r);\n}\n\n// protected\nBigInteger.prototype.copyTo = bnpCopyTo;\nBigInteger.prototype.fromInt = bnpFromInt;\nBigInteger.prototype.fromString = bnpFromString;\nBigInteger.prototype.clamp = bnpClamp;\nBigInteger.prototype.dlShiftTo = bnpDLShiftTo;\nBigInteger.prototype.drShiftTo = bnpDRShiftTo;\nBigInteger.prototype.lShiftTo = bnpLShiftTo;\nBigInteger.prototype.rShiftTo = bnpRShiftTo;\nBigInteger.prototype.subTo = bnpSubTo;\nBigInteger.prototype.multiplyTo = bnpMultiplyTo;\nBigInteger.prototype.squareTo = bnpSquareTo;\nBigInteger.prototype.divRemTo = bnpDivRemTo;\nBigInteger.prototype.invDigit = bnpInvDigit;\nBigInteger.prototype.addTo = bnpAddTo;\n\n// public\nBigInteger.prototype.toString = bnToString;\nBigInteger.prototype.negate = bnNegate;\nBigInteger.prototype.abs = bnAbs;\nBigInteger.prototype.compareTo = bnCompareTo;\nBigInteger.prototype.bitLength = bnBitLength;\nBigInteger.prototype.mod = bnMod;\nBigInteger.prototype.equals = bnEquals;\nBigInteger.prototype.add = bnAdd;\nBigInteger.prototype.subtract = bnSubtract;\nBigInteger.prototype.multiply = bnMultiply;\nBigInteger.prototype.divide = bnDivide;\nBigInteger.prototype.modPow = bnModPow;\n\n// \"constants\"\nBigInteger.ZERO = nbv(0);\nBigInteger.ONE = nbv(1);\n\n\n\n\n// WEBPACK FOOTER //\n// ./src/BigInteger.js","/*\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { util } from 'aws-sdk/global';\n\n/** @class */\nexport default class CognitoAccessToken {\n /**\n * Constructs a new CognitoAccessToken object\n * @param {string=} AccessToken The JWT access token.\n */\n constructor({ AccessToken } = {}) {\n // Assign object\n this.jwtToken = AccessToken || '';\n }\n\n /**\n * @returns {string} the record's token.\n */\n getJwtToken() {\n return this.jwtToken;\n }\n\n /**\n * @returns {int} the token's expiration (exp member).\n */\n getExpiration() {\n const payload = this.jwtToken.split('.')[1];\n const expiration = JSON.parse(util.base64.decode(payload).toString('utf8'));\n return expiration.exp;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoAccessToken.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { util } from 'aws-sdk/global';\n\n/** @class */\nexport default class CognitoIdToken {\n /**\n * Constructs a new CognitoIdToken object\n * @param {string=} IdToken The JWT Id token\n */\n constructor({ IdToken } = {}) {\n // Assign object\n this.jwtToken = IdToken || '';\n }\n\n /**\n * @returns {string} the record's token.\n */\n getJwtToken() {\n return this.jwtToken;\n }\n\n /**\n * @returns {int} the token's expiration (exp member).\n */\n getExpiration() {\n const payload = this.jwtToken.split('.')[1];\n const expiration = JSON.parse(util.base64.decode(payload).toString('utf8'));\n return expiration.exp;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoIdToken.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @class */\nexport default class CognitoRefreshToken {\n /**\n * Constructs a new CognitoRefreshToken object\n * @param {string=} RefreshToken The JWT refresh token.\n */\n constructor({ RefreshToken } = {}) {\n // Assign object\n this.token = RefreshToken || '';\n }\n\n /**\n * @returns {string} the record's token.\n */\n getToken() {\n return this.token;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoRefreshToken.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { util } from 'aws-sdk/global';\n\nimport BigInteger from './BigInteger';\nimport AuthenticationHelper from './AuthenticationHelper';\nimport CognitoAccessToken from './CognitoAccessToken';\nimport CognitoIdToken from './CognitoIdToken';\nimport CognitoRefreshToken from './CognitoRefreshToken';\nimport CognitoUserSession from './CognitoUserSession';\nimport DateHelper from './DateHelper';\nimport CognitoUserAttribute from './CognitoUserAttribute';\nimport StorageHelper from './StorageHelper';\n\n/**\n * @callback nodeCallback\n * @template T result\n * @param {*} err The operation failure reason, or null.\n * @param {T} result The operation result.\n */\n\n/**\n * @callback onFailure\n * @param {*} err Failure reason.\n */\n\n/**\n * @callback onSuccess\n * @template T result\n * @param {T} result The operation result.\n */\n\n/**\n * @callback mfaRequired\n * @param {*} details MFA challenge details.\n */\n\n/**\n * @callback customChallenge\n * @param {*} details Custom challenge details.\n */\n\n/**\n * @callback inputVerificationCode\n * @param {*} data Server response.\n */\n\n/**\n * @callback authSuccess\n * @param {CognitoUserSession} session The new session.\n * @param {bool=} userConfirmationNecessary User must be confirmed.\n */\n\n\n/** @class */\nexport default class CognitoUser {\n /**\n * Constructs a new CognitoUser object\n * @param {object} data Creation options\n * @param {string} data.Username The user's username.\n * @param {CognitoUserPool} data.Pool Pool containing the user.\n * @param {object} data.Storage Optional storage object.\n */\n constructor(data) {\n if (data == null || data.Username == null || data.Pool == null) {\n throw new Error('Username and pool information are required.');\n }\n\n this.username = data.Username || '';\n this.pool = data.Pool;\n this.Session = null;\n\n this.client = data.Pool.client;\n\n this.signInUserSession = null;\n this.authenticationFlowType = 'USER_SRP_AUTH';\n\n this.storage = data.Storage || new StorageHelper().getStorage();\n }\n\n /**\n * @returns {CognitoUserSession} the current session for this user\n */\n getSignInUserSession() {\n return this.signInUserSession;\n }\n\n /**\n * @returns {string} the user's username\n */\n getUsername() {\n return this.username;\n }\n\n /**\n * @returns {String} the authentication flow type\n */\n getAuthenticationFlowType() {\n return this.authenticationFlowType;\n }\n\n /**\n * sets authentication flow type\n * @param {string} authenticationFlowType New value.\n * @returns {void}\n */\n setAuthenticationFlowType(authenticationFlowType) {\n this.authenticationFlowType = authenticationFlowType;\n }\n\n /**\n * This is used for authenticating the user. it calls the AuthenticationHelper for SRP related\n * stuff\n * @param {AuthenticationDetails} authDetails Contains the authentication data\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {newPasswordRequired} callback.newPasswordRequired new\n * password and any required attributes are required to continue\n * @param {mfaRequired} callback.mfaRequired MFA code\n * required to continue.\n * @param {customChallenge} callback.customChallenge Custom challenge\n * response required to continue.\n * @param {authSuccess} callback.onSuccess Called on success with the new session.\n * @returns {void}\n */\n authenticateUser(authDetails, callback) {\n const authenticationHelper = new AuthenticationHelper(\n this.pool.getUserPoolId().split('_')[1]);\n const dateHelper = new DateHelper();\n\n let serverBValue;\n let salt;\n const authParameters = {};\n\n if (this.deviceKey != null) {\n authParameters.DEVICE_KEY = this.deviceKey;\n }\n\n authParameters.USERNAME = this.username;\n authParameters.SRP_A = authenticationHelper.getLargeAValue().toString(16);\n\n if (this.authenticationFlowType === 'CUSTOM_AUTH') {\n authParameters.CHALLENGE_NAME = 'SRP_A';\n }\n\n this.client.makeUnauthenticatedRequest('initiateAuth', {\n AuthFlow: this.authenticationFlowType,\n ClientId: this.pool.getClientId(),\n AuthParameters: authParameters,\n ClientMetadata: authDetails.getValidationData(),\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n\n const challengeParameters = data.ChallengeParameters;\n\n this.username = challengeParameters.USER_ID_FOR_SRP;\n serverBValue = new BigInteger(challengeParameters.SRP_B, 16);\n salt = new BigInteger(challengeParameters.SALT, 16);\n this.getCachedDeviceKeyAndPassword();\n\n const hkdf = authenticationHelper.getPasswordAuthenticationKey(\n this.username,\n authDetails.getPassword(),\n serverBValue,\n salt);\n\n const dateNow = dateHelper.getNowString();\n\n const signatureString = util.crypto.hmac(hkdf, util.buffer.concat([\n new util.Buffer(this.pool.getUserPoolId().split('_')[1], 'utf8'),\n new util.Buffer(this.username, 'utf8'),\n new util.Buffer(challengeParameters.SECRET_BLOCK, 'base64'),\n new util.Buffer(dateNow, 'utf8'),\n ]), 'base64', 'sha256');\n\n const challengeResponses = {};\n\n challengeResponses.USERNAME = this.username;\n challengeResponses.PASSWORD_CLAIM_SECRET_BLOCK = challengeParameters.SECRET_BLOCK;\n challengeResponses.TIMESTAMP = dateNow;\n challengeResponses.PASSWORD_CLAIM_SIGNATURE = signatureString;\n\n if (this.deviceKey != null) {\n challengeResponses.DEVICE_KEY = this.deviceKey;\n }\n\n const respondToAuthChallenge = (challenge, challengeCallback) =>\n this.client.makeUnauthenticatedRequest('respondToAuthChallenge', challenge,\n (errChallenge, dataChallenge) => {\n if (errChallenge && errChallenge.code === 'ResourceNotFoundException' &&\n errChallenge.message.toLowerCase().indexOf('device') !== -1) {\n challengeResponses.DEVICE_KEY = null;\n this.deviceKey = null;\n this.randomPassword = null;\n this.deviceGroupKey = null;\n this.clearCachedDeviceKeyAndPassword();\n return respondToAuthChallenge(challenge, challengeCallback);\n }\n return challengeCallback(errChallenge, dataChallenge);\n });\n\n respondToAuthChallenge({\n ChallengeName: 'PASSWORD_VERIFIER',\n ClientId: this.pool.getClientId(),\n ChallengeResponses: challengeResponses,\n Session: data.Session,\n }, (errAuthenticate, dataAuthenticate) => {\n if (errAuthenticate) {\n return callback.onFailure(errAuthenticate);\n }\n\n const challengeName = dataAuthenticate.ChallengeName;\n if (challengeName === 'NEW_PASSWORD_REQUIRED') {\n this.Session = dataAuthenticate.Session;\n let userAttributes = null;\n let rawRequiredAttributes = null;\n const requiredAttributes = [];\n const userAttributesPrefix = authenticationHelper\n .getNewPasswordRequiredChallengeUserAttributePrefix();\n\n if (dataAuthenticate.ChallengeParameters) {\n userAttributes = JSON.parse(\n dataAuthenticate.ChallengeParameters.userAttributes);\n rawRequiredAttributes = JSON.parse(\n dataAuthenticate.ChallengeParameters.requiredAttributes);\n }\n\n if (rawRequiredAttributes) {\n for (let i = 0; i < rawRequiredAttributes.length; i++) {\n requiredAttributes[i] = rawRequiredAttributes[i].substr(userAttributesPrefix.length);\n }\n }\n return callback.newPasswordRequired(userAttributes, requiredAttributes);\n }\n return this.authenticateUserInternal(dataAuthenticate, authenticationHelper, callback);\n });\n return undefined;\n });\n }\n\n /**\n * PRIVATE ONLY: This is an internal only method and should not\n * be directly called by the consumers.\n * @param {object} dataAuthenticate authentication data\n * @param {object} authenticationHelper helper created\n * @param {callback} callback passed on from caller\n * @returns {void}\n */\n authenticateUserInternal(dataAuthenticate, authenticationHelper, callback) {\n const challengeName = dataAuthenticate.ChallengeName;\n const challengeParameters = dataAuthenticate.ChallengeParameters;\n\n if (challengeName === 'SMS_MFA') {\n this.Session = dataAuthenticate.Session;\n return callback.mfaRequired(challengeName, challengeParameters);\n }\n\n if (challengeName === 'CUSTOM_CHALLENGE') {\n this.Session = dataAuthenticate.Session;\n return callback.customChallenge(challengeParameters);\n }\n\n if (challengeName === 'DEVICE_SRP_AUTH') {\n this.getDeviceResponse(callback);\n return undefined;\n }\n\n this.signInUserSession = this.getCognitoUserSession(dataAuthenticate.AuthenticationResult);\n this.cacheTokens();\n\n const newDeviceMetadata = dataAuthenticate.AuthenticationResult.NewDeviceMetadata;\n if (newDeviceMetadata == null) {\n return callback.onSuccess(this.signInUserSession);\n }\n\n authenticationHelper.generateHashDevice(\n dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,\n dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey);\n\n const deviceSecretVerifierConfig = {\n Salt: new util.Buffer(\n authenticationHelper.getSaltDevices(), 'hex'\n ).toString('base64'),\n PasswordVerifier: new util.Buffer(\n authenticationHelper.getVerifierDevices(), 'hex'\n ).toString('base64'),\n };\n\n this.verifierDevices = deviceSecretVerifierConfig.PasswordVerifier;\n this.deviceGroupKey = newDeviceMetadata.DeviceGroupKey;\n this.randomPassword = authenticationHelper.getRandomPassword();\n\n this.client.makeUnauthenticatedRequest('confirmDevice', {\n DeviceKey: newDeviceMetadata.DeviceKey,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n DeviceSecretVerifierConfig: deviceSecretVerifierConfig,\n DeviceName: navigator.userAgent,\n }, (errConfirm, dataConfirm) => {\n if (errConfirm) {\n return callback.onFailure(errConfirm);\n }\n\n this.deviceKey = dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey;\n this.cacheDeviceKeyAndPassword();\n if (dataConfirm.UserConfirmationNecessary === true) {\n return callback.onSuccess(\n this.signInUserSession, dataConfirm.UserConfirmationNecessary);\n }\n return callback.onSuccess(this.signInUserSession);\n });\n return undefined;\n }\n\n /**\n * This method is user to complete the NEW_PASSWORD_REQUIRED challenge.\n * Pass the new password with any new user attributes to be updated.\n * User attribute keys must be of format userAttributes..\n * @param {string} newPassword new password for this user\n * @param {object} requiredAttributeData map with values for all required attributes\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {mfaRequired} callback.mfaRequired MFA code required to continue.\n * @param {customChallenge} callback.customChallenge Custom challenge\n * response required to continue.\n * @param {authSuccess} callback.onSuccess Called on success with the new session.\n * @returns {void}\n */\n completeNewPasswordChallenge(newPassword, requiredAttributeData, callback) {\n if (!newPassword) {\n return callback.onFailure(new Error('New password is required.'));\n }\n const authenticationHelper = new AuthenticationHelper(\n this.pool.getUserPoolId().split('_')[1]);\n const userAttributesPrefix = authenticationHelper\n .getNewPasswordRequiredChallengeUserAttributePrefix();\n\n const finalUserAttributes = {};\n if (requiredAttributeData) {\n Object.keys(requiredAttributeData).forEach((key) => {\n finalUserAttributes[userAttributesPrefix + key] = requiredAttributeData[key];\n });\n }\n\n finalUserAttributes.NEW_PASSWORD = newPassword;\n finalUserAttributes.USERNAME = this.username;\n this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n ChallengeName: 'NEW_PASSWORD_REQUIRED',\n ClientId: this.pool.getClientId(),\n ChallengeResponses: finalUserAttributes,\n Session: this.Session,\n }, (errAuthenticate, dataAuthenticate) => {\n if (errAuthenticate) {\n return callback.onFailure(errAuthenticate);\n }\n return this.authenticateUserInternal(dataAuthenticate, authenticationHelper, callback);\n });\n return undefined;\n }\n\n /**\n * This is used to get a session using device authentication. It is called at the end of user\n * authentication\n *\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {authSuccess} callback.onSuccess Called on success with the new session.\n * @returns {void}\n * @private\n */\n getDeviceResponse(callback) {\n const authenticationHelper = new AuthenticationHelper(\n this.deviceGroupKey);\n const dateHelper = new DateHelper();\n\n const authParameters = {};\n\n authParameters.USERNAME = this.username;\n authParameters.DEVICE_KEY = this.deviceKey;\n authParameters.SRP_A = authenticationHelper.getLargeAValue().toString(16);\n\n this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n ChallengeName: 'DEVICE_SRP_AUTH',\n ClientId: this.pool.getClientId(),\n ChallengeResponses: authParameters,\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n\n const challengeParameters = data.ChallengeParameters;\n\n const serverBValue = new BigInteger(challengeParameters.SRP_B, 16);\n const salt = new BigInteger(challengeParameters.SALT, 16);\n\n const hkdf = authenticationHelper.getPasswordAuthenticationKey(\n this.deviceKey,\n this.randomPassword,\n serverBValue,\n salt);\n\n const dateNow = dateHelper.getNowString();\n\n const signatureString = util.crypto.hmac(hkdf, util.buffer.concat([\n new util.Buffer(this.deviceGroupKey, 'utf8'),\n new util.Buffer(this.deviceKey, 'utf8'),\n new util.Buffer(challengeParameters.SECRET_BLOCK, 'base64'),\n new util.Buffer(dateNow, 'utf8'),\n ]), 'base64', 'sha256');\n\n const challengeResponses = {};\n\n challengeResponses.USERNAME = this.username;\n challengeResponses.PASSWORD_CLAIM_SECRET_BLOCK = challengeParameters.SECRET_BLOCK;\n challengeResponses.TIMESTAMP = dateNow;\n challengeResponses.PASSWORD_CLAIM_SIGNATURE = signatureString;\n challengeResponses.DEVICE_KEY = this.deviceKey;\n\n this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n ChallengeName: 'DEVICE_PASSWORD_VERIFIER',\n ClientId: this.pool.getClientId(),\n ChallengeResponses: challengeResponses,\n Session: data.Session,\n }, (errAuthenticate, dataAuthenticate) => {\n if (errAuthenticate) {\n return callback.onFailure(errAuthenticate);\n }\n\n this.signInUserSession = this.getCognitoUserSession(dataAuthenticate.AuthenticationResult);\n this.cacheTokens();\n\n return callback.onSuccess(this.signInUserSession);\n });\n return undefined;\n });\n }\n\n /**\n * This is used for a certain user to confirm the registration by using a confirmation code\n * @param {string} confirmationCode Code entered by user.\n * @param {bool} forceAliasCreation Allow migrating from an existing email / phone number.\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n confirmRegistration(confirmationCode, forceAliasCreation, callback) {\n this.client.makeUnauthenticatedRequest('confirmSignUp', {\n ClientId: this.pool.getClientId(),\n ConfirmationCode: confirmationCode,\n Username: this.username,\n ForceAliasCreation: forceAliasCreation,\n }, err => {\n if (err) {\n return callback(err, null);\n }\n return callback(null, 'SUCCESS');\n });\n }\n\n /**\n * This is used by the user once he has the responses to a custom challenge\n * @param {string} answerChallenge The custom challange answer.\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {customChallenge} callback.customChallenge\n * Custom challenge response required to continue.\n * @param {authSuccess} callback.onSuccess Called on success with the new session.\n * @returns {void}\n */\n sendCustomChallengeAnswer(answerChallenge, callback) {\n const challengeResponses = {};\n challengeResponses.USERNAME = this.username;\n challengeResponses.ANSWER = answerChallenge;\n\n this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n ChallengeName: 'CUSTOM_CHALLENGE',\n ChallengeResponses: challengeResponses,\n ClientId: this.pool.getClientId(),\n Session: this.Session,\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n\n const challengeName = data.ChallengeName;\n\n if (challengeName === 'CUSTOM_CHALLENGE') {\n this.Session = data.Session;\n return callback.customChallenge(data.ChallengeParameters);\n }\n\n this.signInUserSession = this.getCognitoUserSession(data.AuthenticationResult);\n this.cacheTokens();\n return callback.onSuccess(this.signInUserSession);\n });\n }\n\n /**\n * This is used by the user once he has an MFA code\n * @param {string} confirmationCode The MFA code entered by the user.\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {authSuccess} callback.onSuccess Called on success with the new session.\n * @returns {void}\n */\n sendMFACode(confirmationCode, callback) {\n const challengeResponses = {};\n challengeResponses.USERNAME = this.username;\n challengeResponses.SMS_MFA_CODE = confirmationCode;\n\n if (this.deviceKey != null) {\n challengeResponses.DEVICE_KEY = this.deviceKey;\n }\n\n this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n ChallengeName: 'SMS_MFA',\n ChallengeResponses: challengeResponses,\n ClientId: this.pool.getClientId(),\n Session: this.Session,\n }, (err, dataAuthenticate) => {\n if (err) {\n return callback.onFailure(err);\n }\n\n const challengeName = dataAuthenticate.ChallengeName;\n\n if (challengeName === 'DEVICE_SRP_AUTH') {\n this.getDeviceResponse(callback);\n return undefined;\n }\n\n this.signInUserSession = this.getCognitoUserSession(dataAuthenticate.AuthenticationResult);\n this.cacheTokens();\n\n if (dataAuthenticate.AuthenticationResult.NewDeviceMetadata == null) {\n return callback.onSuccess(this.signInUserSession);\n }\n\n const authenticationHelper = new AuthenticationHelper(\n this.pool.getUserPoolId().split('_')[1]);\n authenticationHelper.generateHashDevice(\n dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,\n dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey);\n\n const deviceSecretVerifierConfig = {\n Salt: new util.Buffer(\n authenticationHelper.getSaltDevices(), 'hex'\n ).toString('base64'),\n PasswordVerifier: new util.Buffer(\n authenticationHelper.getVerifierDevices(), 'hex'\n ).toString('base64'),\n };\n\n this.verifierDevices = deviceSecretVerifierConfig.PasswordVerifier;\n this.deviceGroupKey = dataAuthenticate.AuthenticationResult\n .NewDeviceMetadata.DeviceGroupKey;\n this.randomPassword = authenticationHelper.getRandomPassword();\n\n this.client.makeUnauthenticatedRequest('confirmDevice', {\n DeviceKey: dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n DeviceSecretVerifierConfig: deviceSecretVerifierConfig,\n DeviceName: navigator.userAgent,\n }, (errConfirm, dataConfirm) => {\n if (errConfirm) {\n return callback.onFailure(errConfirm);\n }\n\n this.deviceKey = dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey;\n this.cacheDeviceKeyAndPassword();\n if (dataConfirm.UserConfirmationNecessary === true) {\n return callback.onSuccess(\n this.signInUserSession,\n dataConfirm.UserConfirmationNecessary);\n }\n return callback.onSuccess(this.signInUserSession);\n });\n return undefined;\n });\n }\n\n /**\n * This is used by an authenticated user to change the current password\n * @param {string} oldUserPassword The current password.\n * @param {string} newUserPassword The requested new password.\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n changePassword(oldUserPassword, newUserPassword, callback) {\n if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n this.client.makeUnauthenticatedRequest('changePassword', {\n PreviousPassword: oldUserPassword,\n ProposedPassword: newUserPassword,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback(err, null);\n }\n return callback(null, 'SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used by an authenticated user to enable MFA for himself\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n enableMFA(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n const mfaOptions = [];\n const mfaEnabled = {\n DeliveryMedium: 'SMS',\n AttributeName: 'phone_number',\n };\n mfaOptions.push(mfaEnabled);\n\n this.client.makeUnauthenticatedRequest('setUserSettings', {\n MFAOptions: mfaOptions,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback(err, null);\n }\n return callback(null, 'SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used by an authenticated user to disable MFA for himself\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n disableMFA(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n const mfaOptions = [];\n\n this.client.makeUnauthenticatedRequest('setUserSettings', {\n MFAOptions: mfaOptions,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback(err, null);\n }\n return callback(null, 'SUCCESS');\n });\n return undefined;\n }\n\n\n /**\n * This is used by an authenticated user to delete himself\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n deleteUser(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n this.client.makeUnauthenticatedRequest('deleteUser', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback(err, null);\n }\n this.clearCachedTokens();\n return callback(null, 'SUCCESS');\n });\n return undefined;\n }\n\n /**\n * @typedef {CognitoUserAttribute | { Name:string, Value:string }} AttributeArg\n */\n /**\n * This is used by an authenticated user to change a list of attributes\n * @param {AttributeArg[]} attributes A list of the new user attributes.\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n updateAttributes(attributes, callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n this.client.makeUnauthenticatedRequest('updateUserAttributes', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n UserAttributes: attributes,\n }, err => {\n if (err) {\n return callback(err, null);\n }\n return callback(null, 'SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used by an authenticated user to get a list of attributes\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n getUserAttributes(callback) {\n if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n this.client.makeUnauthenticatedRequest('getUser', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, (err, userData) => {\n if (err) {\n return callback(err, null);\n }\n\n const attributeList = [];\n\n for (let i = 0; i < userData.UserAttributes.length; i++) {\n const attribute = {\n Name: userData.UserAttributes[i].Name,\n Value: userData.UserAttributes[i].Value,\n };\n const userAttribute = new CognitoUserAttribute(attribute);\n attributeList.push(userAttribute);\n }\n\n return callback(null, attributeList);\n });\n return undefined;\n }\n\n /**\n * This is used by an authenticated user to get the MFAOptions\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n getMFAOptions(callback) {\n if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n this.client.makeUnauthenticatedRequest('getUser', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, (err, userData) => {\n if (err) {\n return callback(err, null);\n }\n\n return callback(null, userData.MFAOptions);\n });\n return undefined;\n }\n\n /**\n * This is used by an authenticated user to delete a list of attributes\n * @param {string[]} attributeList Names of the attributes to delete.\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n deleteAttributes(attributeList, callback) {\n if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n this.client.makeUnauthenticatedRequest('deleteUserAttributes', {\n UserAttributeNames: attributeList,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback(err, null);\n }\n return callback(null, 'SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used by a user to resend a confirmation code\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n resendConfirmationCode(callback) {\n this.client.makeUnauthenticatedRequest('resendConfirmationCode', {\n ClientId: this.pool.getClientId(),\n Username: this.username,\n }, err => {\n if (err, result) {\n return callback(err, null);\n }\n return callback(null, result);\n });\n }\n\n /**\n * This is used to get a session, either from the session object\n * or from the local storage, or by using a refresh token\n *\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n getSession(callback) {\n if (this.username == null) {\n return callback(new Error('Username is null. Cannot retrieve a new session'), null);\n }\n\n if (this.signInUserSession != null && this.signInUserSession.isValid()) {\n return callback(null, this.signInUserSession);\n }\n\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${this.username}`;\n const idTokenKey = `${keyPrefix}.idToken`;\n const accessTokenKey = `${keyPrefix}.accessToken`;\n const refreshTokenKey = `${keyPrefix}.refreshToken`;\n\n if (this.storage.getItem(idTokenKey)) {\n const idToken = new CognitoIdToken({\n IdToken: this.storage.getItem(idTokenKey),\n });\n const accessToken = new CognitoAccessToken({\n AccessToken: this.storage.getItem(accessTokenKey),\n });\n const refreshToken = new CognitoRefreshToken({\n RefreshToken: this.storage.getItem(refreshTokenKey),\n });\n\n const sessionData = {\n IdToken: idToken,\n AccessToken: accessToken,\n RefreshToken: refreshToken,\n };\n const cachedSession = new CognitoUserSession(sessionData);\n if (cachedSession.isValid()) {\n this.signInUserSession = cachedSession;\n return callback(null, this.signInUserSession);\n }\n\n if (refreshToken.getToken() == null) {\n return callback(new Error('Cannot retrieve a new session. Please authenticate.'), null);\n }\n\n this.refreshSession(refreshToken, callback);\n } else {\n callback(new Error('Local storage is missing an ID Token, Please authenticate'), null);\n }\n\n return undefined;\n }\n\n\n /**\n * This uses the refreshToken to retrieve a new session\n * @param {CognitoRefreshToken} refreshToken A previous session's refresh token.\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n refreshSession(refreshToken, callback) {\n const authParameters = {};\n authParameters.REFRESH_TOKEN = refreshToken.getToken();\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}`;\n const lastUserKey = `${keyPrefix}.LastAuthUser`;\n\n if (this.storage.getItem(lastUserKey)) {\n this.username = this.storage.getItem(lastUserKey);\n const deviceKeyKey = `${keyPrefix}.${this.username}.deviceKey`;\n this.deviceKey = this.storage.getItem(deviceKeyKey);\n authParameters.DEVICE_KEY = this.deviceKey;\n }\n\n this.client.makeUnauthenticatedRequest('initiateAuth', {\n ClientId: this.pool.getClientId(),\n AuthFlow: 'REFRESH_TOKEN_AUTH',\n AuthParameters: authParameters,\n }, (err, authResult) => {\n if (err) {\n if (err.code === 'NotAuthorizedException') {\n this.clearCachedTokens();\n }\n return callback(err, null);\n }\n if (authResult) {\n const authenticationResult = authResult.AuthenticationResult;\n if (!Object.prototype.hasOwnProperty.call(authenticationResult, 'RefreshToken')) {\n authenticationResult.RefreshToken = refreshToken.getToken();\n }\n this.signInUserSession = this.getCognitoUserSession(authenticationResult);\n this.cacheTokens();\n return callback(null, this.signInUserSession);\n }\n return undefined;\n });\n }\n\n /**\n * This is used to save the session tokens to local storage\n * @returns {void}\n */\n cacheTokens() {\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}`;\n const idTokenKey = `${keyPrefix}.${this.username}.idToken`;\n const accessTokenKey = `${keyPrefix}.${this.username}.accessToken`;\n const refreshTokenKey = `${keyPrefix}.${this.username}.refreshToken`;\n const lastUserKey = `${keyPrefix}.LastAuthUser`;\n\n this.storage.setItem(idTokenKey, this.signInUserSession.getIdToken().getJwtToken());\n this.storage.setItem(accessTokenKey, this.signInUserSession.getAccessToken().getJwtToken());\n this.storage.setItem(refreshTokenKey, this.signInUserSession.getRefreshToken().getToken());\n this.storage.setItem(lastUserKey, this.username);\n }\n\n /**\n * This is used to cache the device key and device group and device password\n * @returns {void}\n */\n cacheDeviceKeyAndPassword() {\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${this.username}`;\n const deviceKeyKey = `${keyPrefix}.deviceKey`;\n const randomPasswordKey = `${keyPrefix}.randomPasswordKey`;\n const deviceGroupKeyKey = `${keyPrefix}.deviceGroupKey`;\n\n this.storage.setItem(deviceKeyKey, this.deviceKey);\n this.storage.setItem(randomPasswordKey, this.randomPassword);\n this.storage.setItem(deviceGroupKeyKey, this.deviceGroupKey);\n }\n\n /**\n * This is used to get current device key and device group and device password\n * @returns {void}\n */\n getCachedDeviceKeyAndPassword() {\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${this.username}`;\n const deviceKeyKey = `${keyPrefix}.deviceKey`;\n const randomPasswordKey = `${keyPrefix}.randomPasswordKey`;\n const deviceGroupKeyKey = `${keyPrefix}.deviceGroupKey`;\n\n if (this.storage.getItem(deviceKeyKey)) {\n this.deviceKey = this.storage.getItem(deviceKeyKey);\n this.randomPassword = this.storage.getItem(randomPasswordKey);\n this.deviceGroupKey = this.storage.getItem(deviceGroupKeyKey);\n }\n }\n\n /**\n * This is used to clear the device key info from local storage\n * @returns {void}\n */\n clearCachedDeviceKeyAndPassword() {\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${this.username}`;\n const deviceKeyKey = `${keyPrefix}.deviceKey`;\n const randomPasswordKey = `${keyPrefix}.randomPasswordKey`;\n const deviceGroupKeyKey = `${keyPrefix}.deviceGroupKey`;\n\n this.storage.removeItem(deviceKeyKey);\n this.storage.removeItem(randomPasswordKey);\n this.storage.removeItem(deviceGroupKeyKey);\n }\n\n /**\n * This is used to clear the session tokens from local storage\n * @returns {void}\n */\n clearCachedTokens() {\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}`;\n const idTokenKey = `${keyPrefix}.${this.username}.idToken`;\n const accessTokenKey = `${keyPrefix}.${this.username}.accessToken`;\n const refreshTokenKey = `${keyPrefix}.${this.username}.refreshToken`;\n const lastUserKey = `${keyPrefix}.LastAuthUser`;\n\n this.storage.removeItem(idTokenKey);\n this.storage.removeItem(accessTokenKey);\n this.storage.removeItem(refreshTokenKey);\n this.storage.removeItem(lastUserKey);\n }\n\n /**\n * This is used to build a user session from tokens retrieved in the authentication result\n * @param {object} authResult Successful auth response from server.\n * @returns {CognitoUserSession} The new user session.\n * @private\n */\n getCognitoUserSession(authResult) {\n const idToken = new CognitoIdToken(authResult);\n const accessToken = new CognitoAccessToken(authResult);\n const refreshToken = new CognitoRefreshToken(authResult);\n\n const sessionData = {\n IdToken: idToken,\n AccessToken: accessToken,\n RefreshToken: refreshToken,\n };\n\n return new CognitoUserSession(sessionData);\n }\n\n /**\n * This is used to initiate a forgot password request\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {inputVerificationCode?} callback.inputVerificationCode\n * Optional callback raised instead of onSuccess with response data.\n * @param {onSuccess?} callback.onSuccess Called on success.\n * @returns {void}\n */\n forgotPassword(callback) {\n this.client.makeUnauthenticatedRequest('forgotPassword', {\n ClientId: this.pool.getClientId(),\n Username: this.username,\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n if (typeof callback.inputVerificationCode === 'function') {\n return callback.inputVerificationCode(data);\n }\n return callback.onSuccess();\n });\n }\n\n /**\n * This is used to confirm a new password using a confirmationCode\n * @param {string} confirmationCode Code entered by user.\n * @param {string} newPassword Confirm new password.\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n confirmPassword(confirmationCode, newPassword, callback) {\n this.client.makeUnauthenticatedRequest('confirmForgotPassword', {\n ClientId: this.pool.getClientId(),\n Username: this.username,\n ConfirmationCode: confirmationCode,\n Password: newPassword,\n }, err => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess();\n });\n }\n\n /**\n * This is used to initiate an attribute confirmation request\n * @param {string} attributeName User attribute that needs confirmation.\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {inputVerificationCode} callback.inputVerificationCode Called on success.\n * @returns {void}\n */\n getAttributeVerificationCode(attributeName, callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('getUserAttributeVerificationCode', {\n AttributeName: attributeName,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n if (typeof callback.inputVerificationCode === 'function') {\n return callback.inputVerificationCode(data);\n }\n return callback.onSuccess();\n });\n return undefined;\n }\n\n /**\n * This is used to confirm an attribute using a confirmation code\n * @param {string} attributeName Attribute being confirmed.\n * @param {string} confirmationCode Code entered by user.\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n verifyAttribute(attributeName, confirmationCode, callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('verifyUserAttribute', {\n AttributeName: attributeName,\n Code: confirmationCode,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess('SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used to get the device information using the current device key\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess<*>} callback.onSuccess Called on success with device data.\n * @returns {void}\n */\n getDevice(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('getDevice', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n DeviceKey: this.deviceKey,\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess(data);\n });\n return undefined;\n }\n\n /**\n * This is used to forget a specific device\n * @param {string} deviceKey Device key.\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n forgetSpecificDevice(deviceKey, callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('forgetDevice', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n DeviceKey: deviceKey,\n }, err => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess('SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used to forget the current device\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n forgetDevice(callback) {\n this.forgetSpecificDevice(this.deviceKey, {\n onFailure: callback.onFailure,\n onSuccess: result => {\n this.deviceKey = null;\n this.deviceGroupKey = null;\n this.randomPassword = null;\n this.clearCachedDeviceKeyAndPassword();\n return callback.onSuccess(result);\n },\n });\n }\n\n /**\n * This is used to set the device status as remembered\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n setDeviceStatusRemembered(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('updateDeviceStatus', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n DeviceKey: this.deviceKey,\n DeviceRememberedStatus: 'remembered',\n }, err => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess('SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used to set the device status as not remembered\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n setDeviceStatusNotRemembered(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('updateDeviceStatus', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n DeviceKey: this.deviceKey,\n DeviceRememberedStatus: 'not_remembered',\n }, err => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess('SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used to list all devices for a user\n *\n * @param {int} limit the number of devices returned in a call\n * @param {string} paginationToken the pagination token in case any was returned before\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess<*>} callback.onSuccess Called on success with device list.\n * @returns {void}\n */\n listDevices(limit, paginationToken, callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('listDevices', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n Limit: limit,\n PaginationToken: paginationToken,\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess(data);\n });\n return undefined;\n }\n\n /**\n * This is used to globally revoke all tokens issued to a user\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n globalSignOut(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('globalSignOut', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback.onFailure(err);\n }\n this.clearCachedTokens();\n return callback.onSuccess('SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used for the user to signOut of the application and clear the cached tokens.\n * @returns {void}\n */\n signOut() {\n this.signInUserSession = null;\n this.clearCachedTokens();\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoUser.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @class */\nexport default class CognitoUserAttribute {\n /**\n * Constructs a new CognitoUserAttribute object\n * @param {string=} Name The record's name\n * @param {string=} Value The record's value\n */\n constructor({ Name, Value } = {}) {\n this.Name = Name || '';\n this.Value = Value || '';\n }\n\n /**\n * @returns {string} the record's value.\n */\n getValue() {\n return this.Value;\n }\n\n /**\n * Sets the record's value.\n * @param {string} value The new value.\n * @returns {CognitoUserAttribute} The record for method chaining.\n */\n setValue(value) {\n this.Value = value;\n return this;\n }\n\n /**\n * @returns {string} the record's name.\n */\n getName() {\n return this.Name;\n }\n\n /**\n * Sets the record's name\n * @param {string} name The new name.\n * @returns {CognitoUserAttribute} The record for method chaining.\n */\n setName(name) {\n this.Name = name;\n return this;\n }\n\n /**\n * @returns {string} a string representation of the record.\n */\n toString() {\n return JSON.stringify(this);\n }\n\n /**\n * @returns {object} a flat object representing the record.\n */\n toJSON() {\n return {\n Name: this.Name,\n Value: this.Value,\n };\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoUserAttribute.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @class */\nexport default class CognitoUserSession {\n /**\n * Constructs a new CognitoUserSession object\n * @param {string} IdToken The session's Id token.\n * @param {string=} RefreshToken The session's refresh token.\n * @param {string} AccessToken The session's access token.\n */\n constructor({ IdToken, RefreshToken, AccessToken } = {}) {\n if (AccessToken == null || IdToken == null) {\n throw new Error('Id token and Access Token must be present.');\n }\n\n this.idToken = IdToken;\n this.refreshToken = RefreshToken;\n this.accessToken = AccessToken;\n }\n\n /**\n * @returns {CognitoIdToken} the session's Id token\n */\n getIdToken() {\n return this.idToken;\n }\n\n /**\n * @returns {CognitoRefreshToken} the session's refresh token\n */\n getRefreshToken() {\n return this.refreshToken;\n }\n\n /**\n * @returns {CognitoAccessToken} the session's access token\n */\n getAccessToken() {\n return this.accessToken;\n }\n\n /**\n * Checks to see if the session is still valid based on session expiry information found\n * in tokens and the current time\n * @returns {boolean} if the session is still valid\n */\n isValid() {\n const now = Math.floor(new Date() / 1000);\n\n return now < this.accessToken.getExpiration() && now < this.idToken.getExpiration();\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoUserSession.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst monthNames =\n ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\nconst weekNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];\n\n/** @class */\nexport default class DateHelper {\n /**\n * @returns {string} The current time in \"ddd MMM D HH:mm:ss UTC YYYY\" format.\n */\n getNowString() {\n const now = new Date();\n\n const weekDay = weekNames[now.getUTCDay()];\n const month = monthNames[now.getUTCMonth()];\n const day = now.getUTCDate();\n\n let hours = now.getUTCHours();\n if (hours < 10) {\n hours = `0${hours}`;\n }\n\n let minutes = now.getUTCMinutes();\n if (minutes < 10) {\n minutes = `0${minutes}`;\n }\n\n let seconds = now.getUTCSeconds();\n if (seconds < 10) {\n seconds = `0${seconds}`;\n }\n\n const year = now.getUTCFullYear();\n\n // ddd MMM D HH:mm:ss UTC YYYY\n const dateNow = `${weekDay} ${month} ${day} ${hours}:${minutes}:${seconds} UTC ${year}`;\n\n return dateNow;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/DateHelper.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nlet dataMemory = {};\n\n/** @class */\nclass MemoryStorage {\n\n /**\n * This is used to set a specific item in storage\n * @param {string} key - the key for the item\n * @param {object} value - the value\n * @returns {string} value that was set\n */\n static setItem(key, value) {\n dataMemory[key] = value;\n return dataMemory[key];\n }\n\n /**\n * This is used to get a specific key from storage\n * @param {string} key - the key for the item\n * This is used to clear the storage\n * @returns {string} the data item\n */\n static getItem(key) {\n return Object.prototype.hasOwnProperty.call(dataMemory, key) ? dataMemory[key] : undefined;\n }\n\n /**\n * This is used to remove an item from storage\n * @param {string} key - the key being set\n * @returns {string} value - value that was deleted\n */\n static removeItem(key) {\n return delete dataMemory[key];\n }\n\n /**\n * This is used to clear the storage\n * @returns {string} nothing\n */\n static clear() {\n dataMemory = {};\n return dataMemory;\n }\n}\n\n/** @class */\nexport default class StorageHelper {\n\n /**\n * This is used to get a storage object\n * @returns {object} the storage\n */\n constructor() {\n try {\n this.storageWindow = window.localStorage;\n this.storageWindow.setItem('aws.cognito.test-ls', 1);\n this.storageWindow.removeItem('aws.cognito.test-ls');\n } catch (exception) {\n this.storageWindow = MemoryStorage;\n }\n }\n\n /**\n * This is used to return the storage\n * @returns {object} the storage\n */\n getStorage() {\n return this.storageWindow;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/StorageHelper.js","module.exports = __WEBPACK_EXTERNAL_MODULE_12__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":[\"AWSCognito\",\"CognitoIdentityServiceProvider\"],\"commonjs2\":\"aws-sdk/clients/cognitoidentityserviceprovider\",\"commonjs\":\"aws-sdk/clients/cognitoidentityserviceprovider\",\"amd\":\"aws-sdk/clients/cognitoidentityserviceprovider\"}\n// module id = 12\n// module chunks = 0","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @class */\nexport default class AuthenticationDetails {\n /**\n * Constructs a new AuthenticationDetails object\n * @param {object=} data Creation options.\n * @param {string} data.Username User being authenticated.\n * @param {string} data.Password Plain-text password to authenticate with.\n * @param {(AttributeArg[])?} data.ValidationData Application extra metadata.\n */\n constructor(data) {\n const { ValidationData, Username, Password } = data || {};\n this.validationData = ValidationData || [];\n this.username = Username;\n this.password = Password;\n }\n\n /**\n * @returns {string} the record's username\n */\n getUsername() {\n return this.username;\n }\n\n /**\n * @returns {string} the record's password\n */\n getPassword() {\n return this.password;\n }\n\n /**\n * @returns {Array} the record's validationData\n */\n getValidationData() {\n return this.validationData;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/AuthenticationDetails.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport CognitoIdentityServiceProvider from 'aws-sdk/clients/cognitoidentityserviceprovider';\n\nimport CognitoUser from './CognitoUser';\nimport StorageHelper from './StorageHelper';\n\n/** @class */\nexport default class CognitoUserPool {\n /**\n * Constructs a new CognitoUserPool object\n * @param {object} data Creation options.\n * @param {string} data.UserPoolId Cognito user pool id.\n * @param {string} data.ClientId User pool application client id.\n * @param {object} data.Storage Optional storage object.\n */\n constructor(data) {\n const { UserPoolId, ClientId } = data || {};\n if (!UserPoolId || !ClientId) {\n throw new Error('Both UserPoolId and ClientId are required.');\n }\n if (!/^[\\w-]+_.+$/.test(UserPoolId)) {\n throw new Error('Invalid UserPoolId format.');\n }\n const region = UserPoolId.split('_')[0];\n\n this.userPoolId = UserPoolId;\n this.clientId = ClientId;\n\n this.client = new CognitoIdentityServiceProvider({ apiVersion: '2016-04-19', region });\n\n this.storage = data.Storage || new StorageHelper().getStorage();\n }\n\n /**\n * @returns {string} the user pool id\n */\n getUserPoolId() {\n return this.userPoolId;\n }\n\n /**\n * @returns {string} the client id\n */\n getClientId() {\n return this.clientId;\n }\n\n /**\n * @typedef {object} SignUpResult\n * @property {CognitoUser} user New user.\n * @property {bool} userConfirmed If the user is already confirmed.\n */\n /**\n * method for signing up a user\n * @param {string} username User's username.\n * @param {string} password Plain-text initial password entered by user.\n * @param {(AttributeArg[])=} userAttributes New user attributes.\n * @param {(AttributeArg[])=} validationData Application metadata.\n * @param {nodeCallback} callback Called on error or with the new user.\n * @returns {void}\n */\n signUp(username, password, userAttributes, validationData, callback) {\n this.client.makeUnauthenticatedRequest('signUp', {\n ClientId: this.clientId,\n Username: username,\n Password: password,\n UserAttributes: userAttributes,\n ValidationData: validationData,\n }, (err, data) => {\n if (err) {\n return callback(err, null);\n }\n\n const cognitoUser = {\n Username: username,\n Pool: this,\n Storage: this.storage,\n };\n\n const returnData = {\n user: new CognitoUser(cognitoUser),\n userConfirmed: data.UserConfirmed,\n };\n\n return callback(null, returnData);\n });\n }\n\n\n /**\n * method for getting the current user of the application from the local storage\n *\n * @returns {CognitoUser} the user retrieved from storage\n */\n getCurrentUser() {\n const lastUserKey = `CognitoIdentityServiceProvider.${this.clientId}.LastAuthUser`;\n\n const lastAuthUser = this.storage.getItem(lastUserKey);\n if (lastAuthUser) {\n const cognitoUser = {\n Username: lastAuthUser,\n Pool: this,\n Storage: this.storage,\n };\n\n return new CognitoUser(cognitoUser);\n }\n\n return null;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoUserPool.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { default as AuthenticationDetails } from './AuthenticationDetails';\nexport { default as AuthenticationHelper } from './AuthenticationHelper';\nexport { default as CognitoAccessToken } from './CognitoAccessToken';\nexport { default as CognitoIdToken } from './CognitoIdToken';\nexport { default as CognitoRefreshToken } from './CognitoRefreshToken';\nexport { default as CognitoUser } from './CognitoUser';\nexport { default as CognitoUserAttribute } from './CognitoUserAttribute';\nexport { default as CognitoUserPool } from './CognitoUserPool';\nexport { default as CognitoUserSession } from './CognitoUserSession';\nexport { default as DateHelper } from './DateHelper';\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///amazon-cognito-identity.min.js","webpack:///webpack/bootstrap 2cc185fe7183e923d71f","webpack:///./enhance.js","webpack:///external {\"root\":[\"AWSCognito\"],\"commonjs2\":\"aws-sdk/global\",\"commonjs\":\"aws-sdk/global\",\"amd\":\"aws-sdk/global\"}","webpack:///./src/AuthenticationHelper.js","webpack:///./src/BigInteger.js","webpack:///./src/CognitoAccessToken.js","webpack:///./src/CognitoIdToken.js","webpack:///./src/CognitoRefreshToken.js","webpack:///./src/CognitoUser.js","webpack:///./src/CognitoUserAttribute.js","webpack:///./src/CognitoUserSession.js","webpack:///./src/DateHelper.js","webpack:///./src/StorageHelper.js","webpack:///external {\"root\":[\"AWSCognito\",\"CognitoIdentityServiceProvider\"],\"commonjs2\":\"aws-sdk/clients/cognitoidentityserviceprovider\",\"commonjs\":\"aws-sdk/clients/cognitoidentityserviceprovider\",\"amd\":\"aws-sdk/clients/cognitoidentityserviceprovider\"}","webpack:///./src/AuthenticationDetails.js","webpack:///./src/CognitoUserPool.js","webpack:///./src/index.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","__WEBPACK_EXTERNAL_MODULE_12__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_interopRequireWildcard","obj","__esModule","newObj","key","Object","prototype","hasOwnProperty","default","_interopRequireDefault","_src","keys","forEach","defineProperty","enumerable","get","_cognitoidentityserviceprovider","_cognitoidentityserviceprovider2","enhancements","window","crypto","msCrypto","_classCallCheck","instance","Constructor","TypeError","_global","_BigInteger","_BigInteger2","initN","newPasswordRequiredChallengeUserAttributePrefix","AuthenticationHelper","PoolName","N","g","k","hexHash","toString","smallAValue","generateRandomSmallA","largeAValue","calculateA","infoBits","util","Buffer","poolName","getSmallAValue","getLargeAValue","hexRandom","lib","randomBytes","randomBigInt","smallABigInt","mod","generateRandomString","getRandomPassword","randomPassword","getSaltDevices","SaltToHashDevices","getVerifierDevices","verifierDevices","generateHashDevice","deviceGroupKey","username","combinedString","hashedString","hash","padHex","verifierDevicesNotPadded","modPow","a","A","equals","ZERO","Error","calculateU","B","UHexHash","finalU","buf","hashHex","sha256","Array","length","join","hexStr","computehkdf","ikm","salt","prk","hmac","infoBitsUpdate","buffer","concat","String","fromCharCode","slice","getPasswordAuthenticationKey","password","serverBValue","UValue","usernamePassword","usernamePasswordHash","xValue","gModPowXN","intValue2","subtract","multiply","sValue","add","hkdf","getNewPasswordRequiredChallengeUserAttributePrefix","bigInt","hashStr","indexOf","BigInteger","b","fromString","nbi","am1","i","x","w","j","n","v","Math","floor","int2char","BI_RM","charAt","intAt","s","BI_RC","charCodeAt","bnpCopyTo","r","t","bnpFromInt","DV","nbv","fromInt","bnpFromString","mi","sh","DB","clamp","subTo","bnpClamp","DM","bnToString","negate","d","km","bnNegate","bnAbs","bnCompareTo","nbits","bnBitLength","bnpDLShiftTo","bnpDRShiftTo","max","bnpLShiftTo","bs","cbs","bm","ds","bnpRShiftTo","bnpSubTo","min","bnpMultiplyTo","abs","y","am","bnpSquareTo","bnpDivRemTo","q","pm","pt","copyTo","ts","ms","nsh","lShiftTo","ys","y0","yt","F1","F2","d1","FV","d2","e","dlShiftTo","compareTo","ONE","qd","drShiftTo","rShiftTo","bnMod","divRemTo","bnpInvDigit","bnEquals","bnpAddTo","bnAdd","addTo","bnSubtract","bnMultiply","multiplyTo","bnDivide","Montgomery","mp","invDigit","mpl","mph","um","mt2","montConvert","montRevert","reduce","montReduce","u0","montSqrTo","squareTo","montMulTo","bnModPow","bitLength","z","k1","convert","g2","sqrTo","mulTo","is1","r2","revert","dbits","BI_FP","pow","rr","vv","divide","CognitoAccessToken","_ref","arguments","undefined","AccessToken","jwtToken","getJwtToken","getExpiration","payload","split","expiration","JSON","parse","base64","decode","exp","CognitoIdToken","IdToken","CognitoRefreshToken","RefreshToken","token","getToken","_AuthenticationHelper","_AuthenticationHelper2","_CognitoAccessToken","_CognitoAccessToken2","_CognitoIdToken","_CognitoIdToken2","_CognitoRefreshToken","_CognitoRefreshToken2","_CognitoUserSession","_CognitoUserSession2","_DateHelper","_DateHelper2","_CognitoUserAttribute","_CognitoUserAttribute2","_StorageHelper","CognitoUser","data","Username","Pool","pool","Session","client","signInUserSession","authenticationFlowType","storage","getStorage","getSignInUserSession","getUsername","getAuthenticationFlowType","setAuthenticationFlowType","authenticateUser","authDetails","callback","_this","authenticationHelper","getUserPoolId","dateHelper","authParameters","deviceKey","DEVICE_KEY","USERNAME","SRP_A","CHALLENGE_NAME","makeUnauthenticatedRequest","AuthFlow","ClientId","getClientId","AuthParameters","ClientMetadata","getValidationData","err","onFailure","challengeParameters","ChallengeParameters","USER_ID_FOR_SRP","SRP_B","SALT","getCachedDeviceKeyAndPassword","getPassword","dateNow","getNowString","signatureString","SECRET_BLOCK","challengeResponses","PASSWORD_CLAIM_SECRET_BLOCK","TIMESTAMP","PASSWORD_CLAIM_SIGNATURE","respondToAuthChallenge","challenge","challengeCallback","errChallenge","dataChallenge","code","message","toLowerCase","clearCachedDeviceKeyAndPassword","ChallengeName","ChallengeResponses","errAuthenticate","dataAuthenticate","challengeName","userAttributes","rawRequiredAttributes","requiredAttributes","userAttributesPrefix","substr","newPasswordRequired","authenticateUserInternal","_this2","mfaRequired","customChallenge","getDeviceResponse","getCognitoUserSession","AuthenticationResult","cacheTokens","newDeviceMetadata","NewDeviceMetadata","onSuccess","DeviceGroupKey","DeviceKey","deviceSecretVerifierConfig","Salt","PasswordVerifier","getAccessToken","DeviceSecretVerifierConfig","DeviceName","navigator","userAgent","errConfirm","dataConfirm","cacheDeviceKeyAndPassword","UserConfirmationNecessary","completeNewPasswordChallenge","newPassword","requiredAttributeData","_this3","finalUserAttributes","NEW_PASSWORD","_this4","confirmRegistration","confirmationCode","forceAliasCreation","ConfirmationCode","ForceAliasCreation","sendCustomChallengeAnswer","answerChallenge","_this5","ANSWER","sendMFACode","_this6","SMS_MFA_CODE","changePassword","oldUserPassword","newUserPassword","isValid","PreviousPassword","ProposedPassword","enableMFA","mfaOptions","mfaEnabled","DeliveryMedium","AttributeName","push","MFAOptions","disableMFA","deleteUser","_this7","clearCachedTokens","updateAttributes","attributes","UserAttributes","getUserAttributes","userData","attributeList","attribute","Name","Value","userAttribute","getMFAOptions","deleteAttributes","UserAttributeNames","resendConfirmationCode","result","getSession","keyPrefix","idTokenKey","accessTokenKey","refreshTokenKey","getItem","idToken","accessToken","refreshToken","sessionData","cachedSession","refreshSession","_this8","REFRESH_TOKEN","lastUserKey","deviceKeyKey","authResult","authenticationResult","setItem","getIdToken","getRefreshToken","randomPasswordKey","deviceGroupKeyKey","removeItem","forgotPassword","inputVerificationCode","confirmPassword","Password","getAttributeVerificationCode","attributeName","verifyAttribute","Code","getDevice","forgetSpecificDevice","forgetDevice","_this9","setDeviceStatusRemembered","DeviceRememberedStatus","setDeviceStatusNotRemembered","listDevices","limit","paginationToken","Limit","PaginationToken","globalSignOut","_this10","signOut","CognitoUserAttribute","getValue","setValue","value","getName","setName","name","stringify","toJSON","CognitoUserSession","now","Date","monthNames","weekNames","DateHelper","weekDay","getUTCDay","month","getUTCMonth","day","getUTCDate","hours","getUTCHours","minutes","getUTCMinutes","seconds","getUTCSeconds","year","getUTCFullYear","dataMemory","MemoryStorage","clear","StorageHelper","storageWindow","localStorage","exception","AuthenticationDetails","ValidationData","validationData","_CognitoUser","_CognitoUser2","_StorageHelper2","CognitoUserPool","UserPoolId","test","region","userPoolId","clientId","apiVersion","Storage","signUp","cognitoUser","returnData","user","userConfirmed","UserConfirmed","getCurrentUser","lastAuthUser","_AuthenticationDetails","_CognitoUserPool"],"mappings":";;;;;;;;;;;;;;;;CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,EAAAG,QAAA,kBAAAA,QAAA,mDACA,kBAAAC,gBAAAC,IACAD,QAAA,mEAAAJ,GACA,gBAAAC,SACAA,QAAA,sBAAAD,EAAAG,QAAA,kBAAAA,QAAA,mDAEAJ,EAAA,sBAAAC,EAAAD,EAAA,WAAAA,EAAA,4CACCO,KAAA,SAAAC,EAAAC,GACD,MCkBgB,UAAUC,GCxB1B,QAAAC,GAAAC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GiBz2G1BlQ,UjB62GR,IAAIoQ,GAAkBrR,EAAoB,EAE1Cc,QAAOQ,eAAe/B,EAAS,kBAC7BgC,YAAY,EACZC,IAAK,WACH,MAAON,GAAuBmQ,GiBj3G1BpQ,UjBq3GR,IAAIsQ,GAAuBvR,EAAoB,EAE/Cc,QAAOQ,eAAe/B,EAAS,uBAC7BgC,YAAY,EACZC,IAAK,WACH,MAAON,GAAuBqQ,GiBz3G1BtQ,UjB63GR,IAAIyf,GAAe1gB,EAAoB,EAEvCc,QAAOQ,eAAe/B,EAAS,eAC7BgC,YAAY,EACZC,IAAK,WACH,MAAON,GAAuBwf,GiBj4G1Bzf,UjBq4GR,IAAI4Q,GAAwB7R,EAAoB,EAEhDc,QAAOQ,eAAe/B,EAAS,wBAC7BgC,YAAY,EACZC,IAAK,WACH,MAAON,GAAuB2Q,GiBz4G1B5Q,UjB64GR,IAAI6gB,GAAmB9hB,EAAoB,GAE3Cc,QAAOQ,eAAe/B,EAAS,mBAC7BgC,YAAY,EACZC,IAAK,WACH,MAAON,GAAuB4gB,GiBj5G1B7gB,UjBq5GR,IAAIwQ,GAAsBzR,EAAoB,EAE9Cc,QAAOQ,eAAe/B,EAAS,sBAC7BgC,YAAY,EACZC,IAAK,WACH,MAAON,GAAuBuQ,GiBz5G1BxQ,UjB65GR,IAAI0Q,GAAc3R,EAAoB,GAEtCc,QAAOQ,eAAe/B,EAAS,cAC7BgC,YAAY,EACZC,IAAK,WACH,MAAON,GAAuByQ,GiBj6G1B1Q","file":"amazon-cognito-identity.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"aws-sdk/global\"), require(\"aws-sdk/clients/cognitoidentityserviceprovider\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"aws-sdk/global\", \"aws-sdk/clients/cognitoidentityserviceprovider\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"AmazonCognitoIdentity\"] = factory(require(\"aws-sdk/global\"), require(\"aws-sdk/clients/cognitoidentityserviceprovider\"));\n\telse\n\t\troot[\"AmazonCognitoIdentity\"] = factory(root[\"AWSCognito\"], root[\"AWSCognito\"][\"CognitoIdentityServiceProvider\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_12__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n * \n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n * \n * http://aws.amazon.com/asl/\n * \n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License. \n */\n\n\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"aws-sdk/global\"), require(\"aws-sdk/clients/cognitoidentityserviceprovider\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"aws-sdk/global\", \"aws-sdk/clients/cognitoidentityserviceprovider\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"AmazonCognitoIdentity\"] = factory(require(\"aws-sdk/global\"), require(\"aws-sdk/clients/cognitoidentityserviceprovider\"));\n\telse\n\t\troot[\"AmazonCognitoIdentity\"] = factory(root[\"AWSCognito\"], root[\"AWSCognito\"][\"CognitoIdentityServiceProvider\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_12__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tvar _src = __webpack_require__(15);\n\t\n\tObject.keys(_src).forEach(function (key) {\n\t if (key === \"default\" || key === \"__esModule\") return;\n\t Object.defineProperty(exports, key, {\n\t enumerable: true,\n\t get: function get() {\n\t return _src[key];\n\t }\n\t });\n\t});\n\t\n\tvar _cognitoidentityserviceprovider = __webpack_require__(12);\n\t\n\tvar _cognitoidentityserviceprovider2 = _interopRequireDefault(_cognitoidentityserviceprovider);\n\t\n\tvar enhancements = _interopRequireWildcard(_src);\n\t\n\tfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tObject.keys(enhancements).forEach(function (key) {\n\t _cognitoidentityserviceprovider2.default[key] = enhancements[key];\n\t});\n\t\n\t// The version of crypto-browserify included by aws-sdk only\n\t// checks for window.crypto, not window.msCrypto as used by\n\t// IE 11 – so we set it explicitly here\n\tif (typeof window !== 'undefined' && !window.crypto && window.msCrypto) {\n\t window.crypto = window.msCrypto;\n\t}\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tvar _global = __webpack_require__(1);\n\t\n\tvar _BigInteger = __webpack_require__(3);\n\t\n\tvar _BigInteger2 = _interopRequireDefault(_BigInteger);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } } /*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\tvar initN = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1' + '29024E088A67CC74020BBEA63B139B22514A08798E3404DD' + 'EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245' + 'E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' + 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D' + 'C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F' + '83655D23DCA3AD961C62F356208552BB9ED529077096966D' + '670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B' + 'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9' + 'DE2BCBF6955817183995497CEA956AE515D2261898FA0510' + '15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64' + 'ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7' + 'ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B' + 'F12FFA06D98A0864D87602733EC86A64521F2B18177B200C' + 'BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31' + '43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF';\n\t\n\tvar newPasswordRequiredChallengeUserAttributePrefix = 'userAttributes.';\n\t\n\t/** @class */\n\t\n\tvar AuthenticationHelper = function () {\n\t /**\n\t * Constructs a new AuthenticationHelper object\n\t * @param {string} PoolName Cognito user pool name.\n\t */\n\t function AuthenticationHelper(PoolName) {\n\t _classCallCheck(this, AuthenticationHelper);\n\t\n\t this.N = new _BigInteger2.default(initN, 16);\n\t this.g = new _BigInteger2.default('2', 16);\n\t this.k = new _BigInteger2.default(this.hexHash('00' + this.N.toString(16) + '0' + this.g.toString(16)), 16);\n\t\n\t this.smallAValue = this.generateRandomSmallA();\n\t this.largeAValue = this.calculateA(this.smallAValue);\n\t\n\t this.infoBits = new _global.util.Buffer('Caldera Derived Key', 'utf8');\n\t\n\t this.poolName = PoolName;\n\t }\n\t\n\t /**\n\t * @returns {BigInteger} small A, a random number\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.getSmallAValue = function getSmallAValue() {\n\t return this.smallAValue;\n\t };\n\t\n\t /**\n\t * @returns {BigInteger} large A, a value generated from small A\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.getLargeAValue = function getLargeAValue() {\n\t return this.largeAValue;\n\t };\n\t\n\t /**\n\t * helper function to generate a random big integer\n\t * @returns {BigInteger} a random value.\n\t * @private\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.generateRandomSmallA = function generateRandomSmallA() {\n\t var hexRandom = _global.util.crypto.lib.randomBytes(128).toString('hex');\n\t\n\t var randomBigInt = new _BigInteger2.default(hexRandom, 16);\n\t var smallABigInt = randomBigInt.mod(this.N);\n\t\n\t return smallABigInt;\n\t };\n\t\n\t /**\n\t * helper function to generate a random string\n\t * @returns {string} a random value.\n\t * @private\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.generateRandomString = function generateRandomString() {\n\t return _global.util.crypto.lib.randomBytes(40).toString('base64');\n\t };\n\t\n\t /**\n\t * @returns {string} Generated random value included in password hash.\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.getRandomPassword = function getRandomPassword() {\n\t return this.randomPassword;\n\t };\n\t\n\t /**\n\t * @returns {string} Generated random value included in devices hash.\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.getSaltDevices = function getSaltDevices() {\n\t return this.SaltToHashDevices;\n\t };\n\t\n\t /**\n\t * @returns {string} Value used to verify devices.\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.getVerifierDevices = function getVerifierDevices() {\n\t return this.verifierDevices;\n\t };\n\t\n\t /**\n\t * Generate salts and compute verifier.\n\t * @param {string} deviceGroupKey Devices to generate verifier for.\n\t * @param {string} username User to generate verifier for.\n\t * @returns {void}\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.generateHashDevice = function generateHashDevice(deviceGroupKey, username) {\n\t this.randomPassword = this.generateRandomString();\n\t var combinedString = '' + deviceGroupKey + username + ':' + this.randomPassword;\n\t var hashedString = this.hash(combinedString);\n\t\n\t var hexRandom = _global.util.crypto.lib.randomBytes(16).toString('hex');\n\t this.SaltToHashDevices = this.padHex(new _BigInteger2.default(hexRandom, 16));\n\t\n\t var verifierDevicesNotPadded = this.g.modPow(new _BigInteger2.default(this.hexHash(this.SaltToHashDevices + hashedString), 16), this.N);\n\t\n\t this.verifierDevices = this.padHex(verifierDevicesNotPadded);\n\t };\n\t\n\t /**\n\t * Calculate the client's public value A = g^a%N\n\t * with the generated random number a\n\t * @param {BigInteger} a Randomly generated small A.\n\t * @returns {BigInteger} Computed large A.\n\t * @private\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.calculateA = function calculateA(a) {\n\t var A = this.g.modPow(a, this.N);\n\t\n\t if (A.mod(this.N).equals(_BigInteger2.default.ZERO)) {\n\t throw new Error('Illegal paramater. A mod N cannot be 0.');\n\t }\n\t return A;\n\t };\n\t\n\t /**\n\t * Calculate the client's value U which is the hash of A and B\n\t * @param {BigInteger} A Large A value.\n\t * @param {BigInteger} B Server B value.\n\t * @returns {BigInteger} Computed U value.\n\t * @private\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.calculateU = function calculateU(A, B) {\n\t this.UHexHash = this.hexHash(this.padHex(A) + this.padHex(B));\n\t var finalU = new _BigInteger2.default(this.UHexHash, 16);\n\t\n\t return finalU;\n\t };\n\t\n\t /**\n\t * Calculate a hash from a bitArray\n\t * @param {Buffer} buf Value to hash.\n\t * @returns {String} Hex-encoded hash.\n\t * @private\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.hash = function hash(buf) {\n\t var hashHex = _global.util.crypto.sha256(buf, 'hex');\n\t return new Array(64 - hashHex.length).join('0') + hashHex;\n\t };\n\t\n\t /**\n\t * Calculate a hash from a hex string\n\t * @param {String} hexStr Value to hash.\n\t * @returns {String} Hex-encoded hash.\n\t * @private\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.hexHash = function hexHash(hexStr) {\n\t return this.hash(new _global.util.Buffer(hexStr, 'hex'));\n\t };\n\t\n\t /**\n\t * Standard hkdf algorithm\n\t * @param {Buffer} ikm Input key material.\n\t * @param {Buffer} salt Salt value.\n\t * @returns {Buffer} Strong key material.\n\t * @private\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.computehkdf = function computehkdf(ikm, salt) {\n\t var prk = _global.util.crypto.hmac(salt, ikm, 'buffer', 'sha256');\n\t var infoBitsUpdate = _global.util.buffer.concat([this.infoBits, new _global.util.Buffer(String.fromCharCode(1), 'utf8')]);\n\t var hmac = _global.util.crypto.hmac(prk, infoBitsUpdate, 'buffer', 'sha256');\n\t return hmac.slice(0, 16);\n\t };\n\t\n\t /**\n\t * Calculates the final hkdf based on computed S value, and computed U value and the key\n\t * @param {String} username Username.\n\t * @param {String} password Password.\n\t * @param {BigInteger} serverBValue Server B value.\n\t * @param {BigInteger} salt Generated salt.\n\t * @returns {Buffer} Computed HKDF value.\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.getPasswordAuthenticationKey = function getPasswordAuthenticationKey(username, password, serverBValue, salt) {\n\t if (serverBValue.mod(this.N).equals(_BigInteger2.default.ZERO)) {\n\t throw new Error('B cannot be zero.');\n\t }\n\t\n\t this.UValue = this.calculateU(this.largeAValue, serverBValue);\n\t\n\t if (this.UValue.equals(_BigInteger2.default.ZERO)) {\n\t throw new Error('U cannot be zero.');\n\t }\n\t\n\t var usernamePassword = '' + this.poolName + username + ':' + password;\n\t var usernamePasswordHash = this.hash(usernamePassword);\n\t\n\t var xValue = new _BigInteger2.default(this.hexHash(this.padHex(salt) + usernamePasswordHash), 16);\n\t\n\t var gModPowXN = this.g.modPow(xValue, this.N);\n\t var intValue2 = serverBValue.subtract(this.k.multiply(gModPowXN));\n\t var sValue = intValue2.modPow(this.smallAValue.add(this.UValue.multiply(xValue)), this.N).mod(this.N);\n\t\n\t var hkdf = this.computehkdf(new _global.util.Buffer(this.padHex(sValue), 'hex'), new _global.util.Buffer(this.padHex(this.UValue.toString(16)), 'hex'));\n\t\n\t return hkdf;\n\t };\n\t\n\t /**\n\t * Return constant newPasswordRequiredChallengeUserAttributePrefix\n\t * @return {newPasswordRequiredChallengeUserAttributePrefix} constant prefix value\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.getNewPasswordRequiredChallengeUserAttributePrefix = function getNewPasswordRequiredChallengeUserAttributePrefix() {\n\t return newPasswordRequiredChallengeUserAttributePrefix;\n\t };\n\t\n\t /**\n\t * Converts a BigInteger (or hex string) to hex format padded with zeroes for hashing\n\t * @param {BigInteger|String} bigInt Number or string to pad.\n\t * @returns {String} Padded hex string.\n\t */\n\t\n\t\n\t AuthenticationHelper.prototype.padHex = function padHex(bigInt) {\n\t var hashStr = bigInt.toString(16);\n\t if (hashStr.length % 2 === 1) {\n\t hashStr = '0' + hashStr;\n\t } else if ('89ABCDEFabcdef'.indexOf(hashStr[0]) !== -1) {\n\t hashStr = '00' + hashStr;\n\t }\n\t return hashStr;\n\t };\n\t\n\t return AuthenticationHelper;\n\t}();\n\t\n\texports.default = AuthenticationHelper;\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\n\t\"use strict\";\n\t\n\texports.__esModule = true;\n\t// A small implementation of BigInteger based on http://www-cs-students.stanford.edu/~tjw/jsbn/\n\t//\n\t// All public methods have been removed except the following:\n\t// new BigInteger(a, b) (only radix 2, 4, 8, 16 and 32 supported)\n\t// toString (only radix 2, 4, 8, 16 and 32 supported)\n\t// negate\n\t// abs\n\t// compareTo\n\t// bitLength\n\t// mod\n\t// equals\n\t// add\n\t// subtract\n\t// multiply\n\t// divide\n\t// modPow\n\t\n\texports.default = BigInteger;\n\t\n\t/*\n\t * Copyright (c) 2003-2005 Tom Wu\n\t * All Rights Reserved.\n\t *\n\t * Permission is hereby granted, free of charge, to any person obtaining\n\t * a copy of this software and associated documentation files (the\n\t * \"Software\"), to deal in the Software without restriction, including\n\t * without limitation the rights to use, copy, modify, merge, publish,\n\t * distribute, sublicense, and/or sell copies of the Software, and to\n\t * permit persons to whom the Software is furnished to do so, subject to\n\t * the following conditions:\n\t *\n\t * The above copyright notice and this permission notice shall be\n\t * included in all copies or substantial portions of the Software.\n\t *\n\t * THE SOFTWARE IS PROVIDED \"AS-IS\" AND WITHOUT WARRANTY OF ANY KIND,\n\t * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY\n\t * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.\n\t *\n\t * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,\n\t * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER\n\t * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF\n\t * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT\n\t * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\t *\n\t * In addition, the following condition applies:\n\t *\n\t * All redistributions must retain an intact copy of this copyright notice\n\t * and disclaimer.\n\t */\n\t\n\t// (public) Constructor\n\t\n\tfunction BigInteger(a, b) {\n\t if (a != null) this.fromString(a, b);\n\t}\n\t\n\t// return new, unset BigInteger\n\tfunction nbi() {\n\t return new BigInteger(null);\n\t}\n\t\n\t// am: Compute w_j += (x*this_i), propagate carries,\n\t// c is initial carry, returns final carry.\n\t// c < 3*dvalue, x < 2*dvalue, this_i < dvalue\n\t// We need to select the fastest one that works in this environment.\n\t// am1: use a single mult and divide to get the high bits,\n\t// max digit bits should be 26 because\n\t// max internal value = 2*dvalue^2-2*dvalue (< 2^53)\n\tfunction am1(i, x, w, j, c, n) {\n\t while (--n >= 0) {\n\t var v = x * this[i++] + w[j] + c;\n\t c = Math.floor(v / 0x4000000);\n\t w[j++] = v & 0x3ffffff;\n\t }\n\t return c;\n\t}\n\t\n\tBigInteger.prototype.am = am1;\n\t\n\t// Bits per digit\n\tvar dbits = 26;\n\t\n\tBigInteger.prototype.DB = dbits;\n\tBigInteger.prototype.DM = (1 << dbits) - 1;\n\tBigInteger.prototype.DV = 1 << dbits;\n\t\n\tvar BI_FP = 52;\n\tBigInteger.prototype.FV = Math.pow(2, BI_FP);\n\tBigInteger.prototype.F1 = BI_FP - dbits;\n\tBigInteger.prototype.F2 = 2 * dbits - BI_FP;\n\t\n\t// Digit conversions\n\tvar BI_RM = \"0123456789abcdefghijklmnopqrstuvwxyz\";\n\tvar BI_RC = new Array();\n\tvar rr, vv;\n\trr = \"0\".charCodeAt(0);\n\tfor (vv = 0; vv <= 9; ++vv) {\n\t BI_RC[rr++] = vv;\n\t}rr = \"a\".charCodeAt(0);\n\tfor (vv = 10; vv < 36; ++vv) {\n\t BI_RC[rr++] = vv;\n\t}rr = \"A\".charCodeAt(0);\n\tfor (vv = 10; vv < 36; ++vv) {\n\t BI_RC[rr++] = vv;\n\t}function int2char(n) {\n\t return BI_RM.charAt(n);\n\t}\n\tfunction intAt(s, i) {\n\t var c = BI_RC[s.charCodeAt(i)];\n\t return c == null ? -1 : c;\n\t}\n\t\n\t// (protected) copy this to r\n\tfunction bnpCopyTo(r) {\n\t for (var i = this.t - 1; i >= 0; --i) {\n\t r[i] = this[i];\n\t }r.t = this.t;\n\t r.s = this.s;\n\t}\n\t\n\t// (protected) set from integer value x, -DV <= x < DV\n\tfunction bnpFromInt(x) {\n\t this.t = 1;\n\t this.s = x < 0 ? -1 : 0;\n\t if (x > 0) this[0] = x;else if (x < -1) this[0] = x + this.DV;else this.t = 0;\n\t}\n\t\n\t// return bigint initialized to value\n\tfunction nbv(i) {\n\t var r = nbi();\n\t\n\t r.fromInt(i);\n\t\n\t return r;\n\t}\n\t\n\t// (protected) set from string and radix\n\tfunction bnpFromString(s, b) {\n\t var k;\n\t if (b == 16) k = 4;else if (b == 8) k = 3;else if (b == 2) k = 1;else if (b == 32) k = 5;else if (b == 4) k = 2;else throw new Error(\"Only radix 2, 4, 8, 16, 32 are supported\");\n\t this.t = 0;\n\t this.s = 0;\n\t var i = s.length,\n\t mi = false,\n\t sh = 0;\n\t while (--i >= 0) {\n\t var x = intAt(s, i);\n\t if (x < 0) {\n\t if (s.charAt(i) == \"-\") mi = true;\n\t continue;\n\t }\n\t mi = false;\n\t if (sh == 0) this[this.t++] = x;else if (sh + k > this.DB) {\n\t this[this.t - 1] |= (x & (1 << this.DB - sh) - 1) << sh;\n\t this[this.t++] = x >> this.DB - sh;\n\t } else this[this.t - 1] |= x << sh;\n\t sh += k;\n\t if (sh >= this.DB) sh -= this.DB;\n\t }\n\t this.clamp();\n\t if (mi) BigInteger.ZERO.subTo(this, this);\n\t}\n\t\n\t// (protected) clamp off excess high words\n\tfunction bnpClamp() {\n\t var c = this.s & this.DM;\n\t while (this.t > 0 && this[this.t - 1] == c) {\n\t --this.t;\n\t }\n\t}\n\t\n\t// (public) return string representation in given radix\n\tfunction bnToString(b) {\n\t if (this.s < 0) return \"-\" + this.negate().toString();\n\t var k;\n\t if (b == 16) k = 4;else if (b == 8) k = 3;else if (b == 2) k = 1;else if (b == 32) k = 5;else if (b == 4) k = 2;else throw new Error(\"Only radix 2, 4, 8, 16, 32 are supported\");\n\t var km = (1 << k) - 1,\n\t d,\n\t m = false,\n\t r = \"\",\n\t i = this.t;\n\t var p = this.DB - i * this.DB % k;\n\t if (i-- > 0) {\n\t if (p < this.DB && (d = this[i] >> p) > 0) {\n\t m = true;\n\t r = int2char(d);\n\t }\n\t while (i >= 0) {\n\t if (p < k) {\n\t d = (this[i] & (1 << p) - 1) << k - p;\n\t d |= this[--i] >> (p += this.DB - k);\n\t } else {\n\t d = this[i] >> (p -= k) & km;\n\t if (p <= 0) {\n\t p += this.DB;\n\t --i;\n\t }\n\t }\n\t if (d > 0) m = true;\n\t if (m) r += int2char(d);\n\t }\n\t }\n\t return m ? r : \"0\";\n\t}\n\t\n\t// (public) -this\n\tfunction bnNegate() {\n\t var r = nbi();\n\t\n\t BigInteger.ZERO.subTo(this, r);\n\t\n\t return r;\n\t}\n\t\n\t// (public) |this|\n\tfunction bnAbs() {\n\t return this.s < 0 ? this.negate() : this;\n\t}\n\t\n\t// (public) return + if this > a, - if this < a, 0 if equal\n\tfunction bnCompareTo(a) {\n\t var r = this.s - a.s;\n\t if (r != 0) return r;\n\t var i = this.t;\n\t r = i - a.t;\n\t if (r != 0) return this.s < 0 ? -r : r;\n\t while (--i >= 0) {\n\t if ((r = this[i] - a[i]) != 0) return r;\n\t }return 0;\n\t}\n\t\n\t// returns bit length of the integer x\n\tfunction nbits(x) {\n\t var r = 1,\n\t t;\n\t if ((t = x >>> 16) != 0) {\n\t x = t;\n\t r += 16;\n\t }\n\t if ((t = x >> 8) != 0) {\n\t x = t;\n\t r += 8;\n\t }\n\t if ((t = x >> 4) != 0) {\n\t x = t;\n\t r += 4;\n\t }\n\t if ((t = x >> 2) != 0) {\n\t x = t;\n\t r += 2;\n\t }\n\t if ((t = x >> 1) != 0) {\n\t x = t;\n\t r += 1;\n\t }\n\t return r;\n\t}\n\t\n\t// (public) return the number of bits in \"this\"\n\tfunction bnBitLength() {\n\t if (this.t <= 0) return 0;\n\t return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.DM);\n\t}\n\t\n\t// (protected) r = this << n*DB\n\tfunction bnpDLShiftTo(n, r) {\n\t var i;\n\t for (i = this.t - 1; i >= 0; --i) {\n\t r[i + n] = this[i];\n\t }for (i = n - 1; i >= 0; --i) {\n\t r[i] = 0;\n\t }r.t = this.t + n;\n\t r.s = this.s;\n\t}\n\t\n\t// (protected) r = this >> n*DB\n\tfunction bnpDRShiftTo(n, r) {\n\t for (var i = n; i < this.t; ++i) {\n\t r[i - n] = this[i];\n\t }r.t = Math.max(this.t - n, 0);\n\t r.s = this.s;\n\t}\n\t\n\t// (protected) r = this << n\n\tfunction bnpLShiftTo(n, r) {\n\t var bs = n % this.DB;\n\t var cbs = this.DB - bs;\n\t var bm = (1 << cbs) - 1;\n\t var ds = Math.floor(n / this.DB),\n\t c = this.s << bs & this.DM,\n\t i;\n\t for (i = this.t - 1; i >= 0; --i) {\n\t r[i + ds + 1] = this[i] >> cbs | c;\n\t c = (this[i] & bm) << bs;\n\t }\n\t for (i = ds - 1; i >= 0; --i) {\n\t r[i] = 0;\n\t }r[ds] = c;\n\t r.t = this.t + ds + 1;\n\t r.s = this.s;\n\t r.clamp();\n\t}\n\t\n\t// (protected) r = this >> n\n\tfunction bnpRShiftTo(n, r) {\n\t r.s = this.s;\n\t var ds = Math.floor(n / this.DB);\n\t if (ds >= this.t) {\n\t r.t = 0;\n\t return;\n\t }\n\t var bs = n % this.DB;\n\t var cbs = this.DB - bs;\n\t var bm = (1 << bs) - 1;\n\t r[0] = this[ds] >> bs;\n\t for (var i = ds + 1; i < this.t; ++i) {\n\t r[i - ds - 1] |= (this[i] & bm) << cbs;\n\t r[i - ds] = this[i] >> bs;\n\t }\n\t if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;\n\t r.t = this.t - ds;\n\t r.clamp();\n\t}\n\t\n\t// (protected) r = this - a\n\tfunction bnpSubTo(a, r) {\n\t var i = 0,\n\t c = 0,\n\t m = Math.min(a.t, this.t);\n\t while (i < m) {\n\t c += this[i] - a[i];\n\t r[i++] = c & this.DM;\n\t c >>= this.DB;\n\t }\n\t if (a.t < this.t) {\n\t c -= a.s;\n\t while (i < this.t) {\n\t c += this[i];\n\t r[i++] = c & this.DM;\n\t c >>= this.DB;\n\t }\n\t c += this.s;\n\t } else {\n\t c += this.s;\n\t while (i < a.t) {\n\t c -= a[i];\n\t r[i++] = c & this.DM;\n\t c >>= this.DB;\n\t }\n\t c -= a.s;\n\t }\n\t r.s = c < 0 ? -1 : 0;\n\t if (c < -1) r[i++] = this.DV + c;else if (c > 0) r[i++] = c;\n\t r.t = i;\n\t r.clamp();\n\t}\n\t\n\t// (protected) r = this * a, r != this,a (HAC 14.12)\n\t// \"this\" should be the larger one if appropriate.\n\tfunction bnpMultiplyTo(a, r) {\n\t var x = this.abs(),\n\t y = a.abs();\n\t var i = x.t;\n\t r.t = i + y.t;\n\t while (--i >= 0) {\n\t r[i] = 0;\n\t }for (i = 0; i < y.t; ++i) {\n\t r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);\n\t }r.s = 0;\n\t r.clamp();\n\t if (this.s != a.s) BigInteger.ZERO.subTo(r, r);\n\t}\n\t\n\t// (protected) r = this^2, r != this (HAC 14.16)\n\tfunction bnpSquareTo(r) {\n\t var x = this.abs();\n\t var i = r.t = 2 * x.t;\n\t while (--i >= 0) {\n\t r[i] = 0;\n\t }for (i = 0; i < x.t - 1; ++i) {\n\t var c = x.am(i, x[i], r, 2 * i, 0, 1);\n\t if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {\n\t r[i + x.t] -= x.DV;\n\t r[i + x.t + 1] = 1;\n\t }\n\t }\n\t if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);\n\t r.s = 0;\n\t r.clamp();\n\t}\n\t\n\t// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)\n\t// r != q, this != m. q or r may be null.\n\tfunction bnpDivRemTo(m, q, r) {\n\t var pm = m.abs();\n\t if (pm.t <= 0) return;\n\t var pt = this.abs();\n\t if (pt.t < pm.t) {\n\t if (q != null) q.fromInt(0);\n\t if (r != null) this.copyTo(r);\n\t return;\n\t }\n\t if (r == null) r = nbi();\n\t var y = nbi(),\n\t ts = this.s,\n\t ms = m.s;\n\t var nsh = this.DB - nbits(pm[pm.t - 1]);\n\t // normalize modulus\n\t if (nsh > 0) {\n\t pm.lShiftTo(nsh, y);\n\t pt.lShiftTo(nsh, r);\n\t } else {\n\t pm.copyTo(y);\n\t pt.copyTo(r);\n\t }\n\t var ys = y.t;\n\t var y0 = y[ys - 1];\n\t if (y0 == 0) return;\n\t var yt = y0 * (1 << this.F1) + (ys > 1 ? y[ys - 2] >> this.F2 : 0);\n\t var d1 = this.FV / yt,\n\t d2 = (1 << this.F1) / yt,\n\t e = 1 << this.F2;\n\t var i = r.t,\n\t j = i - ys,\n\t t = q == null ? nbi() : q;\n\t y.dlShiftTo(j, t);\n\t if (r.compareTo(t) >= 0) {\n\t r[r.t++] = 1;\n\t r.subTo(t, r);\n\t }\n\t BigInteger.ONE.dlShiftTo(ys, t);\n\t t.subTo(y, y);\n\t // \"negative\" y so we can replace sub with am later\n\t while (y.t < ys) {\n\t y[y.t++] = 0;\n\t }while (--j >= 0) {\n\t // Estimate quotient digit\n\t var qd = r[--i] == y0 ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);\n\t if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) {\n\t // Try it out\n\t y.dlShiftTo(j, t);\n\t r.subTo(t, r);\n\t while (r[i] < --qd) {\n\t r.subTo(t, r);\n\t }\n\t }\n\t }\n\t if (q != null) {\n\t r.drShiftTo(ys, q);\n\t if (ts != ms) BigInteger.ZERO.subTo(q, q);\n\t }\n\t r.t = ys;\n\t r.clamp();\n\t if (nsh > 0) r.rShiftTo(nsh, r);\n\t // Denormalize remainder\n\t if (ts < 0) BigInteger.ZERO.subTo(r, r);\n\t}\n\t\n\t// (public) this mod a\n\tfunction bnMod(a) {\n\t var r = nbi();\n\t this.abs().divRemTo(a, null, r);\n\t if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);\n\t return r;\n\t}\n\t\n\t// (protected) return \"-1/this % 2^DB\"; useful for Mont. reduction\n\t// justification:\n\t// xy == 1 (mod m)\n\t// xy = 1+km\n\t// xy(2-xy) = (1+km)(1-km)\n\t// x[y(2-xy)] = 1-k^2m^2\n\t// x[y(2-xy)] == 1 (mod m^2)\n\t// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2\n\t// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.\n\t// JS multiply \"overflows\" differently from C/C++, so care is needed here.\n\tfunction bnpInvDigit() {\n\t if (this.t < 1) return 0;\n\t var x = this[0];\n\t if ((x & 1) == 0) return 0;\n\t var y = x & 3;\n\t // y == 1/x mod 2^2\n\t y = y * (2 - (x & 0xf) * y) & 0xf;\n\t // y == 1/x mod 2^4\n\t y = y * (2 - (x & 0xff) * y) & 0xff;\n\t // y == 1/x mod 2^8\n\t y = y * (2 - ((x & 0xffff) * y & 0xffff)) & 0xffff;\n\t // y == 1/x mod 2^16\n\t // last step - calculate inverse mod DV directly;\n\t // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints\n\t y = y * (2 - x * y % this.DV) % this.DV;\n\t // y == 1/x mod 2^dbits\n\t // we really want the negative inverse, and -DV < y < DV\n\t return y > 0 ? this.DV - y : -y;\n\t}\n\t\n\tfunction bnEquals(a) {\n\t return this.compareTo(a) == 0;\n\t}\n\t\n\t// (protected) r = this + a\n\tfunction bnpAddTo(a, r) {\n\t var i = 0,\n\t c = 0,\n\t m = Math.min(a.t, this.t);\n\t while (i < m) {\n\t c += this[i] + a[i];\n\t r[i++] = c & this.DM;\n\t c >>= this.DB;\n\t }\n\t if (a.t < this.t) {\n\t c += a.s;\n\t while (i < this.t) {\n\t c += this[i];\n\t r[i++] = c & this.DM;\n\t c >>= this.DB;\n\t }\n\t c += this.s;\n\t } else {\n\t c += this.s;\n\t while (i < a.t) {\n\t c += a[i];\n\t r[i++] = c & this.DM;\n\t c >>= this.DB;\n\t }\n\t c += a.s;\n\t }\n\t r.s = c < 0 ? -1 : 0;\n\t if (c > 0) r[i++] = c;else if (c < -1) r[i++] = this.DV + c;\n\t r.t = i;\n\t r.clamp();\n\t}\n\t\n\t// (public) this + a\n\tfunction bnAdd(a) {\n\t var r = nbi();\n\t\n\t this.addTo(a, r);\n\t\n\t return r;\n\t}\n\t\n\t// (public) this - a\n\tfunction bnSubtract(a) {\n\t var r = nbi();\n\t\n\t this.subTo(a, r);\n\t\n\t return r;\n\t}\n\t\n\t// (public) this * a\n\tfunction bnMultiply(a) {\n\t var r = nbi();\n\t\n\t this.multiplyTo(a, r);\n\t\n\t return r;\n\t}\n\t\n\t// (public) this / a\n\tfunction bnDivide(a) {\n\t var r = nbi();\n\t\n\t this.divRemTo(a, r, null);\n\t\n\t return r;\n\t}\n\t\n\t// Montgomery reduction\n\tfunction Montgomery(m) {\n\t this.m = m;\n\t this.mp = m.invDigit();\n\t this.mpl = this.mp & 0x7fff;\n\t this.mph = this.mp >> 15;\n\t this.um = (1 << m.DB - 15) - 1;\n\t this.mt2 = 2 * m.t;\n\t}\n\t\n\t// xR mod m\n\tfunction montConvert(x) {\n\t var r = nbi();\n\t x.abs().dlShiftTo(this.m.t, r);\n\t r.divRemTo(this.m, null, r);\n\t if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);\n\t return r;\n\t}\n\t\n\t// x/R mod m\n\tfunction montRevert(x) {\n\t var r = nbi();\n\t x.copyTo(r);\n\t this.reduce(r);\n\t return r;\n\t}\n\t\n\t// x = x/R mod m (HAC 14.32)\n\tfunction montReduce(x) {\n\t while (x.t <= this.mt2) {\n\t // pad x so am has enough room later\n\t x[x.t++] = 0;\n\t }for (var i = 0; i < this.m.t; ++i) {\n\t // faster way of calculating u0 = x[i]*mp mod DV\n\t var j = x[i] & 0x7fff;\n\t var u0 = j * this.mpl + ((j * this.mph + (x[i] >> 15) * this.mpl & this.um) << 15) & x.DM;\n\t // use am to combine the multiply-shift-add into one call\n\t j = i + this.m.t;\n\t x[j] += this.m.am(0, u0, x, i, 0, this.m.t);\n\t // propagate carry\n\t while (x[j] >= x.DV) {\n\t x[j] -= x.DV;\n\t x[++j]++;\n\t }\n\t }\n\t x.clamp();\n\t x.drShiftTo(this.m.t, x);\n\t if (x.compareTo(this.m) >= 0) x.subTo(this.m, x);\n\t}\n\t\n\t// r = \"x^2/R mod m\"; x != r\n\tfunction montSqrTo(x, r) {\n\t x.squareTo(r);\n\t\n\t this.reduce(r);\n\t}\n\t\n\t// r = \"xy/R mod m\"; x,y != r\n\tfunction montMulTo(x, y, r) {\n\t x.multiplyTo(y, r);\n\t\n\t this.reduce(r);\n\t}\n\t\n\tMontgomery.prototype.convert = montConvert;\n\tMontgomery.prototype.revert = montRevert;\n\tMontgomery.prototype.reduce = montReduce;\n\tMontgomery.prototype.mulTo = montMulTo;\n\tMontgomery.prototype.sqrTo = montSqrTo;\n\t\n\t// (public) this^e % m (HAC 14.85)\n\tfunction bnModPow(e, m) {\n\t var i = e.bitLength(),\n\t k,\n\t r = nbv(1),\n\t z = new Montgomery(m);\n\t if (i <= 0) return r;else if (i < 18) k = 1;else if (i < 48) k = 3;else if (i < 144) k = 4;else if (i < 768) k = 5;else k = 6;\n\t\n\t // precomputation\n\t var g = new Array(),\n\t n = 3,\n\t k1 = k - 1,\n\t km = (1 << k) - 1;\n\t g[1] = z.convert(this);\n\t if (k > 1) {\n\t var g2 = nbi();\n\t z.sqrTo(g[1], g2);\n\t while (n <= km) {\n\t g[n] = nbi();\n\t z.mulTo(g2, g[n - 2], g[n]);\n\t n += 2;\n\t }\n\t }\n\t\n\t var j = e.t - 1,\n\t w,\n\t is1 = true,\n\t r2 = nbi(),\n\t t;\n\t i = nbits(e[j]) - 1;\n\t while (j >= 0) {\n\t if (i >= k1) w = e[j] >> i - k1 & km;else {\n\t w = (e[j] & (1 << i + 1) - 1) << k1 - i;\n\t if (j > 0) w |= e[j - 1] >> this.DB + i - k1;\n\t }\n\t\n\t n = k;\n\t while ((w & 1) == 0) {\n\t w >>= 1;\n\t --n;\n\t }\n\t if ((i -= n) < 0) {\n\t i += this.DB;\n\t --j;\n\t }\n\t if (is1) {\n\t // ret == 1, don't bother squaring or multiplying it\n\t g[w].copyTo(r);\n\t is1 = false;\n\t } else {\n\t while (n > 1) {\n\t z.sqrTo(r, r2);\n\t z.sqrTo(r2, r);\n\t n -= 2;\n\t }\n\t if (n > 0) z.sqrTo(r, r2);else {\n\t t = r;\n\t r = r2;\n\t r2 = t;\n\t }\n\t z.mulTo(r2, g[w], r);\n\t }\n\t\n\t while (j >= 0 && (e[j] & 1 << i) == 0) {\n\t z.sqrTo(r, r2);\n\t t = r;\n\t r = r2;\n\t r2 = t;\n\t if (--i < 0) {\n\t i = this.DB - 1;\n\t --j;\n\t }\n\t }\n\t }\n\t return z.revert(r);\n\t}\n\t\n\t// protected\n\tBigInteger.prototype.copyTo = bnpCopyTo;\n\tBigInteger.prototype.fromInt = bnpFromInt;\n\tBigInteger.prototype.fromString = bnpFromString;\n\tBigInteger.prototype.clamp = bnpClamp;\n\tBigInteger.prototype.dlShiftTo = bnpDLShiftTo;\n\tBigInteger.prototype.drShiftTo = bnpDRShiftTo;\n\tBigInteger.prototype.lShiftTo = bnpLShiftTo;\n\tBigInteger.prototype.rShiftTo = bnpRShiftTo;\n\tBigInteger.prototype.subTo = bnpSubTo;\n\tBigInteger.prototype.multiplyTo = bnpMultiplyTo;\n\tBigInteger.prototype.squareTo = bnpSquareTo;\n\tBigInteger.prototype.divRemTo = bnpDivRemTo;\n\tBigInteger.prototype.invDigit = bnpInvDigit;\n\tBigInteger.prototype.addTo = bnpAddTo;\n\t\n\t// public\n\tBigInteger.prototype.toString = bnToString;\n\tBigInteger.prototype.negate = bnNegate;\n\tBigInteger.prototype.abs = bnAbs;\n\tBigInteger.prototype.compareTo = bnCompareTo;\n\tBigInteger.prototype.bitLength = bnBitLength;\n\tBigInteger.prototype.mod = bnMod;\n\tBigInteger.prototype.equals = bnEquals;\n\tBigInteger.prototype.add = bnAdd;\n\tBigInteger.prototype.subtract = bnSubtract;\n\tBigInteger.prototype.multiply = bnMultiply;\n\tBigInteger.prototype.divide = bnDivide;\n\tBigInteger.prototype.modPow = bnModPow;\n\t\n\t// \"constants\"\n\tBigInteger.ZERO = nbv(0);\n\tBigInteger.ONE = nbv(1);\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tvar _global = __webpack_require__(1);\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } } /*\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar CognitoAccessToken = function () {\n\t /**\n\t * Constructs a new CognitoAccessToken object\n\t * @param {string=} AccessToken The JWT access token.\n\t */\n\t function CognitoAccessToken() {\n\t var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n\t AccessToken = _ref.AccessToken;\n\t\n\t _classCallCheck(this, CognitoAccessToken);\n\t\n\t // Assign object\n\t this.jwtToken = AccessToken || '';\n\t }\n\t\n\t /**\n\t * @returns {string} the record's token.\n\t */\n\t\n\t\n\t CognitoAccessToken.prototype.getJwtToken = function getJwtToken() {\n\t return this.jwtToken;\n\t };\n\t\n\t /**\n\t * @returns {int} the token's expiration (exp member).\n\t */\n\t\n\t\n\t CognitoAccessToken.prototype.getExpiration = function getExpiration() {\n\t var payload = this.jwtToken.split('.')[1];\n\t var expiration = JSON.parse(_global.util.base64.decode(payload).toString('utf8'));\n\t return expiration.exp;\n\t };\n\t\n\t return CognitoAccessToken;\n\t}();\n\t\n\texports.default = CognitoAccessToken;\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tvar _global = __webpack_require__(1);\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } } /*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar CognitoIdToken = function () {\n\t /**\n\t * Constructs a new CognitoIdToken object\n\t * @param {string=} IdToken The JWT Id token\n\t */\n\t function CognitoIdToken() {\n\t var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n\t IdToken = _ref.IdToken;\n\t\n\t _classCallCheck(this, CognitoIdToken);\n\t\n\t // Assign object\n\t this.jwtToken = IdToken || '';\n\t }\n\t\n\t /**\n\t * @returns {string} the record's token.\n\t */\n\t\n\t\n\t CognitoIdToken.prototype.getJwtToken = function getJwtToken() {\n\t return this.jwtToken;\n\t };\n\t\n\t /**\n\t * @returns {int} the token's expiration (exp member).\n\t */\n\t\n\t\n\t CognitoIdToken.prototype.getExpiration = function getExpiration() {\n\t var payload = this.jwtToken.split('.')[1];\n\t var expiration = JSON.parse(_global.util.base64.decode(payload).toString('utf8'));\n\t return expiration.exp;\n\t };\n\t\n\t return CognitoIdToken;\n\t}();\n\t\n\texports.default = CognitoIdToken;\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar CognitoRefreshToken = function () {\n\t /**\n\t * Constructs a new CognitoRefreshToken object\n\t * @param {string=} RefreshToken The JWT refresh token.\n\t */\n\t function CognitoRefreshToken() {\n\t var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n\t RefreshToken = _ref.RefreshToken;\n\t\n\t _classCallCheck(this, CognitoRefreshToken);\n\t\n\t // Assign object\n\t this.token = RefreshToken || '';\n\t }\n\t\n\t /**\n\t * @returns {string} the record's token.\n\t */\n\t\n\t\n\t CognitoRefreshToken.prototype.getToken = function getToken() {\n\t return this.token;\n\t };\n\t\n\t return CognitoRefreshToken;\n\t}();\n\t\n\texports.default = CognitoRefreshToken;\n\n/***/ }),\n/* 7 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tvar _global = __webpack_require__(1);\n\t\n\tvar _BigInteger = __webpack_require__(3);\n\t\n\tvar _BigInteger2 = _interopRequireDefault(_BigInteger);\n\t\n\tvar _AuthenticationHelper = __webpack_require__(2);\n\t\n\tvar _AuthenticationHelper2 = _interopRequireDefault(_AuthenticationHelper);\n\t\n\tvar _CognitoAccessToken = __webpack_require__(4);\n\t\n\tvar _CognitoAccessToken2 = _interopRequireDefault(_CognitoAccessToken);\n\t\n\tvar _CognitoIdToken = __webpack_require__(5);\n\t\n\tvar _CognitoIdToken2 = _interopRequireDefault(_CognitoIdToken);\n\t\n\tvar _CognitoRefreshToken = __webpack_require__(6);\n\t\n\tvar _CognitoRefreshToken2 = _interopRequireDefault(_CognitoRefreshToken);\n\t\n\tvar _CognitoUserSession = __webpack_require__(9);\n\t\n\tvar _CognitoUserSession2 = _interopRequireDefault(_CognitoUserSession);\n\t\n\tvar _DateHelper = __webpack_require__(10);\n\t\n\tvar _DateHelper2 = _interopRequireDefault(_DateHelper);\n\t\n\tvar _CognitoUserAttribute = __webpack_require__(8);\n\t\n\tvar _CognitoUserAttribute2 = _interopRequireDefault(_CognitoUserAttribute);\n\t\n\tvar _StorageHelper = __webpack_require__(11);\n\t\n\tvar _StorageHelper2 = _interopRequireDefault(_StorageHelper);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } } /*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/**\n\t * @callback nodeCallback\n\t * @template T result\n\t * @param {*} err The operation failure reason, or null.\n\t * @param {T} result The operation result.\n\t */\n\t\n\t/**\n\t * @callback onFailure\n\t * @param {*} err Failure reason.\n\t */\n\t\n\t/**\n\t * @callback onSuccess\n\t * @template T result\n\t * @param {T} result The operation result.\n\t */\n\t\n\t/**\n\t * @callback mfaRequired\n\t * @param {*} details MFA challenge details.\n\t */\n\t\n\t/**\n\t * @callback customChallenge\n\t * @param {*} details Custom challenge details.\n\t */\n\t\n\t/**\n\t * @callback inputVerificationCode\n\t * @param {*} data Server response.\n\t */\n\t\n\t/**\n\t * @callback authSuccess\n\t * @param {CognitoUserSession} session The new session.\n\t * @param {bool=} userConfirmationNecessary User must be confirmed.\n\t */\n\t\n\t/** @class */\n\tvar CognitoUser = function () {\n\t /**\n\t * Constructs a new CognitoUser object\n\t * @param {object} data Creation options\n\t * @param {string} data.Username The user's username.\n\t * @param {CognitoUserPool} data.Pool Pool containing the user.\n\t * @param {object} data.Storage Optional storage object.\n\t */\n\t function CognitoUser(data) {\n\t _classCallCheck(this, CognitoUser);\n\t\n\t if (data == null || data.Username == null || data.Pool == null) {\n\t throw new Error('Username and pool information are required.');\n\t }\n\t\n\t this.username = data.Username || '';\n\t this.pool = data.Pool;\n\t this.Session = null;\n\t\n\t this.client = data.Pool.client;\n\t\n\t this.signInUserSession = null;\n\t this.authenticationFlowType = 'USER_SRP_AUTH';\n\t\n\t this.storage = this.pool.getStorage();\n\t }\n\t\n\t /**\n\t * @returns {CognitoUserSession} the current session for this user\n\t */\n\t\n\t\n\t CognitoUser.prototype.getSignInUserSession = function getSignInUserSession() {\n\t return this.signInUserSession;\n\t };\n\t\n\t /**\n\t * @returns {string} the user's username\n\t */\n\t\n\t\n\t CognitoUser.prototype.getUsername = function getUsername() {\n\t return this.username;\n\t };\n\t\n\t /**\n\t * @returns {String} the authentication flow type\n\t */\n\t\n\t\n\t CognitoUser.prototype.getAuthenticationFlowType = function getAuthenticationFlowType() {\n\t return this.authenticationFlowType;\n\t };\n\t\n\t /**\n\t * sets authentication flow type\n\t * @param {string} authenticationFlowType New value.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.setAuthenticationFlowType = function setAuthenticationFlowType(authenticationFlowType) {\n\t this.authenticationFlowType = authenticationFlowType;\n\t };\n\t\n\t /**\n\t * This is used for authenticating the user. it calls the AuthenticationHelper for SRP related\n\t * stuff\n\t * @param {AuthenticationDetails} authDetails Contains the authentication data\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {newPasswordRequired} callback.newPasswordRequired new\n\t * password and any required attributes are required to continue\n\t * @param {mfaRequired} callback.mfaRequired MFA code\n\t * required to continue.\n\t * @param {customChallenge} callback.customChallenge Custom challenge\n\t * response required to continue.\n\t * @param {authSuccess} callback.onSuccess Called on success with the new session.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.authenticateUser = function authenticateUser(authDetails, callback) {\n\t var _this = this;\n\t\n\t var authenticationHelper = new _AuthenticationHelper2.default(this.pool.getUserPoolId().split('_')[1]);\n\t var dateHelper = new _DateHelper2.default();\n\t\n\t var serverBValue = void 0;\n\t var salt = void 0;\n\t var authParameters = {};\n\t\n\t if (this.deviceKey != null) {\n\t authParameters.DEVICE_KEY = this.deviceKey;\n\t }\n\t\n\t authParameters.USERNAME = this.username;\n\t authParameters.SRP_A = authenticationHelper.getLargeAValue().toString(16);\n\t\n\t if (this.authenticationFlowType === 'CUSTOM_AUTH') {\n\t authParameters.CHALLENGE_NAME = 'SRP_A';\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('initiateAuth', {\n\t AuthFlow: this.authenticationFlowType,\n\t ClientId: this.pool.getClientId(),\n\t AuthParameters: authParameters,\n\t ClientMetadata: authDetails.getValidationData()\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t\n\t var challengeParameters = data.ChallengeParameters;\n\t\n\t _this.username = challengeParameters.USER_ID_FOR_SRP;\n\t serverBValue = new _BigInteger2.default(challengeParameters.SRP_B, 16);\n\t salt = new _BigInteger2.default(challengeParameters.SALT, 16);\n\t _this.getCachedDeviceKeyAndPassword();\n\t\n\t var hkdf = authenticationHelper.getPasswordAuthenticationKey(_this.username, authDetails.getPassword(), serverBValue, salt);\n\t\n\t var dateNow = dateHelper.getNowString();\n\t\n\t var signatureString = _global.util.crypto.hmac(hkdf, _global.util.buffer.concat([new _global.util.Buffer(_this.pool.getUserPoolId().split('_')[1], 'utf8'), new _global.util.Buffer(_this.username, 'utf8'), new _global.util.Buffer(challengeParameters.SECRET_BLOCK, 'base64'), new _global.util.Buffer(dateNow, 'utf8')]), 'base64', 'sha256');\n\t\n\t var challengeResponses = {};\n\t\n\t challengeResponses.USERNAME = _this.username;\n\t challengeResponses.PASSWORD_CLAIM_SECRET_BLOCK = challengeParameters.SECRET_BLOCK;\n\t challengeResponses.TIMESTAMP = dateNow;\n\t challengeResponses.PASSWORD_CLAIM_SIGNATURE = signatureString;\n\t\n\t if (_this.deviceKey != null) {\n\t challengeResponses.DEVICE_KEY = _this.deviceKey;\n\t }\n\t\n\t var respondToAuthChallenge = function respondToAuthChallenge(challenge, challengeCallback) {\n\t return _this.client.makeUnauthenticatedRequest('respondToAuthChallenge', challenge, function (errChallenge, dataChallenge) {\n\t if (errChallenge && errChallenge.code === 'ResourceNotFoundException' && errChallenge.message.toLowerCase().indexOf('device') !== -1) {\n\t challengeResponses.DEVICE_KEY = null;\n\t _this.deviceKey = null;\n\t _this.randomPassword = null;\n\t _this.deviceGroupKey = null;\n\t _this.clearCachedDeviceKeyAndPassword();\n\t return respondToAuthChallenge(challenge, challengeCallback);\n\t }\n\t return challengeCallback(errChallenge, dataChallenge);\n\t });\n\t };\n\t\n\t respondToAuthChallenge({\n\t ChallengeName: 'PASSWORD_VERIFIER',\n\t ClientId: _this.pool.getClientId(),\n\t ChallengeResponses: challengeResponses,\n\t Session: data.Session\n\t }, function (errAuthenticate, dataAuthenticate) {\n\t if (errAuthenticate) {\n\t return callback.onFailure(errAuthenticate);\n\t }\n\t\n\t var challengeName = dataAuthenticate.ChallengeName;\n\t if (challengeName === 'NEW_PASSWORD_REQUIRED') {\n\t _this.Session = dataAuthenticate.Session;\n\t var userAttributes = null;\n\t var rawRequiredAttributes = null;\n\t var requiredAttributes = [];\n\t var userAttributesPrefix = authenticationHelper.getNewPasswordRequiredChallengeUserAttributePrefix();\n\t\n\t if (dataAuthenticate.ChallengeParameters) {\n\t userAttributes = JSON.parse(dataAuthenticate.ChallengeParameters.userAttributes);\n\t rawRequiredAttributes = JSON.parse(dataAuthenticate.ChallengeParameters.requiredAttributes);\n\t }\n\t\n\t if (rawRequiredAttributes) {\n\t for (var i = 0; i < rawRequiredAttributes.length; i++) {\n\t requiredAttributes[i] = rawRequiredAttributes[i].substr(userAttributesPrefix.length);\n\t }\n\t }\n\t return callback.newPasswordRequired(userAttributes, requiredAttributes);\n\t }\n\t return _this.authenticateUserInternal(dataAuthenticate, authenticationHelper, callback);\n\t });\n\t return undefined;\n\t });\n\t };\n\t\n\t /**\n\t * PRIVATE ONLY: This is an internal only method and should not\n\t * be directly called by the consumers.\n\t * @param {object} dataAuthenticate authentication data\n\t * @param {object} authenticationHelper helper created\n\t * @param {callback} callback passed on from caller\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.authenticateUserInternal = function authenticateUserInternal(dataAuthenticate, authenticationHelper, callback) {\n\t var _this2 = this;\n\t\n\t var challengeName = dataAuthenticate.ChallengeName;\n\t var challengeParameters = dataAuthenticate.ChallengeParameters;\n\t\n\t if (challengeName === 'SMS_MFA') {\n\t this.Session = dataAuthenticate.Session;\n\t return callback.mfaRequired(challengeName, challengeParameters);\n\t }\n\t\n\t if (challengeName === 'CUSTOM_CHALLENGE') {\n\t this.Session = dataAuthenticate.Session;\n\t return callback.customChallenge(challengeParameters);\n\t }\n\t\n\t if (challengeName === 'DEVICE_SRP_AUTH') {\n\t this.getDeviceResponse(callback);\n\t return undefined;\n\t }\n\t\n\t this.signInUserSession = this.getCognitoUserSession(dataAuthenticate.AuthenticationResult);\n\t this.cacheTokens();\n\t\n\t var newDeviceMetadata = dataAuthenticate.AuthenticationResult.NewDeviceMetadata;\n\t if (newDeviceMetadata == null) {\n\t return callback.onSuccess(this.signInUserSession);\n\t }\n\t\n\t authenticationHelper.generateHashDevice(dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey, dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey);\n\t\n\t var deviceSecretVerifierConfig = {\n\t Salt: new _global.util.Buffer(authenticationHelper.getSaltDevices(), 'hex').toString('base64'),\n\t PasswordVerifier: new _global.util.Buffer(authenticationHelper.getVerifierDevices(), 'hex').toString('base64')\n\t };\n\t\n\t this.verifierDevices = deviceSecretVerifierConfig.PasswordVerifier;\n\t this.deviceGroupKey = newDeviceMetadata.DeviceGroupKey;\n\t this.randomPassword = authenticationHelper.getRandomPassword();\n\t\n\t this.client.makeUnauthenticatedRequest('confirmDevice', {\n\t DeviceKey: newDeviceMetadata.DeviceKey,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t DeviceSecretVerifierConfig: deviceSecretVerifierConfig,\n\t DeviceName: navigator.userAgent\n\t }, function (errConfirm, dataConfirm) {\n\t if (errConfirm) {\n\t return callback.onFailure(errConfirm);\n\t }\n\t\n\t _this2.deviceKey = dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey;\n\t _this2.cacheDeviceKeyAndPassword();\n\t if (dataConfirm.UserConfirmationNecessary === true) {\n\t return callback.onSuccess(_this2.signInUserSession, dataConfirm.UserConfirmationNecessary);\n\t }\n\t return callback.onSuccess(_this2.signInUserSession);\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This method is user to complete the NEW_PASSWORD_REQUIRED challenge.\n\t * Pass the new password with any new user attributes to be updated.\n\t * User attribute keys must be of format userAttributes..\n\t * @param {string} newPassword new password for this user\n\t * @param {object} requiredAttributeData map with values for all required attributes\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {mfaRequired} callback.mfaRequired MFA code required to continue.\n\t * @param {customChallenge} callback.customChallenge Custom challenge\n\t * response required to continue.\n\t * @param {authSuccess} callback.onSuccess Called on success with the new session.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.completeNewPasswordChallenge = function completeNewPasswordChallenge(newPassword, requiredAttributeData, callback) {\n\t var _this3 = this;\n\t\n\t if (!newPassword) {\n\t return callback.onFailure(new Error('New password is required.'));\n\t }\n\t var authenticationHelper = new _AuthenticationHelper2.default(this.pool.getUserPoolId().split('_')[1]);\n\t var userAttributesPrefix = authenticationHelper.getNewPasswordRequiredChallengeUserAttributePrefix();\n\t\n\t var finalUserAttributes = {};\n\t if (requiredAttributeData) {\n\t Object.keys(requiredAttributeData).forEach(function (key) {\n\t finalUserAttributes[userAttributesPrefix + key] = requiredAttributeData[key];\n\t });\n\t }\n\t\n\t finalUserAttributes.NEW_PASSWORD = newPassword;\n\t finalUserAttributes.USERNAME = this.username;\n\t this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n\t ChallengeName: 'NEW_PASSWORD_REQUIRED',\n\t ClientId: this.pool.getClientId(),\n\t ChallengeResponses: finalUserAttributes,\n\t Session: this.Session\n\t }, function (errAuthenticate, dataAuthenticate) {\n\t if (errAuthenticate) {\n\t return callback.onFailure(errAuthenticate);\n\t }\n\t return _this3.authenticateUserInternal(dataAuthenticate, authenticationHelper, callback);\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to get a session using device authentication. It is called at the end of user\n\t * authentication\n\t *\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {authSuccess} callback.onSuccess Called on success with the new session.\n\t * @returns {void}\n\t * @private\n\t */\n\t\n\t\n\t CognitoUser.prototype.getDeviceResponse = function getDeviceResponse(callback) {\n\t var _this4 = this;\n\t\n\t var authenticationHelper = new _AuthenticationHelper2.default(this.deviceGroupKey);\n\t var dateHelper = new _DateHelper2.default();\n\t\n\t var authParameters = {};\n\t\n\t authParameters.USERNAME = this.username;\n\t authParameters.DEVICE_KEY = this.deviceKey;\n\t authParameters.SRP_A = authenticationHelper.getLargeAValue().toString(16);\n\t\n\t this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n\t ChallengeName: 'DEVICE_SRP_AUTH',\n\t ClientId: this.pool.getClientId(),\n\t ChallengeResponses: authParameters\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t\n\t var challengeParameters = data.ChallengeParameters;\n\t\n\t var serverBValue = new _BigInteger2.default(challengeParameters.SRP_B, 16);\n\t var salt = new _BigInteger2.default(challengeParameters.SALT, 16);\n\t\n\t var hkdf = authenticationHelper.getPasswordAuthenticationKey(_this4.deviceKey, _this4.randomPassword, serverBValue, salt);\n\t\n\t var dateNow = dateHelper.getNowString();\n\t\n\t var signatureString = _global.util.crypto.hmac(hkdf, _global.util.buffer.concat([new _global.util.Buffer(_this4.deviceGroupKey, 'utf8'), new _global.util.Buffer(_this4.deviceKey, 'utf8'), new _global.util.Buffer(challengeParameters.SECRET_BLOCK, 'base64'), new _global.util.Buffer(dateNow, 'utf8')]), 'base64', 'sha256');\n\t\n\t var challengeResponses = {};\n\t\n\t challengeResponses.USERNAME = _this4.username;\n\t challengeResponses.PASSWORD_CLAIM_SECRET_BLOCK = challengeParameters.SECRET_BLOCK;\n\t challengeResponses.TIMESTAMP = dateNow;\n\t challengeResponses.PASSWORD_CLAIM_SIGNATURE = signatureString;\n\t challengeResponses.DEVICE_KEY = _this4.deviceKey;\n\t\n\t _this4.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n\t ChallengeName: 'DEVICE_PASSWORD_VERIFIER',\n\t ClientId: _this4.pool.getClientId(),\n\t ChallengeResponses: challengeResponses,\n\t Session: data.Session\n\t }, function (errAuthenticate, dataAuthenticate) {\n\t if (errAuthenticate) {\n\t return callback.onFailure(errAuthenticate);\n\t }\n\t\n\t _this4.signInUserSession = _this4.getCognitoUserSession(dataAuthenticate.AuthenticationResult);\n\t _this4.cacheTokens();\n\t\n\t return callback.onSuccess(_this4.signInUserSession);\n\t });\n\t return undefined;\n\t });\n\t };\n\t\n\t /**\n\t * This is used for a certain user to confirm the registration by using a confirmation code\n\t * @param {string} confirmationCode Code entered by user.\n\t * @param {bool} forceAliasCreation Allow migrating from an existing email / phone number.\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.confirmRegistration = function confirmRegistration(confirmationCode, forceAliasCreation, callback) {\n\t this.client.makeUnauthenticatedRequest('confirmSignUp', {\n\t ClientId: this.pool.getClientId(),\n\t ConfirmationCode: confirmationCode,\n\t Username: this.username,\n\t ForceAliasCreation: forceAliasCreation\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t return callback(null, 'SUCCESS');\n\t });\n\t };\n\t\n\t /**\n\t * This is used by the user once he has the responses to a custom challenge\n\t * @param {string} answerChallenge The custom challange answer.\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {customChallenge} callback.customChallenge\n\t * Custom challenge response required to continue.\n\t * @param {authSuccess} callback.onSuccess Called on success with the new session.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.sendCustomChallengeAnswer = function sendCustomChallengeAnswer(answerChallenge, callback) {\n\t var _this5 = this;\n\t\n\t var challengeResponses = {};\n\t challengeResponses.USERNAME = this.username;\n\t challengeResponses.ANSWER = answerChallenge;\n\t\n\t this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n\t ChallengeName: 'CUSTOM_CHALLENGE',\n\t ChallengeResponses: challengeResponses,\n\t ClientId: this.pool.getClientId(),\n\t Session: this.Session\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t\n\t var challengeName = data.ChallengeName;\n\t\n\t if (challengeName === 'CUSTOM_CHALLENGE') {\n\t _this5.Session = data.Session;\n\t return callback.customChallenge(data.ChallengeParameters);\n\t }\n\t\n\t _this5.signInUserSession = _this5.getCognitoUserSession(data.AuthenticationResult);\n\t _this5.cacheTokens();\n\t return callback.onSuccess(_this5.signInUserSession);\n\t });\n\t };\n\t\n\t /**\n\t * This is used by the user once he has an MFA code\n\t * @param {string} confirmationCode The MFA code entered by the user.\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {authSuccess} callback.onSuccess Called on success with the new session.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.sendMFACode = function sendMFACode(confirmationCode, callback) {\n\t var _this6 = this;\n\t\n\t var challengeResponses = {};\n\t challengeResponses.USERNAME = this.username;\n\t challengeResponses.SMS_MFA_CODE = confirmationCode;\n\t\n\t if (this.deviceKey != null) {\n\t challengeResponses.DEVICE_KEY = this.deviceKey;\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n\t ChallengeName: 'SMS_MFA',\n\t ChallengeResponses: challengeResponses,\n\t ClientId: this.pool.getClientId(),\n\t Session: this.Session\n\t }, function (err, dataAuthenticate) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t\n\t var challengeName = dataAuthenticate.ChallengeName;\n\t\n\t if (challengeName === 'DEVICE_SRP_AUTH') {\n\t _this6.getDeviceResponse(callback);\n\t return undefined;\n\t }\n\t\n\t _this6.signInUserSession = _this6.getCognitoUserSession(dataAuthenticate.AuthenticationResult);\n\t _this6.cacheTokens();\n\t\n\t if (dataAuthenticate.AuthenticationResult.NewDeviceMetadata == null) {\n\t return callback.onSuccess(_this6.signInUserSession);\n\t }\n\t\n\t var authenticationHelper = new _AuthenticationHelper2.default(_this6.pool.getUserPoolId().split('_')[1]);\n\t authenticationHelper.generateHashDevice(dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey, dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey);\n\t\n\t var deviceSecretVerifierConfig = {\n\t Salt: new _global.util.Buffer(authenticationHelper.getSaltDevices(), 'hex').toString('base64'),\n\t PasswordVerifier: new _global.util.Buffer(authenticationHelper.getVerifierDevices(), 'hex').toString('base64')\n\t };\n\t\n\t _this6.verifierDevices = deviceSecretVerifierConfig.PasswordVerifier;\n\t _this6.deviceGroupKey = dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey;\n\t _this6.randomPassword = authenticationHelper.getRandomPassword();\n\t\n\t _this6.client.makeUnauthenticatedRequest('confirmDevice', {\n\t DeviceKey: dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey,\n\t AccessToken: _this6.signInUserSession.getAccessToken().getJwtToken(),\n\t DeviceSecretVerifierConfig: deviceSecretVerifierConfig,\n\t DeviceName: navigator.userAgent\n\t }, function (errConfirm, dataConfirm) {\n\t if (errConfirm) {\n\t return callback.onFailure(errConfirm);\n\t }\n\t\n\t _this6.deviceKey = dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey;\n\t _this6.cacheDeviceKeyAndPassword();\n\t if (dataConfirm.UserConfirmationNecessary === true) {\n\t return callback.onSuccess(_this6.signInUserSession, dataConfirm.UserConfirmationNecessary);\n\t }\n\t return callback.onSuccess(_this6.signInUserSession);\n\t });\n\t return undefined;\n\t });\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to change the current password\n\t * @param {string} oldUserPassword The current password.\n\t * @param {string} newUserPassword The requested new password.\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.changePassword = function changePassword(oldUserPassword, newUserPassword, callback) {\n\t if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('changePassword', {\n\t PreviousPassword: oldUserPassword,\n\t ProposedPassword: newUserPassword,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t return callback(null, 'SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to enable MFA for himself\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.enableMFA = function enableMFA(callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t var mfaOptions = [];\n\t var mfaEnabled = {\n\t DeliveryMedium: 'SMS',\n\t AttributeName: 'phone_number'\n\t };\n\t mfaOptions.push(mfaEnabled);\n\t\n\t this.client.makeUnauthenticatedRequest('setUserSettings', {\n\t MFAOptions: mfaOptions,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t return callback(null, 'SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to disable MFA for himself\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.disableMFA = function disableMFA(callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t var mfaOptions = [];\n\t\n\t this.client.makeUnauthenticatedRequest('setUserSettings', {\n\t MFAOptions: mfaOptions,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t return callback(null, 'SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to delete himself\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.deleteUser = function deleteUser(callback) {\n\t var _this7 = this;\n\t\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('deleteUser', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t _this7.clearCachedTokens();\n\t return callback(null, 'SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * @typedef {CognitoUserAttribute | { Name:string, Value:string }} AttributeArg\n\t */\n\t /**\n\t * This is used by an authenticated user to change a list of attributes\n\t * @param {AttributeArg[]} attributes A list of the new user attributes.\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.updateAttributes = function updateAttributes(attributes, callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('updateUserAttributes', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t UserAttributes: attributes\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t return callback(null, 'SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to get a list of attributes\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.getUserAttributes = function getUserAttributes(callback) {\n\t if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('getUser', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err, userData) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t\n\t var attributeList = [];\n\t\n\t for (var i = 0; i < userData.UserAttributes.length; i++) {\n\t var attribute = {\n\t Name: userData.UserAttributes[i].Name,\n\t Value: userData.UserAttributes[i].Value\n\t };\n\t var userAttribute = new _CognitoUserAttribute2.default(attribute);\n\t attributeList.push(userAttribute);\n\t }\n\t\n\t return callback(null, attributeList);\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to get the MFAOptions\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.getMFAOptions = function getMFAOptions(callback) {\n\t if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('getUser', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err, userData) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t\n\t return callback(null, userData.MFAOptions);\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by an authenticated user to delete a list of attributes\n\t * @param {string[]} attributeList Names of the attributes to delete.\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.deleteAttributes = function deleteAttributes(attributeList, callback) {\n\t if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n\t return callback(new Error('User is not authenticated'), null);\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('deleteUserAttributes', {\n\t UserAttributeNames: attributeList,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t return callback(null, 'SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used by a user to resend a confirmation code\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.resendConfirmationCode = function resendConfirmationCode(callback) {\n\t this.client.makeUnauthenticatedRequest('resendConfirmationCode', {\n\t ClientId: this.pool.getClientId(),\n\t Username: this.username\n\t }, function (err) {\n\t if (err, result) {\n\t return callback(err, null);\n\t }\n\t return callback(null, result);\n\t });\n\t };\n\t\n\t /**\n\t * This is used to get a session, either from the session object\n\t * or from the local storage, or by using a refresh token\n\t *\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.getSession = function getSession(callback) {\n\t if (this.username == null) {\n\t return callback(new Error('Username is null. Cannot retrieve a new session'), null);\n\t }\n\t\n\t if (this.signInUserSession != null && this.signInUserSession.isValid()) {\n\t return callback(null, this.signInUserSession);\n\t }\n\t\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId() + '.' + this.username;\n\t var idTokenKey = keyPrefix + '.idToken';\n\t var accessTokenKey = keyPrefix + '.accessToken';\n\t var refreshTokenKey = keyPrefix + '.refreshToken';\n\t\n\t if (this.storage.getItem(idTokenKey)) {\n\t var idToken = new _CognitoIdToken2.default({\n\t IdToken: this.storage.getItem(idTokenKey)\n\t });\n\t var accessToken = new _CognitoAccessToken2.default({\n\t AccessToken: this.storage.getItem(accessTokenKey)\n\t });\n\t var refreshToken = new _CognitoRefreshToken2.default({\n\t RefreshToken: this.storage.getItem(refreshTokenKey)\n\t });\n\t\n\t var sessionData = {\n\t IdToken: idToken,\n\t AccessToken: accessToken,\n\t RefreshToken: refreshToken\n\t };\n\t var cachedSession = new _CognitoUserSession2.default(sessionData);\n\t if (cachedSession.isValid()) {\n\t this.signInUserSession = cachedSession;\n\t return callback(null, this.signInUserSession);\n\t }\n\t\n\t if (refreshToken.getToken() == null) {\n\t return callback(new Error('Cannot retrieve a new session. Please authenticate.'), null);\n\t }\n\t\n\t this.refreshSession(refreshToken, callback);\n\t } else {\n\t callback(new Error('Local storage is missing an ID Token, Please authenticate'), null);\n\t }\n\t\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This uses the refreshToken to retrieve a new session\n\t * @param {CognitoRefreshToken} refreshToken A previous session's refresh token.\n\t * @param {nodeCallback} callback Called on success or error.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.refreshSession = function refreshSession(refreshToken, callback) {\n\t var _this8 = this;\n\t\n\t var authParameters = {};\n\t authParameters.REFRESH_TOKEN = refreshToken.getToken();\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId();\n\t var lastUserKey = keyPrefix + '.LastAuthUser';\n\t\n\t if (this.storage.getItem(lastUserKey)) {\n\t this.username = this.storage.getItem(lastUserKey);\n\t var deviceKeyKey = keyPrefix + '.' + this.username + '.deviceKey';\n\t this.deviceKey = this.storage.getItem(deviceKeyKey);\n\t authParameters.DEVICE_KEY = this.deviceKey;\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('initiateAuth', {\n\t ClientId: this.pool.getClientId(),\n\t AuthFlow: 'REFRESH_TOKEN_AUTH',\n\t AuthParameters: authParameters\n\t }, function (err, authResult) {\n\t if (err) {\n\t if (err.code === 'NotAuthorizedException') {\n\t _this8.clearCachedTokens();\n\t }\n\t return callback(err, null);\n\t }\n\t if (authResult) {\n\t var authenticationResult = authResult.AuthenticationResult;\n\t if (!Object.prototype.hasOwnProperty.call(authenticationResult, 'RefreshToken')) {\n\t authenticationResult.RefreshToken = refreshToken.getToken();\n\t }\n\t _this8.signInUserSession = _this8.getCognitoUserSession(authenticationResult);\n\t _this8.cacheTokens();\n\t return callback(null, _this8.signInUserSession);\n\t }\n\t return undefined;\n\t });\n\t };\n\t\n\t /**\n\t * This is used to save the session tokens to local storage\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.cacheTokens = function cacheTokens() {\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId();\n\t var idTokenKey = keyPrefix + '.' + this.username + '.idToken';\n\t var accessTokenKey = keyPrefix + '.' + this.username + '.accessToken';\n\t var refreshTokenKey = keyPrefix + '.' + this.username + '.refreshToken';\n\t var lastUserKey = keyPrefix + '.LastAuthUser';\n\t\n\t this.storage.setItem(idTokenKey, this.signInUserSession.getIdToken().getJwtToken());\n\t this.storage.setItem(accessTokenKey, this.signInUserSession.getAccessToken().getJwtToken());\n\t this.storage.setItem(refreshTokenKey, this.signInUserSession.getRefreshToken().getToken());\n\t this.storage.setItem(lastUserKey, this.username);\n\t };\n\t\n\t /**\n\t * This is used to cache the device key and device group and device password\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.cacheDeviceKeyAndPassword = function cacheDeviceKeyAndPassword() {\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId() + '.' + this.username;\n\t var deviceKeyKey = keyPrefix + '.deviceKey';\n\t var randomPasswordKey = keyPrefix + '.randomPasswordKey';\n\t var deviceGroupKeyKey = keyPrefix + '.deviceGroupKey';\n\t\n\t this.storage.setItem(deviceKeyKey, this.deviceKey);\n\t this.storage.setItem(randomPasswordKey, this.randomPassword);\n\t this.storage.setItem(deviceGroupKeyKey, this.deviceGroupKey);\n\t };\n\t\n\t /**\n\t * This is used to get current device key and device group and device password\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.getCachedDeviceKeyAndPassword = function getCachedDeviceKeyAndPassword() {\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId() + '.' + this.username;\n\t var deviceKeyKey = keyPrefix + '.deviceKey';\n\t var randomPasswordKey = keyPrefix + '.randomPasswordKey';\n\t var deviceGroupKeyKey = keyPrefix + '.deviceGroupKey';\n\t\n\t if (this.storage.getItem(deviceKeyKey)) {\n\t this.deviceKey = this.storage.getItem(deviceKeyKey);\n\t this.randomPassword = this.storage.getItem(randomPasswordKey);\n\t this.deviceGroupKey = this.storage.getItem(deviceGroupKeyKey);\n\t }\n\t };\n\t\n\t /**\n\t * This is used to clear the device key info from local storage\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.clearCachedDeviceKeyAndPassword = function clearCachedDeviceKeyAndPassword() {\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId() + '.' + this.username;\n\t var deviceKeyKey = keyPrefix + '.deviceKey';\n\t var randomPasswordKey = keyPrefix + '.randomPasswordKey';\n\t var deviceGroupKeyKey = keyPrefix + '.deviceGroupKey';\n\t\n\t this.storage.removeItem(deviceKeyKey);\n\t this.storage.removeItem(randomPasswordKey);\n\t this.storage.removeItem(deviceGroupKeyKey);\n\t };\n\t\n\t /**\n\t * This is used to clear the session tokens from local storage\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.clearCachedTokens = function clearCachedTokens() {\n\t var keyPrefix = 'CognitoIdentityServiceProvider.' + this.pool.getClientId();\n\t var idTokenKey = keyPrefix + '.' + this.username + '.idToken';\n\t var accessTokenKey = keyPrefix + '.' + this.username + '.accessToken';\n\t var refreshTokenKey = keyPrefix + '.' + this.username + '.refreshToken';\n\t var lastUserKey = keyPrefix + '.LastAuthUser';\n\t\n\t this.storage.removeItem(idTokenKey);\n\t this.storage.removeItem(accessTokenKey);\n\t this.storage.removeItem(refreshTokenKey);\n\t this.storage.removeItem(lastUserKey);\n\t };\n\t\n\t /**\n\t * This is used to build a user session from tokens retrieved in the authentication result\n\t * @param {object} authResult Successful auth response from server.\n\t * @returns {CognitoUserSession} The new user session.\n\t * @private\n\t */\n\t\n\t\n\t CognitoUser.prototype.getCognitoUserSession = function getCognitoUserSession(authResult) {\n\t var idToken = new _CognitoIdToken2.default(authResult);\n\t var accessToken = new _CognitoAccessToken2.default(authResult);\n\t var refreshToken = new _CognitoRefreshToken2.default(authResult);\n\t\n\t var sessionData = {\n\t IdToken: idToken,\n\t AccessToken: accessToken,\n\t RefreshToken: refreshToken\n\t };\n\t\n\t return new _CognitoUserSession2.default(sessionData);\n\t };\n\t\n\t /**\n\t * This is used to initiate a forgot password request\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {inputVerificationCode?} callback.inputVerificationCode\n\t * Optional callback raised instead of onSuccess with response data.\n\t * @param {onSuccess?} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.forgotPassword = function forgotPassword(callback) {\n\t this.client.makeUnauthenticatedRequest('forgotPassword', {\n\t ClientId: this.pool.getClientId(),\n\t Username: this.username\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t if (typeof callback.inputVerificationCode === 'function') {\n\t return callback.inputVerificationCode(data);\n\t }\n\t return callback.onSuccess();\n\t });\n\t };\n\t\n\t /**\n\t * This is used to confirm a new password using a confirmationCode\n\t * @param {string} confirmationCode Code entered by user.\n\t * @param {string} newPassword Confirm new password.\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.confirmPassword = function confirmPassword(confirmationCode, newPassword, callback) {\n\t this.client.makeUnauthenticatedRequest('confirmForgotPassword', {\n\t ClientId: this.pool.getClientId(),\n\t Username: this.username,\n\t ConfirmationCode: confirmationCode,\n\t Password: newPassword\n\t }, function (err) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess();\n\t });\n\t };\n\t\n\t /**\n\t * This is used to initiate an attribute confirmation request\n\t * @param {string} attributeName User attribute that needs confirmation.\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {inputVerificationCode} callback.inputVerificationCode Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.getAttributeVerificationCode = function getAttributeVerificationCode(attributeName, callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('getUserAttributeVerificationCode', {\n\t AttributeName: attributeName,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t if (typeof callback.inputVerificationCode === 'function') {\n\t return callback.inputVerificationCode(data);\n\t }\n\t return callback.onSuccess();\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to confirm an attribute using a confirmation code\n\t * @param {string} attributeName Attribute being confirmed.\n\t * @param {string} confirmationCode Code entered by user.\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.verifyAttribute = function verifyAttribute(attributeName, confirmationCode, callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('verifyUserAttribute', {\n\t AttributeName: attributeName,\n\t Code: confirmationCode,\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess('SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to get the device information using the current device key\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess<*>} callback.onSuccess Called on success with device data.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.getDevice = function getDevice(callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('getDevice', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t DeviceKey: this.deviceKey\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess(data);\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to forget a specific device\n\t * @param {string} deviceKey Device key.\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.forgetSpecificDevice = function forgetSpecificDevice(deviceKey, callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('forgetDevice', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t DeviceKey: deviceKey\n\t }, function (err) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess('SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to forget the current device\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.forgetDevice = function forgetDevice(callback) {\n\t var _this9 = this;\n\t\n\t this.forgetSpecificDevice(this.deviceKey, {\n\t onFailure: callback.onFailure,\n\t onSuccess: function onSuccess(result) {\n\t _this9.deviceKey = null;\n\t _this9.deviceGroupKey = null;\n\t _this9.randomPassword = null;\n\t _this9.clearCachedDeviceKeyAndPassword();\n\t return callback.onSuccess(result);\n\t }\n\t });\n\t };\n\t\n\t /**\n\t * This is used to set the device status as remembered\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.setDeviceStatusRemembered = function setDeviceStatusRemembered(callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('updateDeviceStatus', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t DeviceKey: this.deviceKey,\n\t DeviceRememberedStatus: 'remembered'\n\t }, function (err) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess('SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to set the device status as not remembered\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.setDeviceStatusNotRemembered = function setDeviceStatusNotRemembered(callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('updateDeviceStatus', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t DeviceKey: this.deviceKey,\n\t DeviceRememberedStatus: 'not_remembered'\n\t }, function (err) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess('SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to list all devices for a user\n\t *\n\t * @param {int} limit the number of devices returned in a call\n\t * @param {string} paginationToken the pagination token in case any was returned before\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess<*>} callback.onSuccess Called on success with device list.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.listDevices = function listDevices(limit, paginationToken, callback) {\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('listDevices', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n\t Limit: limit,\n\t PaginationToken: paginationToken\n\t }, function (err, data) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t return callback.onSuccess(data);\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used to globally revoke all tokens issued to a user\n\t * @param {object} callback Result callback map.\n\t * @param {onFailure} callback.onFailure Called on any error.\n\t * @param {onSuccess} callback.onSuccess Called on success.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.globalSignOut = function globalSignOut(callback) {\n\t var _this10 = this;\n\t\n\t if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n\t return callback.onFailure(new Error('User is not authenticated'));\n\t }\n\t\n\t this.client.makeUnauthenticatedRequest('globalSignOut', {\n\t AccessToken: this.signInUserSession.getAccessToken().getJwtToken()\n\t }, function (err) {\n\t if (err) {\n\t return callback.onFailure(err);\n\t }\n\t _this10.clearCachedTokens();\n\t return callback.onSuccess('SUCCESS');\n\t });\n\t return undefined;\n\t };\n\t\n\t /**\n\t * This is used for the user to signOut of the application and clear the cached tokens.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUser.prototype.signOut = function signOut() {\n\t this.signInUserSession = null;\n\t this.clearCachedTokens();\n\t };\n\t\n\t return CognitoUser;\n\t}();\n\t\n\texports.default = CognitoUser;\n\n/***/ }),\n/* 8 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar CognitoUserAttribute = function () {\n\t /**\n\t * Constructs a new CognitoUserAttribute object\n\t * @param {string=} Name The record's name\n\t * @param {string=} Value The record's value\n\t */\n\t function CognitoUserAttribute() {\n\t var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n\t Name = _ref.Name,\n\t Value = _ref.Value;\n\t\n\t _classCallCheck(this, CognitoUserAttribute);\n\t\n\t this.Name = Name || '';\n\t this.Value = Value || '';\n\t }\n\t\n\t /**\n\t * @returns {string} the record's value.\n\t */\n\t\n\t\n\t CognitoUserAttribute.prototype.getValue = function getValue() {\n\t return this.Value;\n\t };\n\t\n\t /**\n\t * Sets the record's value.\n\t * @param {string} value The new value.\n\t * @returns {CognitoUserAttribute} The record for method chaining.\n\t */\n\t\n\t\n\t CognitoUserAttribute.prototype.setValue = function setValue(value) {\n\t this.Value = value;\n\t return this;\n\t };\n\t\n\t /**\n\t * @returns {string} the record's name.\n\t */\n\t\n\t\n\t CognitoUserAttribute.prototype.getName = function getName() {\n\t return this.Name;\n\t };\n\t\n\t /**\n\t * Sets the record's name\n\t * @param {string} name The new name.\n\t * @returns {CognitoUserAttribute} The record for method chaining.\n\t */\n\t\n\t\n\t CognitoUserAttribute.prototype.setName = function setName(name) {\n\t this.Name = name;\n\t return this;\n\t };\n\t\n\t /**\n\t * @returns {string} a string representation of the record.\n\t */\n\t\n\t\n\t CognitoUserAttribute.prototype.toString = function toString() {\n\t return JSON.stringify(this);\n\t };\n\t\n\t /**\n\t * @returns {object} a flat object representing the record.\n\t */\n\t\n\t\n\t CognitoUserAttribute.prototype.toJSON = function toJSON() {\n\t return {\n\t Name: this.Name,\n\t Value: this.Value\n\t };\n\t };\n\t\n\t return CognitoUserAttribute;\n\t}();\n\t\n\texports.default = CognitoUserAttribute;\n\n/***/ }),\n/* 9 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar CognitoUserSession = function () {\n\t /**\n\t * Constructs a new CognitoUserSession object\n\t * @param {string} IdToken The session's Id token.\n\t * @param {string=} RefreshToken The session's refresh token.\n\t * @param {string} AccessToken The session's access token.\n\t */\n\t function CognitoUserSession() {\n\t var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n\t IdToken = _ref.IdToken,\n\t RefreshToken = _ref.RefreshToken,\n\t AccessToken = _ref.AccessToken;\n\t\n\t _classCallCheck(this, CognitoUserSession);\n\t\n\t if (AccessToken == null || IdToken == null) {\n\t throw new Error('Id token and Access Token must be present.');\n\t }\n\t\n\t this.idToken = IdToken;\n\t this.refreshToken = RefreshToken;\n\t this.accessToken = AccessToken;\n\t }\n\t\n\t /**\n\t * @returns {CognitoIdToken} the session's Id token\n\t */\n\t\n\t\n\t CognitoUserSession.prototype.getIdToken = function getIdToken() {\n\t return this.idToken;\n\t };\n\t\n\t /**\n\t * @returns {CognitoRefreshToken} the session's refresh token\n\t */\n\t\n\t\n\t CognitoUserSession.prototype.getRefreshToken = function getRefreshToken() {\n\t return this.refreshToken;\n\t };\n\t\n\t /**\n\t * @returns {CognitoAccessToken} the session's access token\n\t */\n\t\n\t\n\t CognitoUserSession.prototype.getAccessToken = function getAccessToken() {\n\t return this.accessToken;\n\t };\n\t\n\t /**\n\t * Checks to see if the session is still valid based on session expiry information found\n\t * in tokens and the current time\n\t * @returns {boolean} if the session is still valid\n\t */\n\t\n\t\n\t CognitoUserSession.prototype.isValid = function isValid() {\n\t var now = Math.floor(new Date() / 1000);\n\t\n\t return now < this.accessToken.getExpiration() && now < this.idToken.getExpiration();\n\t };\n\t\n\t return CognitoUserSession;\n\t}();\n\t\n\texports.default = CognitoUserSession;\n\n/***/ }),\n/* 10 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\tvar monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n\tvar weekNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];\n\t\n\t/** @class */\n\t\n\tvar DateHelper = function () {\n\t function DateHelper() {\n\t _classCallCheck(this, DateHelper);\n\t }\n\t\n\t /**\n\t * @returns {string} The current time in \"ddd MMM D HH:mm:ss UTC YYYY\" format.\n\t */\n\t DateHelper.prototype.getNowString = function getNowString() {\n\t var now = new Date();\n\t\n\t var weekDay = weekNames[now.getUTCDay()];\n\t var month = monthNames[now.getUTCMonth()];\n\t var day = now.getUTCDate();\n\t\n\t var hours = now.getUTCHours();\n\t if (hours < 10) {\n\t hours = '0' + hours;\n\t }\n\t\n\t var minutes = now.getUTCMinutes();\n\t if (minutes < 10) {\n\t minutes = '0' + minutes;\n\t }\n\t\n\t var seconds = now.getUTCSeconds();\n\t if (seconds < 10) {\n\t seconds = '0' + seconds;\n\t }\n\t\n\t var year = now.getUTCFullYear();\n\t\n\t // ddd MMM D HH:mm:ss UTC YYYY\n\t var dateNow = weekDay + ' ' + month + ' ' + day + ' ' + hours + ':' + minutes + ':' + seconds + ' UTC ' + year;\n\t\n\t return dateNow;\n\t };\n\t\n\t return DateHelper;\n\t}();\n\t\n\texports.default = DateHelper;\n\n/***/ }),\n/* 11 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\tvar dataMemory = {};\n\t\n\t/** @class */\n\t\n\tvar MemoryStorage = function () {\n\t function MemoryStorage() {\n\t _classCallCheck(this, MemoryStorage);\n\t }\n\t\n\t /**\n\t * This is used to set a specific item in storage\n\t * @param {string} key - the key for the item\n\t * @param {object} value - the value\n\t * @returns {string} value that was set\n\t */\n\t MemoryStorage.setItem = function setItem(key, value) {\n\t dataMemory[key] = value;\n\t return dataMemory[key];\n\t };\n\t\n\t /**\n\t * This is used to get a specific key from storage\n\t * @param {string} key - the key for the item\n\t * This is used to clear the storage\n\t * @returns {string} the data item\n\t */\n\t\n\t\n\t MemoryStorage.getItem = function getItem(key) {\n\t return Object.prototype.hasOwnProperty.call(dataMemory, key) ? dataMemory[key] : undefined;\n\t };\n\t\n\t /**\n\t * This is used to remove an item from storage\n\t * @param {string} key - the key being set\n\t * @returns {string} value - value that was deleted\n\t */\n\t\n\t\n\t MemoryStorage.removeItem = function removeItem(key) {\n\t return delete dataMemory[key];\n\t };\n\t\n\t /**\n\t * This is used to clear the storage\n\t * @returns {string} nothing\n\t */\n\t\n\t\n\t MemoryStorage.clear = function clear() {\n\t dataMemory = {};\n\t return dataMemory;\n\t };\n\t\n\t return MemoryStorage;\n\t}();\n\t\n\t/** @class */\n\t\n\t\n\tvar StorageHelper = function () {\n\t\n\t /**\n\t * This is used to get a storage object\n\t * @returns {object} the storage\n\t */\n\t function StorageHelper() {\n\t _classCallCheck(this, StorageHelper);\n\t\n\t try {\n\t this.storageWindow = window.localStorage;\n\t this.storageWindow.setItem('aws.cognito.test-ls', 1);\n\t this.storageWindow.removeItem('aws.cognito.test-ls');\n\t } catch (exception) {\n\t this.storageWindow = MemoryStorage;\n\t }\n\t }\n\t\n\t /**\n\t * This is used to return the storage\n\t * @returns {object} the storage\n\t */\n\t\n\t\n\t StorageHelper.prototype.getStorage = function getStorage() {\n\t return this.storageWindow;\n\t };\n\t\n\t return StorageHelper;\n\t}();\n\t\n\texports.default = StorageHelper;\n\n/***/ }),\n/* 12 */\n/***/ (function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_12__;\n\n/***/ }),\n/* 13 */\n/***/ (function(module, exports) {\n\n\t\"use strict\";\n\t\n\texports.__esModule = true;\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar AuthenticationDetails = function () {\n\t /**\n\t * Constructs a new AuthenticationDetails object\n\t * @param {object=} data Creation options.\n\t * @param {string} data.Username User being authenticated.\n\t * @param {string} data.Password Plain-text password to authenticate with.\n\t * @param {(AttributeArg[])?} data.ValidationData Application extra metadata.\n\t */\n\t function AuthenticationDetails(data) {\n\t _classCallCheck(this, AuthenticationDetails);\n\t\n\t var _ref = data || {},\n\t ValidationData = _ref.ValidationData,\n\t Username = _ref.Username,\n\t Password = _ref.Password;\n\t\n\t this.validationData = ValidationData || [];\n\t this.username = Username;\n\t this.password = Password;\n\t }\n\t\n\t /**\n\t * @returns {string} the record's username\n\t */\n\t\n\t\n\t AuthenticationDetails.prototype.getUsername = function getUsername() {\n\t return this.username;\n\t };\n\t\n\t /**\n\t * @returns {string} the record's password\n\t */\n\t\n\t\n\t AuthenticationDetails.prototype.getPassword = function getPassword() {\n\t return this.password;\n\t };\n\t\n\t /**\n\t * @returns {Array} the record's validationData\n\t */\n\t\n\t\n\t AuthenticationDetails.prototype.getValidationData = function getValidationData() {\n\t return this.validationData;\n\t };\n\t\n\t return AuthenticationDetails;\n\t}();\n\t\n\texports.default = AuthenticationDetails;\n\n/***/ }),\n/* 14 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tvar _cognitoidentityserviceprovider = __webpack_require__(12);\n\t\n\tvar _cognitoidentityserviceprovider2 = _interopRequireDefault(_cognitoidentityserviceprovider);\n\t\n\tvar _CognitoUser = __webpack_require__(7);\n\t\n\tvar _CognitoUser2 = _interopRequireDefault(_CognitoUser);\n\t\n\tvar _StorageHelper = __webpack_require__(11);\n\t\n\tvar _StorageHelper2 = _interopRequireDefault(_StorageHelper);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } } /*!\n\t * Copyright 2016 Amazon.com,\n\t * Inc. or its affiliates. All Rights Reserved.\n\t *\n\t * Licensed under the Amazon Software License (the \"License\").\n\t * You may not use this file except in compliance with the\n\t * License. A copy of the License is located at\n\t *\n\t * http://aws.amazon.com/asl/\n\t *\n\t * or in the \"license\" file accompanying this file. This file is\n\t * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n\t * CONDITIONS OF ANY KIND, express or implied. See the License\n\t * for the specific language governing permissions and\n\t * limitations under the License.\n\t */\n\t\n\t/** @class */\n\tvar CognitoUserPool = function () {\n\t /**\n\t * Constructs a new CognitoUserPool object\n\t * @param {object} data Creation options.\n\t * @param {string} data.UserPoolId Cognito user pool id.\n\t * @param {string} data.ClientId User pool application client id.\n\t * @param {object} data.Storage Optional storage object.\n\t */\n\t function CognitoUserPool(data) {\n\t _classCallCheck(this, CognitoUserPool);\n\t\n\t var _ref = data || {},\n\t UserPoolId = _ref.UserPoolId,\n\t ClientId = _ref.ClientId;\n\t\n\t if (!UserPoolId || !ClientId) {\n\t throw new Error('Both UserPoolId and ClientId are required.');\n\t }\n\t if (!/^[\\w-]+_.+$/.test(UserPoolId)) {\n\t throw new Error('Invalid UserPoolId format.');\n\t }\n\t var region = UserPoolId.split('_')[0];\n\t\n\t this.userPoolId = UserPoolId;\n\t this.clientId = ClientId;\n\t\n\t this.client = new _cognitoidentityserviceprovider2.default({ apiVersion: '2016-04-19', region: region });\n\t\n\t this.storage = data.Storage || new _StorageHelper2.default().getStorage();\n\t }\n\t\n\t /**\n\t * @returns {string} the user pool id\n\t */\n\t\n\t\n\t CognitoUserPool.prototype.getUserPoolId = function getUserPoolId() {\n\t return this.userPoolId;\n\t };\n\t\n\t /**\n\t * @returns {string} the client id\n\t */\n\t\n\t\n\t CognitoUserPool.prototype.getClientId = function getClientId() {\n\t return this.clientId;\n\t };\n\t\n\t /**\n\t * @typedef {object} SignUpResult\n\t * @property {CognitoUser} user New user.\n\t * @property {bool} userConfirmed If the user is already confirmed.\n\t */\n\t /**\n\t * method for signing up a user\n\t * @param {string} username User's username.\n\t * @param {string} password Plain-text initial password entered by user.\n\t * @param {(AttributeArg[])=} userAttributes New user attributes.\n\t * @param {(AttributeArg[])=} validationData Application metadata.\n\t * @param {nodeCallback} callback Called on error or with the new user.\n\t * @returns {void}\n\t */\n\t\n\t\n\t CognitoUserPool.prototype.signUp = function signUp(username, password, userAttributes, validationData, callback) {\n\t var _this = this;\n\t\n\t this.client.makeUnauthenticatedRequest('signUp', {\n\t ClientId: this.clientId,\n\t Username: username,\n\t Password: password,\n\t UserAttributes: userAttributes,\n\t ValidationData: validationData\n\t }, function (err, data) {\n\t if (err) {\n\t return callback(err, null);\n\t }\n\t\n\t var cognitoUser = {\n\t Username: username,\n\t Pool: _this\n\t };\n\t\n\t var returnData = {\n\t user: new _CognitoUser2.default(cognitoUser),\n\t userConfirmed: data.UserConfirmed\n\t };\n\t\n\t return callback(null, returnData);\n\t });\n\t };\n\t\n\t /**\n\t * method for getting the current user of the application from the local storage\n\t *\n\t * @returns {CognitoUser} the user retrieved from storage\n\t */\n\t\n\t\n\t CognitoUserPool.prototype.getCurrentUser = function getCurrentUser() {\n\t var lastUserKey = 'CognitoIdentityServiceProvider.' + this.clientId + '.LastAuthUser';\n\t\n\t var lastAuthUser = this.storage.getItem(lastUserKey);\n\t if (lastAuthUser) {\n\t var cognitoUser = {\n\t Username: lastAuthUser,\n\t Pool: this\n\t };\n\t\n\t return new _CognitoUser2.default(cognitoUser);\n\t }\n\t\n\t return null;\n\t };\n\t\n\t /**\n\t * This is used to return the storage\n\t * @returns {object} the storage\n\t */\n\t\n\t\n\t CognitoUserPool.prototype.getStorage = function getStorage() {\n\t return this.storage;\n\t };\n\t\n\t return CognitoUserPool;\n\t}();\n\t\n\texports.default = CognitoUserPool;\n\n/***/ }),\n/* 15 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\texports.__esModule = true;\n\t\n\tvar _AuthenticationDetails = __webpack_require__(13);\n\t\n\tObject.defineProperty(exports, 'AuthenticationDetails', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_AuthenticationDetails).default;\n\t }\n\t});\n\t\n\tvar _AuthenticationHelper = __webpack_require__(2);\n\t\n\tObject.defineProperty(exports, 'AuthenticationHelper', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_AuthenticationHelper).default;\n\t }\n\t});\n\t\n\tvar _CognitoAccessToken = __webpack_require__(4);\n\t\n\tObject.defineProperty(exports, 'CognitoAccessToken', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoAccessToken).default;\n\t }\n\t});\n\t\n\tvar _CognitoIdToken = __webpack_require__(5);\n\t\n\tObject.defineProperty(exports, 'CognitoIdToken', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoIdToken).default;\n\t }\n\t});\n\t\n\tvar _CognitoRefreshToken = __webpack_require__(6);\n\t\n\tObject.defineProperty(exports, 'CognitoRefreshToken', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoRefreshToken).default;\n\t }\n\t});\n\t\n\tvar _CognitoUser = __webpack_require__(7);\n\t\n\tObject.defineProperty(exports, 'CognitoUser', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoUser).default;\n\t }\n\t});\n\t\n\tvar _CognitoUserAttribute = __webpack_require__(8);\n\t\n\tObject.defineProperty(exports, 'CognitoUserAttribute', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoUserAttribute).default;\n\t }\n\t});\n\t\n\tvar _CognitoUserPool = __webpack_require__(14);\n\t\n\tObject.defineProperty(exports, 'CognitoUserPool', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoUserPool).default;\n\t }\n\t});\n\t\n\tvar _CognitoUserSession = __webpack_require__(9);\n\t\n\tObject.defineProperty(exports, 'CognitoUserSession', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_CognitoUserSession).default;\n\t }\n\t});\n\t\n\tvar _DateHelper = __webpack_require__(10);\n\t\n\tObject.defineProperty(exports, 'DateHelper', {\n\t enumerable: true,\n\t get: function get() {\n\t return _interopRequireDefault(_DateHelper).default;\n\t }\n\t});\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/***/ })\n/******/ ])\n});\n;\n\n\n// WEBPACK FOOTER //\n// amazon-cognito-identity.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 2cc185fe7183e923d71f","import CognitoIdentityServiceProvider from 'aws-sdk/clients/cognitoidentityserviceprovider';\nimport * as enhancements from './src';\n\nexport * from './src';\n\nObject.keys(enhancements).forEach(key => {\n CognitoIdentityServiceProvider[key] = enhancements[key];\n});\n\n// The version of crypto-browserify included by aws-sdk only\n// checks for window.crypto, not window.msCrypto as used by\n// IE 11 – so we set it explicitly here\nif (typeof window !== 'undefined' && !window.crypto && window.msCrypto) {\n window.crypto = window.msCrypto;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./enhance.js","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":[\"AWSCognito\"],\"commonjs2\":\"aws-sdk/global\",\"commonjs\":\"aws-sdk/global\",\"amd\":\"aws-sdk/global\"}\n// module id = 1\n// module chunks = 0","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { util } from 'aws-sdk/global';\n\nimport BigInteger from './BigInteger';\n\nconst initN = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1'\n + '29024E088A67CC74020BBEA63B139B22514A08798E3404DD'\n + 'EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245'\n + 'E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED'\n + 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D'\n + 'C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F'\n + '83655D23DCA3AD961C62F356208552BB9ED529077096966D'\n + '670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B'\n + 'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9'\n + 'DE2BCBF6955817183995497CEA956AE515D2261898FA0510'\n + '15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64'\n + 'ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7'\n + 'ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B'\n + 'F12FFA06D98A0864D87602733EC86A64521F2B18177B200C'\n + 'BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31'\n + '43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF';\n\nconst newPasswordRequiredChallengeUserAttributePrefix = 'userAttributes.';\n\n/** @class */\nexport default class AuthenticationHelper {\n /**\n * Constructs a new AuthenticationHelper object\n * @param {string} PoolName Cognito user pool name.\n */\n constructor(PoolName) {\n this.N = new BigInteger(initN, 16);\n this.g = new BigInteger('2', 16);\n this.k = new BigInteger(this.hexHash(`00${this.N.toString(16)}0${this.g.toString(16)}`), 16);\n\n this.smallAValue = this.generateRandomSmallA();\n this.largeAValue = this.calculateA(this.smallAValue);\n\n this.infoBits = new util.Buffer('Caldera Derived Key', 'utf8');\n\n this.poolName = PoolName;\n }\n\n /**\n * @returns {BigInteger} small A, a random number\n */\n getSmallAValue() {\n return this.smallAValue;\n }\n\n /**\n * @returns {BigInteger} large A, a value generated from small A\n */\n getLargeAValue() {\n return this.largeAValue;\n }\n\n /**\n * helper function to generate a random big integer\n * @returns {BigInteger} a random value.\n * @private\n */\n generateRandomSmallA() {\n const hexRandom = util.crypto.lib.randomBytes(128).toString('hex');\n\n const randomBigInt = new BigInteger(hexRandom, 16);\n const smallABigInt = randomBigInt.mod(this.N);\n\n return smallABigInt;\n }\n\n /**\n * helper function to generate a random string\n * @returns {string} a random value.\n * @private\n */\n generateRandomString() {\n return util.crypto.lib.randomBytes(40).toString('base64');\n }\n\n /**\n * @returns {string} Generated random value included in password hash.\n */\n getRandomPassword() {\n return this.randomPassword;\n }\n\n /**\n * @returns {string} Generated random value included in devices hash.\n */\n getSaltDevices() {\n return this.SaltToHashDevices;\n }\n\n /**\n * @returns {string} Value used to verify devices.\n */\n getVerifierDevices() {\n return this.verifierDevices;\n }\n\n /**\n * Generate salts and compute verifier.\n * @param {string} deviceGroupKey Devices to generate verifier for.\n * @param {string} username User to generate verifier for.\n * @returns {void}\n */\n generateHashDevice(deviceGroupKey, username) {\n this.randomPassword = this.generateRandomString();\n const combinedString = `${deviceGroupKey}${username}:${this.randomPassword}`;\n const hashedString = this.hash(combinedString);\n\n const hexRandom = util.crypto.lib.randomBytes(16).toString('hex');\n this.SaltToHashDevices = this.padHex(new BigInteger(hexRandom, 16));\n\n const verifierDevicesNotPadded = this.g.modPow(\n new BigInteger(this.hexHash(this.SaltToHashDevices + hashedString), 16),\n this.N);\n\n this.verifierDevices = this.padHex(verifierDevicesNotPadded);\n }\n\n /**\n * Calculate the client's public value A = g^a%N\n * with the generated random number a\n * @param {BigInteger} a Randomly generated small A.\n * @returns {BigInteger} Computed large A.\n * @private\n */\n calculateA(a) {\n const A = this.g.modPow(a, this.N);\n\n if (A.mod(this.N).equals(BigInteger.ZERO)) {\n throw new Error('Illegal paramater. A mod N cannot be 0.');\n }\n return A;\n }\n\n /**\n * Calculate the client's value U which is the hash of A and B\n * @param {BigInteger} A Large A value.\n * @param {BigInteger} B Server B value.\n * @returns {BigInteger} Computed U value.\n * @private\n */\n calculateU(A, B) {\n this.UHexHash = this.hexHash(this.padHex(A) + this.padHex(B));\n const finalU = new BigInteger(this.UHexHash, 16);\n\n return finalU;\n }\n\n /**\n * Calculate a hash from a bitArray\n * @param {Buffer} buf Value to hash.\n * @returns {String} Hex-encoded hash.\n * @private\n */\n hash(buf) {\n const hashHex = util.crypto.sha256(buf, 'hex');\n return (new Array(64 - hashHex.length).join('0')) + hashHex;\n }\n\n /**\n * Calculate a hash from a hex string\n * @param {String} hexStr Value to hash.\n * @returns {String} Hex-encoded hash.\n * @private\n */\n hexHash(hexStr) {\n return this.hash(new util.Buffer(hexStr, 'hex'));\n }\n\n /**\n * Standard hkdf algorithm\n * @param {Buffer} ikm Input key material.\n * @param {Buffer} salt Salt value.\n * @returns {Buffer} Strong key material.\n * @private\n */\n computehkdf(ikm, salt) {\n const prk = util.crypto.hmac(salt, ikm, 'buffer', 'sha256');\n const infoBitsUpdate = util.buffer.concat([\n this.infoBits,\n new util.Buffer(String.fromCharCode(1), 'utf8'),\n ]);\n const hmac = util.crypto.hmac(prk, infoBitsUpdate, 'buffer', 'sha256');\n return hmac.slice(0, 16);\n }\n\n /**\n * Calculates the final hkdf based on computed S value, and computed U value and the key\n * @param {String} username Username.\n * @param {String} password Password.\n * @param {BigInteger} serverBValue Server B value.\n * @param {BigInteger} salt Generated salt.\n * @returns {Buffer} Computed HKDF value.\n */\n getPasswordAuthenticationKey(username, password, serverBValue, salt) {\n if (serverBValue.mod(this.N).equals(BigInteger.ZERO)) {\n throw new Error('B cannot be zero.');\n }\n\n this.UValue = this.calculateU(this.largeAValue, serverBValue);\n\n if (this.UValue.equals(BigInteger.ZERO)) {\n throw new Error('U cannot be zero.');\n }\n\n const usernamePassword = `${this.poolName}${username}:${password}`;\n const usernamePasswordHash = this.hash(usernamePassword);\n\n const xValue = new BigInteger(this.hexHash(this.padHex(salt) + usernamePasswordHash), 16);\n\n const gModPowXN = this.g.modPow(xValue, this.N);\n const intValue2 = serverBValue.subtract(this.k.multiply(gModPowXN));\n const sValue = intValue2.modPow(\n this.smallAValue.add(this.UValue.multiply(xValue)),\n this.N\n ).mod(this.N);\n\n const hkdf = this.computehkdf(\n new util.Buffer(this.padHex(sValue), 'hex'),\n new util.Buffer(this.padHex(this.UValue.toString(16)), 'hex'));\n\n return hkdf;\n }\n\n /**\n * Return constant newPasswordRequiredChallengeUserAttributePrefix\n * @return {newPasswordRequiredChallengeUserAttributePrefix} constant prefix value\n */\n getNewPasswordRequiredChallengeUserAttributePrefix() {\n return newPasswordRequiredChallengeUserAttributePrefix;\n }\n\n /**\n * Converts a BigInteger (or hex string) to hex format padded with zeroes for hashing\n * @param {BigInteger|String} bigInt Number or string to pad.\n * @returns {String} Padded hex string.\n */\n padHex(bigInt) {\n let hashStr = bigInt.toString(16);\n if (hashStr.length % 2 === 1) {\n hashStr = `0${hashStr}`;\n } else if ('89ABCDEFabcdef'.indexOf(hashStr[0]) !== -1) {\n hashStr = `00${hashStr}`;\n }\n return hashStr;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/AuthenticationHelper.js","// A small implementation of BigInteger based on http://www-cs-students.stanford.edu/~tjw/jsbn/\n//\n// All public methods have been removed except the following:\n// new BigInteger(a, b) (only radix 2, 4, 8, 16 and 32 supported)\n// toString (only radix 2, 4, 8, 16 and 32 supported)\n// negate\n// abs\n// compareTo\n// bitLength\n// mod\n// equals\n// add\n// subtract\n// multiply\n// divide\n// modPow\n\nexport default BigInteger;\n\n/*\n * Copyright (c) 2003-2005 Tom Wu\n * All Rights Reserved.\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS-IS\" AND WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY\n * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.\n *\n * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,\n * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER\n * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF\n * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT\n * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n *\n * In addition, the following condition applies:\n *\n * All redistributions must retain an intact copy of this copyright notice\n * and disclaimer.\n */\n\n// (public) Constructor\nfunction BigInteger(a, b) {\n if (a != null) this.fromString(a, b);\n}\n\n// return new, unset BigInteger\nfunction nbi() {\n return new BigInteger(null);\n}\n\n// am: Compute w_j += (x*this_i), propagate carries,\n// c is initial carry, returns final carry.\n// c < 3*dvalue, x < 2*dvalue, this_i < dvalue\n// We need to select the fastest one that works in this environment.\n// am1: use a single mult and divide to get the high bits,\n// max digit bits should be 26 because\n// max internal value = 2*dvalue^2-2*dvalue (< 2^53)\nfunction am1(i, x, w, j, c, n) {\n while (--n >= 0) {\n var v = x * this[i++] + w[j] + c;\n c = Math.floor(v / 0x4000000);\n w[j++] = v & 0x3ffffff;\n }\n return c;\n}\n\nBigInteger.prototype.am = am1;\n\n// Bits per digit\nvar dbits = 26;\n\nBigInteger.prototype.DB = dbits;\nBigInteger.prototype.DM = (1 << dbits) - 1;\nBigInteger.prototype.DV = 1 << dbits;\n\nvar BI_FP = 52;\nBigInteger.prototype.FV = Math.pow(2, BI_FP);\nBigInteger.prototype.F1 = BI_FP - dbits;\nBigInteger.prototype.F2 = 2 * dbits - BI_FP;\n\n// Digit conversions\nvar BI_RM = \"0123456789abcdefghijklmnopqrstuvwxyz\";\nvar BI_RC = new Array();\nvar rr, vv;\nrr = \"0\".charCodeAt(0);\nfor (vv = 0; vv <= 9; ++vv)\n BI_RC[rr++] = vv;\nrr = \"a\".charCodeAt(0);\nfor (vv = 10; vv < 36; ++vv)\n BI_RC[rr++] = vv;\nrr = \"A\".charCodeAt(0);\nfor (vv = 10; vv < 36; ++vv)\n BI_RC[rr++] = vv;\n\nfunction int2char(n) {\n return BI_RM.charAt(n);\n}\nfunction intAt(s, i) {\n var c = BI_RC[s.charCodeAt(i)];\n return c == null ? -1 : c;\n}\n\n// (protected) copy this to r\nfunction bnpCopyTo(r) {\n for (var i = this.t - 1; i >= 0; --i)\n r[i] = this[i];\n r.t = this.t;\n r.s = this.s;\n}\n\n// (protected) set from integer value x, -DV <= x < DV\nfunction bnpFromInt(x) {\n this.t = 1;\n this.s = x < 0 ? -1 : 0;\n if (x > 0) this[0] = x;\n else if (x < -1) this[0] = x + this.DV;\n else this.t = 0;\n}\n\n// return bigint initialized to value\nfunction nbv(i) {\n var r = nbi();\n\n r.fromInt(i);\n\n return r;\n}\n\n// (protected) set from string and radix\nfunction bnpFromString(s, b) {\n var k;\n if (b == 16) k = 4;\n else if (b == 8) k = 3;\n else if (b == 2) k = 1;\n else if (b == 32) k = 5;\n else if (b == 4) k = 2;\n else throw new Error(\"Only radix 2, 4, 8, 16, 32 are supported\");\n this.t = 0;\n this.s = 0;\n var i = s.length, mi = false, sh = 0;\n while (--i >= 0) {\n var x = intAt(s, i);\n if (x < 0) {\n if (s.charAt(i) == \"-\") mi = true;\n continue;\n }\n mi = false;\n if (sh == 0) this[this.t++] = x;\n else if (sh + k > this.DB) {\n this[this.t - 1] |= (x & (1 << this.DB - sh) - 1) << sh;\n this[this.t++] = x >> this.DB - sh;\n } else this[this.t - 1] |= x << sh;\n sh += k;\n if (sh >= this.DB) sh -= this.DB;\n }\n this.clamp();\n if (mi) BigInteger.ZERO.subTo(this, this);\n}\n\n// (protected) clamp off excess high words\nfunction bnpClamp() {\n var c = this.s & this.DM;\n while (this.t > 0 && this[this.t - 1] == c)\n --this.t;\n}\n\n// (public) return string representation in given radix\nfunction bnToString(b) {\n if (this.s < 0) return \"-\" + this.negate().toString();\n var k;\n if (b == 16) k = 4;\n else if (b == 8) k = 3;\n else if (b == 2) k = 1;\n else if (b == 32) k = 5;\n else if (b == 4) k = 2;\n else throw new Error(\"Only radix 2, 4, 8, 16, 32 are supported\");\n var km = (1 << k) - 1, d, m = false, r = \"\", i = this.t;\n var p = this.DB - i * this.DB % k;\n if (i-- > 0) {\n if (p < this.DB && (d = this[i] >> p) > 0) {\n m = true;\n r = int2char(d);\n }\n while (i >= 0) {\n if (p < k) {\n d = (this[i] & (1 << p) - 1) << k - p;\n d |= this[--i] >> (p += this.DB - k);\n } else {\n d = this[i] >> (p -= k) & km;\n if (p <= 0) {\n p += this.DB;\n --i;\n }\n }\n if (d > 0) m = true;\n if (m) r += int2char(d);\n }\n }\n return m ? r : \"0\";\n}\n\n// (public) -this\nfunction bnNegate() {\n var r = nbi();\n\n BigInteger.ZERO.subTo(this, r);\n\n return r;\n}\n\n// (public) |this|\nfunction bnAbs() {\n return this.s < 0 ? this.negate() : this;\n}\n\n// (public) return + if this > a, - if this < a, 0 if equal\nfunction bnCompareTo(a) {\n var r = this.s - a.s;\n if (r != 0) return r;\n var i = this.t;\n r = i - a.t;\n if (r != 0) return this.s < 0 ? -r : r;\n while (--i >= 0)\n if ((r = this[i] - a[i]) != 0) return r;\n return 0;\n}\n\n// returns bit length of the integer x\nfunction nbits(x) {\n var r = 1, t;\n if ((t = x >>> 16) != 0) {\n x = t;\n r += 16;\n }\n if ((t = x >> 8) != 0) {\n x = t;\n r += 8;\n }\n if ((t = x >> 4) != 0) {\n x = t;\n r += 4;\n }\n if ((t = x >> 2) != 0) {\n x = t;\n r += 2;\n }\n if ((t = x >> 1) != 0) {\n x = t;\n r += 1;\n }\n return r;\n}\n\n// (public) return the number of bits in \"this\"\nfunction bnBitLength() {\n if (this.t <= 0) return 0;\n return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.DM);\n}\n\n// (protected) r = this << n*DB\nfunction bnpDLShiftTo(n, r) {\n var i;\n for (i = this.t - 1; i >= 0; --i)\n r[i + n] = this[i];\n for (i = n - 1; i >= 0; --i)\n r[i] = 0;\n r.t = this.t + n;\n r.s = this.s;\n}\n\n// (protected) r = this >> n*DB\nfunction bnpDRShiftTo(n, r) {\n for (var i = n; i < this.t; ++i)\n r[i - n] = this[i];\n r.t = Math.max(this.t - n, 0);\n r.s = this.s;\n}\n\n// (protected) r = this << n\nfunction bnpLShiftTo(n, r) {\n var bs = n % this.DB;\n var cbs = this.DB - bs;\n var bm = (1 << cbs) - 1;\n var ds = Math.floor(n / this.DB), c = this.s << bs & this.DM, i;\n for (i = this.t - 1; i >= 0; --i) {\n r[i + ds + 1] = this[i] >> cbs | c;\n c = (this[i] & bm) << bs;\n }\n for (i = ds - 1; i >= 0; --i)\n r[i] = 0;\n r[ds] = c;\n r.t = this.t + ds + 1;\n r.s = this.s;\n r.clamp();\n}\n\n// (protected) r = this >> n\nfunction bnpRShiftTo(n, r) {\n r.s = this.s;\n var ds = Math.floor(n / this.DB);\n if (ds >= this.t) {\n r.t = 0;\n return;\n }\n var bs = n % this.DB;\n var cbs = this.DB - bs;\n var bm = (1 << bs) - 1;\n r[0] = this[ds] >> bs;\n for (var i = ds + 1; i < this.t; ++i) {\n r[i - ds - 1] |= (this[i] & bm) << cbs;\n r[i - ds] = this[i] >> bs;\n }\n if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;\n r.t = this.t - ds;\n r.clamp();\n}\n\n// (protected) r = this - a\nfunction bnpSubTo(a, r) {\n var i = 0, c = 0, m = Math.min(a.t, this.t);\n while (i < m) {\n c += this[i] - a[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n if (a.t < this.t) {\n c -= a.s;\n while (i < this.t) {\n c += this[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n c += this.s;\n } else {\n c += this.s;\n while (i < a.t) {\n c -= a[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n c -= a.s;\n }\n r.s = c < 0 ? -1 : 0;\n if (c < -1) r[i++] = this.DV + c;\n else if (c > 0) r[i++] = c;\n r.t = i;\n r.clamp();\n}\n\n// (protected) r = this * a, r != this,a (HAC 14.12)\n// \"this\" should be the larger one if appropriate.\nfunction bnpMultiplyTo(a, r) {\n var x = this.abs(), y = a.abs();\n var i = x.t;\n r.t = i + y.t;\n while (--i >= 0)\n r[i] = 0;\n for (i = 0; i < y.t; ++i)\n r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);\n r.s = 0;\n r.clamp();\n if (this.s != a.s) BigInteger.ZERO.subTo(r, r);\n}\n\n// (protected) r = this^2, r != this (HAC 14.16)\nfunction bnpSquareTo(r) {\n var x = this.abs();\n var i = r.t = 2 * x.t;\n while (--i >= 0)\n r[i] = 0;\n for (i = 0; i < x.t - 1; ++i) {\n var c = x.am(i, x[i], r, 2 * i, 0, 1);\n if (\n (r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >=\n x.DV\n ) {\n r[i + x.t] -= x.DV;\n r[i + x.t + 1] = 1;\n }\n }\n if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);\n r.s = 0;\n r.clamp();\n}\n\n// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)\n// r != q, this != m. q or r may be null.\nfunction bnpDivRemTo(m, q, r) {\n var pm = m.abs();\n if (pm.t <= 0) return;\n var pt = this.abs();\n if (pt.t < pm.t) {\n if (q != null) q.fromInt(0);\n if (r != null) this.copyTo(r);\n return;\n }\n if (r == null) r = nbi();\n var y = nbi(), ts = this.s, ms = m.s;\n var nsh = this.DB - nbits(pm[pm.t - 1]);\n // normalize modulus\n if (nsh > 0) {\n pm.lShiftTo(nsh, y);\n pt.lShiftTo(nsh, r);\n } else {\n pm.copyTo(y);\n pt.copyTo(r);\n }\n var ys = y.t;\n var y0 = y[ys - 1];\n if (y0 == 0) return;\n var yt = y0 * (1 << this.F1) + (ys > 1 ? y[ys - 2] >> this.F2 : 0);\n var d1 = this.FV / yt, d2 = (1 << this.F1) / yt, e = 1 << this.F2;\n var i = r.t, j = i - ys, t = q == null ? nbi() : q;\n y.dlShiftTo(j, t);\n if (r.compareTo(t) >= 0) {\n r[r.t++] = 1;\n r.subTo(t, r);\n }\n BigInteger.ONE.dlShiftTo(ys, t);\n t.subTo(y, y);\n // \"negative\" y so we can replace sub with am later\n while (y.t < ys)\n y[y.t++] = 0;\n while (--j >= 0) {\n // Estimate quotient digit\n var qd = r[--i] == y0\n ? this.DM\n : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);\n if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) {\n // Try it out\n y.dlShiftTo(j, t);\n r.subTo(t, r);\n while (r[i] < --qd) r.subTo(t, r);\n }\n }\n if (q != null) {\n r.drShiftTo(ys, q);\n if (ts != ms) BigInteger.ZERO.subTo(q, q);\n }\n r.t = ys;\n r.clamp();\n if (nsh > 0) r.rShiftTo(nsh, r);\n // Denormalize remainder\n if (ts < 0) BigInteger.ZERO.subTo(r, r);\n}\n\n// (public) this mod a\nfunction bnMod(a) {\n var r = nbi();\n this.abs().divRemTo(a, null, r);\n if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);\n return r;\n}\n\n// (protected) return \"-1/this % 2^DB\"; useful for Mont. reduction\n// justification:\n// xy == 1 (mod m)\n// xy = 1+km\n// xy(2-xy) = (1+km)(1-km)\n// x[y(2-xy)] = 1-k^2m^2\n// x[y(2-xy)] == 1 (mod m^2)\n// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2\n// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.\n// JS multiply \"overflows\" differently from C/C++, so care is needed here.\nfunction bnpInvDigit() {\n if (this.t < 1) return 0;\n var x = this[0];\n if ((x & 1) == 0) return 0;\n var y = x & 3;\n // y == 1/x mod 2^2\n y = y * (2 - (x & 0xf) * y) & 0xf;\n // y == 1/x mod 2^4\n y = y * (2 - (x & 0xff) * y) & 0xff;\n // y == 1/x mod 2^8\n y = y * (2 - ((x & 0xffff) * y & 0xffff)) & 0xffff;\n // y == 1/x mod 2^16\n // last step - calculate inverse mod DV directly;\n // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints\n y = y * (2 - x * y % this.DV) % this.DV;\n // y == 1/x mod 2^dbits\n // we really want the negative inverse, and -DV < y < DV\n return y > 0 ? this.DV - y : -y;\n}\n\nfunction bnEquals(a) {\n return this.compareTo(a) == 0;\n}\n\n// (protected) r = this + a\nfunction bnpAddTo(a, r) {\n var i = 0, c = 0, m = Math.min(a.t, this.t);\n while (i < m) {\n c += this[i] + a[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n if (a.t < this.t) {\n c += a.s;\n while (i < this.t) {\n c += this[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n c += this.s;\n } else {\n c += this.s;\n while (i < a.t) {\n c += a[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n c += a.s;\n }\n r.s = c < 0 ? -1 : 0;\n if (c > 0) r[i++] = c;\n else if (c < -1) r[i++] = this.DV + c;\n r.t = i;\n r.clamp();\n}\n\n// (public) this + a\nfunction bnAdd(a) {\n var r = nbi();\n\n this.addTo(a, r);\n\n return r;\n}\n\n// (public) this - a\nfunction bnSubtract(a) {\n var r = nbi();\n\n this.subTo(a, r);\n\n return r;\n}\n\n// (public) this * a\nfunction bnMultiply(a) {\n var r = nbi();\n\n this.multiplyTo(a, r);\n\n return r;\n}\n\n// (public) this / a\nfunction bnDivide(a) {\n var r = nbi();\n\n this.divRemTo(a, r, null);\n\n return r;\n}\n\n// Montgomery reduction\nfunction Montgomery(m) {\n this.m = m;\n this.mp = m.invDigit();\n this.mpl = this.mp & 0x7fff;\n this.mph = this.mp >> 15;\n this.um = (1 << m.DB - 15) - 1;\n this.mt2 = 2 * m.t;\n}\n\n// xR mod m\nfunction montConvert(x) {\n var r = nbi();\n x.abs().dlShiftTo(this.m.t, r);\n r.divRemTo(this.m, null, r);\n if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);\n return r;\n}\n\n// x/R mod m\nfunction montRevert(x) {\n var r = nbi();\n x.copyTo(r);\n this.reduce(r);\n return r;\n}\n\n// x = x/R mod m (HAC 14.32)\nfunction montReduce(x) {\n while (x.t <= this.mt2)\n // pad x so am has enough room later\n x[x.t++] = 0;\n for (var i = 0; i < this.m.t; ++i) {\n // faster way of calculating u0 = x[i]*mp mod DV\n var j = x[i] & 0x7fff;\n var u0 = j * this.mpl +\n ((j * this.mph + (x[i] >> 15) * this.mpl & this.um) << 15) &\n x.DM;\n // use am to combine the multiply-shift-add into one call\n j = i + this.m.t;\n x[j] += this.m.am(0, u0, x, i, 0, this.m.t);\n // propagate carry\n while (x[j] >= x.DV) {\n x[j] -= x.DV;\n x[++j]++;\n }\n }\n x.clamp();\n x.drShiftTo(this.m.t, x);\n if (x.compareTo(this.m) >= 0) x.subTo(this.m, x);\n}\n\n// r = \"x^2/R mod m\"; x != r\nfunction montSqrTo(x, r) {\n x.squareTo(r);\n\n this.reduce(r);\n}\n\n// r = \"xy/R mod m\"; x,y != r\nfunction montMulTo(x, y, r) {\n x.multiplyTo(y, r);\n\n this.reduce(r);\n}\n\nMontgomery.prototype.convert = montConvert;\nMontgomery.prototype.revert = montRevert;\nMontgomery.prototype.reduce = montReduce;\nMontgomery.prototype.mulTo = montMulTo;\nMontgomery.prototype.sqrTo = montSqrTo;\n\n// (public) this^e % m (HAC 14.85)\nfunction bnModPow(e, m) {\n var i = e.bitLength(), k, r = nbv(1), z = new Montgomery(m);\n if (i <= 0) return r;\n else if (i < 18) k = 1;\n else if (i < 48) k = 3;\n else if (i < 144) k = 4;\n else if (i < 768) k = 5;\n else k = 6;\n\n // precomputation\n var g = new Array(), n = 3, k1 = k - 1, km = (1 << k) - 1;\n g[1] = z.convert(this);\n if (k > 1) {\n var g2 = nbi();\n z.sqrTo(g[1], g2);\n while (n <= km) {\n g[n] = nbi();\n z.mulTo(g2, g[n - 2], g[n]);\n n += 2;\n }\n }\n\n var j = e.t - 1, w, is1 = true, r2 = nbi(), t;\n i = nbits(e[j]) - 1;\n while (j >= 0) {\n if (i >= k1) w = e[j] >> i - k1 & km;\n else {\n w = (e[j] & (1 << i + 1) - 1) << k1 - i;\n if (j > 0) w |= e[j - 1] >> this.DB + i - k1;\n }\n\n n = k;\n while ((w & 1) == 0) {\n w >>= 1;\n --n;\n }\n if ((i -= n) < 0) {\n i += this.DB;\n --j;\n }\n if (is1) {\n // ret == 1, don't bother squaring or multiplying it\n g[w].copyTo(r);\n is1 = false;\n } else {\n while (n > 1) {\n z.sqrTo(r, r2);\n z.sqrTo(r2, r);\n n -= 2;\n }\n if (n > 0) z.sqrTo(r, r2);\n else {\n t = r;\n r = r2;\n r2 = t;\n }\n z.mulTo(r2, g[w], r);\n }\n\n while (j >= 0 && (e[j] & 1 << i) == 0) {\n z.sqrTo(r, r2);\n t = r;\n r = r2;\n r2 = t;\n if (--i < 0) {\n i = this.DB - 1;\n --j;\n }\n }\n }\n return z.revert(r);\n}\n\n// protected\nBigInteger.prototype.copyTo = bnpCopyTo;\nBigInteger.prototype.fromInt = bnpFromInt;\nBigInteger.prototype.fromString = bnpFromString;\nBigInteger.prototype.clamp = bnpClamp;\nBigInteger.prototype.dlShiftTo = bnpDLShiftTo;\nBigInteger.prototype.drShiftTo = bnpDRShiftTo;\nBigInteger.prototype.lShiftTo = bnpLShiftTo;\nBigInteger.prototype.rShiftTo = bnpRShiftTo;\nBigInteger.prototype.subTo = bnpSubTo;\nBigInteger.prototype.multiplyTo = bnpMultiplyTo;\nBigInteger.prototype.squareTo = bnpSquareTo;\nBigInteger.prototype.divRemTo = bnpDivRemTo;\nBigInteger.prototype.invDigit = bnpInvDigit;\nBigInteger.prototype.addTo = bnpAddTo;\n\n// public\nBigInteger.prototype.toString = bnToString;\nBigInteger.prototype.negate = bnNegate;\nBigInteger.prototype.abs = bnAbs;\nBigInteger.prototype.compareTo = bnCompareTo;\nBigInteger.prototype.bitLength = bnBitLength;\nBigInteger.prototype.mod = bnMod;\nBigInteger.prototype.equals = bnEquals;\nBigInteger.prototype.add = bnAdd;\nBigInteger.prototype.subtract = bnSubtract;\nBigInteger.prototype.multiply = bnMultiply;\nBigInteger.prototype.divide = bnDivide;\nBigInteger.prototype.modPow = bnModPow;\n\n// \"constants\"\nBigInteger.ZERO = nbv(0);\nBigInteger.ONE = nbv(1);\n\n\n\n\n// WEBPACK FOOTER //\n// ./src/BigInteger.js","/*\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { util } from 'aws-sdk/global';\n\n/** @class */\nexport default class CognitoAccessToken {\n /**\n * Constructs a new CognitoAccessToken object\n * @param {string=} AccessToken The JWT access token.\n */\n constructor({ AccessToken } = {}) {\n // Assign object\n this.jwtToken = AccessToken || '';\n }\n\n /**\n * @returns {string} the record's token.\n */\n getJwtToken() {\n return this.jwtToken;\n }\n\n /**\n * @returns {int} the token's expiration (exp member).\n */\n getExpiration() {\n const payload = this.jwtToken.split('.')[1];\n const expiration = JSON.parse(util.base64.decode(payload).toString('utf8'));\n return expiration.exp;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoAccessToken.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { util } from 'aws-sdk/global';\n\n/** @class */\nexport default class CognitoIdToken {\n /**\n * Constructs a new CognitoIdToken object\n * @param {string=} IdToken The JWT Id token\n */\n constructor({ IdToken } = {}) {\n // Assign object\n this.jwtToken = IdToken || '';\n }\n\n /**\n * @returns {string} the record's token.\n */\n getJwtToken() {\n return this.jwtToken;\n }\n\n /**\n * @returns {int} the token's expiration (exp member).\n */\n getExpiration() {\n const payload = this.jwtToken.split('.')[1];\n const expiration = JSON.parse(util.base64.decode(payload).toString('utf8'));\n return expiration.exp;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoIdToken.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @class */\nexport default class CognitoRefreshToken {\n /**\n * Constructs a new CognitoRefreshToken object\n * @param {string=} RefreshToken The JWT refresh token.\n */\n constructor({ RefreshToken } = {}) {\n // Assign object\n this.token = RefreshToken || '';\n }\n\n /**\n * @returns {string} the record's token.\n */\n getToken() {\n return this.token;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoRefreshToken.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { util } from 'aws-sdk/global';\n\nimport BigInteger from './BigInteger';\nimport AuthenticationHelper from './AuthenticationHelper';\nimport CognitoAccessToken from './CognitoAccessToken';\nimport CognitoIdToken from './CognitoIdToken';\nimport CognitoRefreshToken from './CognitoRefreshToken';\nimport CognitoUserSession from './CognitoUserSession';\nimport DateHelper from './DateHelper';\nimport CognitoUserAttribute from './CognitoUserAttribute';\nimport StorageHelper from './StorageHelper';\n\n/**\n * @callback nodeCallback\n * @template T result\n * @param {*} err The operation failure reason, or null.\n * @param {T} result The operation result.\n */\n\n/**\n * @callback onFailure\n * @param {*} err Failure reason.\n */\n\n/**\n * @callback onSuccess\n * @template T result\n * @param {T} result The operation result.\n */\n\n/**\n * @callback mfaRequired\n * @param {*} details MFA challenge details.\n */\n\n/**\n * @callback customChallenge\n * @param {*} details Custom challenge details.\n */\n\n/**\n * @callback inputVerificationCode\n * @param {*} data Server response.\n */\n\n/**\n * @callback authSuccess\n * @param {CognitoUserSession} session The new session.\n * @param {bool=} userConfirmationNecessary User must be confirmed.\n */\n\n\n/** @class */\nexport default class CognitoUser {\n /**\n * Constructs a new CognitoUser object\n * @param {object} data Creation options\n * @param {string} data.Username The user's username.\n * @param {CognitoUserPool} data.Pool Pool containing the user.\n * @param {object} data.Storage Optional storage object.\n */\n constructor(data) {\n if (data == null || data.Username == null || data.Pool == null) {\n throw new Error('Username and pool information are required.');\n }\n\n this.username = data.Username || '';\n this.pool = data.Pool;\n this.Session = null;\n\n this.client = data.Pool.client;\n\n this.signInUserSession = null;\n this.authenticationFlowType = 'USER_SRP_AUTH';\n\n this.storage = this.pool.getStorage();\n }\n\n /**\n * @returns {CognitoUserSession} the current session for this user\n */\n getSignInUserSession() {\n return this.signInUserSession;\n }\n\n /**\n * @returns {string} the user's username\n */\n getUsername() {\n return this.username;\n }\n\n /**\n * @returns {String} the authentication flow type\n */\n getAuthenticationFlowType() {\n return this.authenticationFlowType;\n }\n\n /**\n * sets authentication flow type\n * @param {string} authenticationFlowType New value.\n * @returns {void}\n */\n setAuthenticationFlowType(authenticationFlowType) {\n this.authenticationFlowType = authenticationFlowType;\n }\n\n /**\n * This is used for authenticating the user. it calls the AuthenticationHelper for SRP related\n * stuff\n * @param {AuthenticationDetails} authDetails Contains the authentication data\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {newPasswordRequired} callback.newPasswordRequired new\n * password and any required attributes are required to continue\n * @param {mfaRequired} callback.mfaRequired MFA code\n * required to continue.\n * @param {customChallenge} callback.customChallenge Custom challenge\n * response required to continue.\n * @param {authSuccess} callback.onSuccess Called on success with the new session.\n * @returns {void}\n */\n authenticateUser(authDetails, callback) {\n const authenticationHelper = new AuthenticationHelper(\n this.pool.getUserPoolId().split('_')[1]);\n const dateHelper = new DateHelper();\n\n let serverBValue;\n let salt;\n const authParameters = {};\n\n if (this.deviceKey != null) {\n authParameters.DEVICE_KEY = this.deviceKey;\n }\n\n authParameters.USERNAME = this.username;\n authParameters.SRP_A = authenticationHelper.getLargeAValue().toString(16);\n\n if (this.authenticationFlowType === 'CUSTOM_AUTH') {\n authParameters.CHALLENGE_NAME = 'SRP_A';\n }\n\n this.client.makeUnauthenticatedRequest('initiateAuth', {\n AuthFlow: this.authenticationFlowType,\n ClientId: this.pool.getClientId(),\n AuthParameters: authParameters,\n ClientMetadata: authDetails.getValidationData(),\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n\n const challengeParameters = data.ChallengeParameters;\n\n this.username = challengeParameters.USER_ID_FOR_SRP;\n serverBValue = new BigInteger(challengeParameters.SRP_B, 16);\n salt = new BigInteger(challengeParameters.SALT, 16);\n this.getCachedDeviceKeyAndPassword();\n\n const hkdf = authenticationHelper.getPasswordAuthenticationKey(\n this.username,\n authDetails.getPassword(),\n serverBValue,\n salt);\n\n const dateNow = dateHelper.getNowString();\n\n const signatureString = util.crypto.hmac(hkdf, util.buffer.concat([\n new util.Buffer(this.pool.getUserPoolId().split('_')[1], 'utf8'),\n new util.Buffer(this.username, 'utf8'),\n new util.Buffer(challengeParameters.SECRET_BLOCK, 'base64'),\n new util.Buffer(dateNow, 'utf8'),\n ]), 'base64', 'sha256');\n\n const challengeResponses = {};\n\n challengeResponses.USERNAME = this.username;\n challengeResponses.PASSWORD_CLAIM_SECRET_BLOCK = challengeParameters.SECRET_BLOCK;\n challengeResponses.TIMESTAMP = dateNow;\n challengeResponses.PASSWORD_CLAIM_SIGNATURE = signatureString;\n\n if (this.deviceKey != null) {\n challengeResponses.DEVICE_KEY = this.deviceKey;\n }\n\n const respondToAuthChallenge = (challenge, challengeCallback) =>\n this.client.makeUnauthenticatedRequest('respondToAuthChallenge', challenge,\n (errChallenge, dataChallenge) => {\n if (errChallenge && errChallenge.code === 'ResourceNotFoundException' &&\n errChallenge.message.toLowerCase().indexOf('device') !== -1) {\n challengeResponses.DEVICE_KEY = null;\n this.deviceKey = null;\n this.randomPassword = null;\n this.deviceGroupKey = null;\n this.clearCachedDeviceKeyAndPassword();\n return respondToAuthChallenge(challenge, challengeCallback);\n }\n return challengeCallback(errChallenge, dataChallenge);\n });\n\n respondToAuthChallenge({\n ChallengeName: 'PASSWORD_VERIFIER',\n ClientId: this.pool.getClientId(),\n ChallengeResponses: challengeResponses,\n Session: data.Session,\n }, (errAuthenticate, dataAuthenticate) => {\n if (errAuthenticate) {\n return callback.onFailure(errAuthenticate);\n }\n\n const challengeName = dataAuthenticate.ChallengeName;\n if (challengeName === 'NEW_PASSWORD_REQUIRED') {\n this.Session = dataAuthenticate.Session;\n let userAttributes = null;\n let rawRequiredAttributes = null;\n const requiredAttributes = [];\n const userAttributesPrefix = authenticationHelper\n .getNewPasswordRequiredChallengeUserAttributePrefix();\n\n if (dataAuthenticate.ChallengeParameters) {\n userAttributes = JSON.parse(\n dataAuthenticate.ChallengeParameters.userAttributes);\n rawRequiredAttributes = JSON.parse(\n dataAuthenticate.ChallengeParameters.requiredAttributes);\n }\n\n if (rawRequiredAttributes) {\n for (let i = 0; i < rawRequiredAttributes.length; i++) {\n requiredAttributes[i] = rawRequiredAttributes[i].substr(userAttributesPrefix.length);\n }\n }\n return callback.newPasswordRequired(userAttributes, requiredAttributes);\n }\n return this.authenticateUserInternal(dataAuthenticate, authenticationHelper, callback);\n });\n return undefined;\n });\n }\n\n /**\n * PRIVATE ONLY: This is an internal only method and should not\n * be directly called by the consumers.\n * @param {object} dataAuthenticate authentication data\n * @param {object} authenticationHelper helper created\n * @param {callback} callback passed on from caller\n * @returns {void}\n */\n authenticateUserInternal(dataAuthenticate, authenticationHelper, callback) {\n const challengeName = dataAuthenticate.ChallengeName;\n const challengeParameters = dataAuthenticate.ChallengeParameters;\n\n if (challengeName === 'SMS_MFA') {\n this.Session = dataAuthenticate.Session;\n return callback.mfaRequired(challengeName, challengeParameters);\n }\n\n if (challengeName === 'CUSTOM_CHALLENGE') {\n this.Session = dataAuthenticate.Session;\n return callback.customChallenge(challengeParameters);\n }\n\n if (challengeName === 'DEVICE_SRP_AUTH') {\n this.getDeviceResponse(callback);\n return undefined;\n }\n\n this.signInUserSession = this.getCognitoUserSession(dataAuthenticate.AuthenticationResult);\n this.cacheTokens();\n\n const newDeviceMetadata = dataAuthenticate.AuthenticationResult.NewDeviceMetadata;\n if (newDeviceMetadata == null) {\n return callback.onSuccess(this.signInUserSession);\n }\n\n authenticationHelper.generateHashDevice(\n dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,\n dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey);\n\n const deviceSecretVerifierConfig = {\n Salt: new util.Buffer(\n authenticationHelper.getSaltDevices(), 'hex'\n ).toString('base64'),\n PasswordVerifier: new util.Buffer(\n authenticationHelper.getVerifierDevices(), 'hex'\n ).toString('base64'),\n };\n\n this.verifierDevices = deviceSecretVerifierConfig.PasswordVerifier;\n this.deviceGroupKey = newDeviceMetadata.DeviceGroupKey;\n this.randomPassword = authenticationHelper.getRandomPassword();\n\n this.client.makeUnauthenticatedRequest('confirmDevice', {\n DeviceKey: newDeviceMetadata.DeviceKey,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n DeviceSecretVerifierConfig: deviceSecretVerifierConfig,\n DeviceName: navigator.userAgent,\n }, (errConfirm, dataConfirm) => {\n if (errConfirm) {\n return callback.onFailure(errConfirm);\n }\n\n this.deviceKey = dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey;\n this.cacheDeviceKeyAndPassword();\n if (dataConfirm.UserConfirmationNecessary === true) {\n return callback.onSuccess(\n this.signInUserSession, dataConfirm.UserConfirmationNecessary);\n }\n return callback.onSuccess(this.signInUserSession);\n });\n return undefined;\n }\n\n /**\n * This method is user to complete the NEW_PASSWORD_REQUIRED challenge.\n * Pass the new password with any new user attributes to be updated.\n * User attribute keys must be of format userAttributes..\n * @param {string} newPassword new password for this user\n * @param {object} requiredAttributeData map with values for all required attributes\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {mfaRequired} callback.mfaRequired MFA code required to continue.\n * @param {customChallenge} callback.customChallenge Custom challenge\n * response required to continue.\n * @param {authSuccess} callback.onSuccess Called on success with the new session.\n * @returns {void}\n */\n completeNewPasswordChallenge(newPassword, requiredAttributeData, callback) {\n if (!newPassword) {\n return callback.onFailure(new Error('New password is required.'));\n }\n const authenticationHelper = new AuthenticationHelper(\n this.pool.getUserPoolId().split('_')[1]);\n const userAttributesPrefix = authenticationHelper\n .getNewPasswordRequiredChallengeUserAttributePrefix();\n\n const finalUserAttributes = {};\n if (requiredAttributeData) {\n Object.keys(requiredAttributeData).forEach((key) => {\n finalUserAttributes[userAttributesPrefix + key] = requiredAttributeData[key];\n });\n }\n\n finalUserAttributes.NEW_PASSWORD = newPassword;\n finalUserAttributes.USERNAME = this.username;\n this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n ChallengeName: 'NEW_PASSWORD_REQUIRED',\n ClientId: this.pool.getClientId(),\n ChallengeResponses: finalUserAttributes,\n Session: this.Session,\n }, (errAuthenticate, dataAuthenticate) => {\n if (errAuthenticate) {\n return callback.onFailure(errAuthenticate);\n }\n return this.authenticateUserInternal(dataAuthenticate, authenticationHelper, callback);\n });\n return undefined;\n }\n\n /**\n * This is used to get a session using device authentication. It is called at the end of user\n * authentication\n *\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {authSuccess} callback.onSuccess Called on success with the new session.\n * @returns {void}\n * @private\n */\n getDeviceResponse(callback) {\n const authenticationHelper = new AuthenticationHelper(\n this.deviceGroupKey);\n const dateHelper = new DateHelper();\n\n const authParameters = {};\n\n authParameters.USERNAME = this.username;\n authParameters.DEVICE_KEY = this.deviceKey;\n authParameters.SRP_A = authenticationHelper.getLargeAValue().toString(16);\n\n this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n ChallengeName: 'DEVICE_SRP_AUTH',\n ClientId: this.pool.getClientId(),\n ChallengeResponses: authParameters,\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n\n const challengeParameters = data.ChallengeParameters;\n\n const serverBValue = new BigInteger(challengeParameters.SRP_B, 16);\n const salt = new BigInteger(challengeParameters.SALT, 16);\n\n const hkdf = authenticationHelper.getPasswordAuthenticationKey(\n this.deviceKey,\n this.randomPassword,\n serverBValue,\n salt);\n\n const dateNow = dateHelper.getNowString();\n\n const signatureString = util.crypto.hmac(hkdf, util.buffer.concat([\n new util.Buffer(this.deviceGroupKey, 'utf8'),\n new util.Buffer(this.deviceKey, 'utf8'),\n new util.Buffer(challengeParameters.SECRET_BLOCK, 'base64'),\n new util.Buffer(dateNow, 'utf8'),\n ]), 'base64', 'sha256');\n\n const challengeResponses = {};\n\n challengeResponses.USERNAME = this.username;\n challengeResponses.PASSWORD_CLAIM_SECRET_BLOCK = challengeParameters.SECRET_BLOCK;\n challengeResponses.TIMESTAMP = dateNow;\n challengeResponses.PASSWORD_CLAIM_SIGNATURE = signatureString;\n challengeResponses.DEVICE_KEY = this.deviceKey;\n\n this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n ChallengeName: 'DEVICE_PASSWORD_VERIFIER',\n ClientId: this.pool.getClientId(),\n ChallengeResponses: challengeResponses,\n Session: data.Session,\n }, (errAuthenticate, dataAuthenticate) => {\n if (errAuthenticate) {\n return callback.onFailure(errAuthenticate);\n }\n\n this.signInUserSession = this.getCognitoUserSession(dataAuthenticate.AuthenticationResult);\n this.cacheTokens();\n\n return callback.onSuccess(this.signInUserSession);\n });\n return undefined;\n });\n }\n\n /**\n * This is used for a certain user to confirm the registration by using a confirmation code\n * @param {string} confirmationCode Code entered by user.\n * @param {bool} forceAliasCreation Allow migrating from an existing email / phone number.\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n confirmRegistration(confirmationCode, forceAliasCreation, callback) {\n this.client.makeUnauthenticatedRequest('confirmSignUp', {\n ClientId: this.pool.getClientId(),\n ConfirmationCode: confirmationCode,\n Username: this.username,\n ForceAliasCreation: forceAliasCreation,\n }, err => {\n if (err) {\n return callback(err, null);\n }\n return callback(null, 'SUCCESS');\n });\n }\n\n /**\n * This is used by the user once he has the responses to a custom challenge\n * @param {string} answerChallenge The custom challange answer.\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {customChallenge} callback.customChallenge\n * Custom challenge response required to continue.\n * @param {authSuccess} callback.onSuccess Called on success with the new session.\n * @returns {void}\n */\n sendCustomChallengeAnswer(answerChallenge, callback) {\n const challengeResponses = {};\n challengeResponses.USERNAME = this.username;\n challengeResponses.ANSWER = answerChallenge;\n\n this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n ChallengeName: 'CUSTOM_CHALLENGE',\n ChallengeResponses: challengeResponses,\n ClientId: this.pool.getClientId(),\n Session: this.Session,\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n\n const challengeName = data.ChallengeName;\n\n if (challengeName === 'CUSTOM_CHALLENGE') {\n this.Session = data.Session;\n return callback.customChallenge(data.ChallengeParameters);\n }\n\n this.signInUserSession = this.getCognitoUserSession(data.AuthenticationResult);\n this.cacheTokens();\n return callback.onSuccess(this.signInUserSession);\n });\n }\n\n /**\n * This is used by the user once he has an MFA code\n * @param {string} confirmationCode The MFA code entered by the user.\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {authSuccess} callback.onSuccess Called on success with the new session.\n * @returns {void}\n */\n sendMFACode(confirmationCode, callback) {\n const challengeResponses = {};\n challengeResponses.USERNAME = this.username;\n challengeResponses.SMS_MFA_CODE = confirmationCode;\n\n if (this.deviceKey != null) {\n challengeResponses.DEVICE_KEY = this.deviceKey;\n }\n\n this.client.makeUnauthenticatedRequest('respondToAuthChallenge', {\n ChallengeName: 'SMS_MFA',\n ChallengeResponses: challengeResponses,\n ClientId: this.pool.getClientId(),\n Session: this.Session,\n }, (err, dataAuthenticate) => {\n if (err) {\n return callback.onFailure(err);\n }\n\n const challengeName = dataAuthenticate.ChallengeName;\n\n if (challengeName === 'DEVICE_SRP_AUTH') {\n this.getDeviceResponse(callback);\n return undefined;\n }\n\n this.signInUserSession = this.getCognitoUserSession(dataAuthenticate.AuthenticationResult);\n this.cacheTokens();\n\n if (dataAuthenticate.AuthenticationResult.NewDeviceMetadata == null) {\n return callback.onSuccess(this.signInUserSession);\n }\n\n const authenticationHelper = new AuthenticationHelper(\n this.pool.getUserPoolId().split('_')[1]);\n authenticationHelper.generateHashDevice(\n dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,\n dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey);\n\n const deviceSecretVerifierConfig = {\n Salt: new util.Buffer(\n authenticationHelper.getSaltDevices(), 'hex'\n ).toString('base64'),\n PasswordVerifier: new util.Buffer(\n authenticationHelper.getVerifierDevices(), 'hex'\n ).toString('base64'),\n };\n\n this.verifierDevices = deviceSecretVerifierConfig.PasswordVerifier;\n this.deviceGroupKey = dataAuthenticate.AuthenticationResult\n .NewDeviceMetadata.DeviceGroupKey;\n this.randomPassword = authenticationHelper.getRandomPassword();\n\n this.client.makeUnauthenticatedRequest('confirmDevice', {\n DeviceKey: dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n DeviceSecretVerifierConfig: deviceSecretVerifierConfig,\n DeviceName: navigator.userAgent,\n }, (errConfirm, dataConfirm) => {\n if (errConfirm) {\n return callback.onFailure(errConfirm);\n }\n\n this.deviceKey = dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey;\n this.cacheDeviceKeyAndPassword();\n if (dataConfirm.UserConfirmationNecessary === true) {\n return callback.onSuccess(\n this.signInUserSession,\n dataConfirm.UserConfirmationNecessary);\n }\n return callback.onSuccess(this.signInUserSession);\n });\n return undefined;\n });\n }\n\n /**\n * This is used by an authenticated user to change the current password\n * @param {string} oldUserPassword The current password.\n * @param {string} newUserPassword The requested new password.\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n changePassword(oldUserPassword, newUserPassword, callback) {\n if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n this.client.makeUnauthenticatedRequest('changePassword', {\n PreviousPassword: oldUserPassword,\n ProposedPassword: newUserPassword,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback(err, null);\n }\n return callback(null, 'SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used by an authenticated user to enable MFA for himself\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n enableMFA(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n const mfaOptions = [];\n const mfaEnabled = {\n DeliveryMedium: 'SMS',\n AttributeName: 'phone_number',\n };\n mfaOptions.push(mfaEnabled);\n\n this.client.makeUnauthenticatedRequest('setUserSettings', {\n MFAOptions: mfaOptions,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback(err, null);\n }\n return callback(null, 'SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used by an authenticated user to disable MFA for himself\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n disableMFA(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n const mfaOptions = [];\n\n this.client.makeUnauthenticatedRequest('setUserSettings', {\n MFAOptions: mfaOptions,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback(err, null);\n }\n return callback(null, 'SUCCESS');\n });\n return undefined;\n }\n\n\n /**\n * This is used by an authenticated user to delete himself\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n deleteUser(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n this.client.makeUnauthenticatedRequest('deleteUser', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback(err, null);\n }\n this.clearCachedTokens();\n return callback(null, 'SUCCESS');\n });\n return undefined;\n }\n\n /**\n * @typedef {CognitoUserAttribute | { Name:string, Value:string }} AttributeArg\n */\n /**\n * This is used by an authenticated user to change a list of attributes\n * @param {AttributeArg[]} attributes A list of the new user attributes.\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n updateAttributes(attributes, callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n this.client.makeUnauthenticatedRequest('updateUserAttributes', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n UserAttributes: attributes,\n }, err => {\n if (err) {\n return callback(err, null);\n }\n return callback(null, 'SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used by an authenticated user to get a list of attributes\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n getUserAttributes(callback) {\n if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n this.client.makeUnauthenticatedRequest('getUser', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, (err, userData) => {\n if (err) {\n return callback(err, null);\n }\n\n const attributeList = [];\n\n for (let i = 0; i < userData.UserAttributes.length; i++) {\n const attribute = {\n Name: userData.UserAttributes[i].Name,\n Value: userData.UserAttributes[i].Value,\n };\n const userAttribute = new CognitoUserAttribute(attribute);\n attributeList.push(userAttribute);\n }\n\n return callback(null, attributeList);\n });\n return undefined;\n }\n\n /**\n * This is used by an authenticated user to get the MFAOptions\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n getMFAOptions(callback) {\n if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n this.client.makeUnauthenticatedRequest('getUser', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, (err, userData) => {\n if (err) {\n return callback(err, null);\n }\n\n return callback(null, userData.MFAOptions);\n });\n return undefined;\n }\n\n /**\n * This is used by an authenticated user to delete a list of attributes\n * @param {string[]} attributeList Names of the attributes to delete.\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n deleteAttributes(attributeList, callback) {\n if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {\n return callback(new Error('User is not authenticated'), null);\n }\n\n this.client.makeUnauthenticatedRequest('deleteUserAttributes', {\n UserAttributeNames: attributeList,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback(err, null);\n }\n return callback(null, 'SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used by a user to resend a confirmation code\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n resendConfirmationCode(callback) {\n this.client.makeUnauthenticatedRequest('resendConfirmationCode', {\n ClientId: this.pool.getClientId(),\n Username: this.username,\n }, err => {\n if (err, result) {\n return callback(err, null);\n }\n return callback(null, result);\n });\n }\n\n /**\n * This is used to get a session, either from the session object\n * or from the local storage, or by using a refresh token\n *\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n getSession(callback) {\n if (this.username == null) {\n return callback(new Error('Username is null. Cannot retrieve a new session'), null);\n }\n\n if (this.signInUserSession != null && this.signInUserSession.isValid()) {\n return callback(null, this.signInUserSession);\n }\n\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${this.username}`;\n const idTokenKey = `${keyPrefix}.idToken`;\n const accessTokenKey = `${keyPrefix}.accessToken`;\n const refreshTokenKey = `${keyPrefix}.refreshToken`;\n\n if (this.storage.getItem(idTokenKey)) {\n const idToken = new CognitoIdToken({\n IdToken: this.storage.getItem(idTokenKey),\n });\n const accessToken = new CognitoAccessToken({\n AccessToken: this.storage.getItem(accessTokenKey),\n });\n const refreshToken = new CognitoRefreshToken({\n RefreshToken: this.storage.getItem(refreshTokenKey),\n });\n\n const sessionData = {\n IdToken: idToken,\n AccessToken: accessToken,\n RefreshToken: refreshToken,\n };\n const cachedSession = new CognitoUserSession(sessionData);\n if (cachedSession.isValid()) {\n this.signInUserSession = cachedSession;\n return callback(null, this.signInUserSession);\n }\n\n if (refreshToken.getToken() == null) {\n return callback(new Error('Cannot retrieve a new session. Please authenticate.'), null);\n }\n\n this.refreshSession(refreshToken, callback);\n } else {\n callback(new Error('Local storage is missing an ID Token, Please authenticate'), null);\n }\n\n return undefined;\n }\n\n\n /**\n * This uses the refreshToken to retrieve a new session\n * @param {CognitoRefreshToken} refreshToken A previous session's refresh token.\n * @param {nodeCallback} callback Called on success or error.\n * @returns {void}\n */\n refreshSession(refreshToken, callback) {\n const authParameters = {};\n authParameters.REFRESH_TOKEN = refreshToken.getToken();\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}`;\n const lastUserKey = `${keyPrefix}.LastAuthUser`;\n\n if (this.storage.getItem(lastUserKey)) {\n this.username = this.storage.getItem(lastUserKey);\n const deviceKeyKey = `${keyPrefix}.${this.username}.deviceKey`;\n this.deviceKey = this.storage.getItem(deviceKeyKey);\n authParameters.DEVICE_KEY = this.deviceKey;\n }\n\n this.client.makeUnauthenticatedRequest('initiateAuth', {\n ClientId: this.pool.getClientId(),\n AuthFlow: 'REFRESH_TOKEN_AUTH',\n AuthParameters: authParameters,\n }, (err, authResult) => {\n if (err) {\n if (err.code === 'NotAuthorizedException') {\n this.clearCachedTokens();\n }\n return callback(err, null);\n }\n if (authResult) {\n const authenticationResult = authResult.AuthenticationResult;\n if (!Object.prototype.hasOwnProperty.call(authenticationResult, 'RefreshToken')) {\n authenticationResult.RefreshToken = refreshToken.getToken();\n }\n this.signInUserSession = this.getCognitoUserSession(authenticationResult);\n this.cacheTokens();\n return callback(null, this.signInUserSession);\n }\n return undefined;\n });\n }\n\n /**\n * This is used to save the session tokens to local storage\n * @returns {void}\n */\n cacheTokens() {\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}`;\n const idTokenKey = `${keyPrefix}.${this.username}.idToken`;\n const accessTokenKey = `${keyPrefix}.${this.username}.accessToken`;\n const refreshTokenKey = `${keyPrefix}.${this.username}.refreshToken`;\n const lastUserKey = `${keyPrefix}.LastAuthUser`;\n\n this.storage.setItem(idTokenKey, this.signInUserSession.getIdToken().getJwtToken());\n this.storage.setItem(accessTokenKey, this.signInUserSession.getAccessToken().getJwtToken());\n this.storage.setItem(refreshTokenKey, this.signInUserSession.getRefreshToken().getToken());\n this.storage.setItem(lastUserKey, this.username);\n }\n\n /**\n * This is used to cache the device key and device group and device password\n * @returns {void}\n */\n cacheDeviceKeyAndPassword() {\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${this.username}`;\n const deviceKeyKey = `${keyPrefix}.deviceKey`;\n const randomPasswordKey = `${keyPrefix}.randomPasswordKey`;\n const deviceGroupKeyKey = `${keyPrefix}.deviceGroupKey`;\n\n this.storage.setItem(deviceKeyKey, this.deviceKey);\n this.storage.setItem(randomPasswordKey, this.randomPassword);\n this.storage.setItem(deviceGroupKeyKey, this.deviceGroupKey);\n }\n\n /**\n * This is used to get current device key and device group and device password\n * @returns {void}\n */\n getCachedDeviceKeyAndPassword() {\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${this.username}`;\n const deviceKeyKey = `${keyPrefix}.deviceKey`;\n const randomPasswordKey = `${keyPrefix}.randomPasswordKey`;\n const deviceGroupKeyKey = `${keyPrefix}.deviceGroupKey`;\n\n if (this.storage.getItem(deviceKeyKey)) {\n this.deviceKey = this.storage.getItem(deviceKeyKey);\n this.randomPassword = this.storage.getItem(randomPasswordKey);\n this.deviceGroupKey = this.storage.getItem(deviceGroupKeyKey);\n }\n }\n\n /**\n * This is used to clear the device key info from local storage\n * @returns {void}\n */\n clearCachedDeviceKeyAndPassword() {\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${this.username}`;\n const deviceKeyKey = `${keyPrefix}.deviceKey`;\n const randomPasswordKey = `${keyPrefix}.randomPasswordKey`;\n const deviceGroupKeyKey = `${keyPrefix}.deviceGroupKey`;\n\n this.storage.removeItem(deviceKeyKey);\n this.storage.removeItem(randomPasswordKey);\n this.storage.removeItem(deviceGroupKeyKey);\n }\n\n /**\n * This is used to clear the session tokens from local storage\n * @returns {void}\n */\n clearCachedTokens() {\n const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}`;\n const idTokenKey = `${keyPrefix}.${this.username}.idToken`;\n const accessTokenKey = `${keyPrefix}.${this.username}.accessToken`;\n const refreshTokenKey = `${keyPrefix}.${this.username}.refreshToken`;\n const lastUserKey = `${keyPrefix}.LastAuthUser`;\n\n this.storage.removeItem(idTokenKey);\n this.storage.removeItem(accessTokenKey);\n this.storage.removeItem(refreshTokenKey);\n this.storage.removeItem(lastUserKey);\n }\n\n /**\n * This is used to build a user session from tokens retrieved in the authentication result\n * @param {object} authResult Successful auth response from server.\n * @returns {CognitoUserSession} The new user session.\n * @private\n */\n getCognitoUserSession(authResult) {\n const idToken = new CognitoIdToken(authResult);\n const accessToken = new CognitoAccessToken(authResult);\n const refreshToken = new CognitoRefreshToken(authResult);\n\n const sessionData = {\n IdToken: idToken,\n AccessToken: accessToken,\n RefreshToken: refreshToken,\n };\n\n return new CognitoUserSession(sessionData);\n }\n\n /**\n * This is used to initiate a forgot password request\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {inputVerificationCode?} callback.inputVerificationCode\n * Optional callback raised instead of onSuccess with response data.\n * @param {onSuccess?} callback.onSuccess Called on success.\n * @returns {void}\n */\n forgotPassword(callback) {\n this.client.makeUnauthenticatedRequest('forgotPassword', {\n ClientId: this.pool.getClientId(),\n Username: this.username,\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n if (typeof callback.inputVerificationCode === 'function') {\n return callback.inputVerificationCode(data);\n }\n return callback.onSuccess();\n });\n }\n\n /**\n * This is used to confirm a new password using a confirmationCode\n * @param {string} confirmationCode Code entered by user.\n * @param {string} newPassword Confirm new password.\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n confirmPassword(confirmationCode, newPassword, callback) {\n this.client.makeUnauthenticatedRequest('confirmForgotPassword', {\n ClientId: this.pool.getClientId(),\n Username: this.username,\n ConfirmationCode: confirmationCode,\n Password: newPassword,\n }, err => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess();\n });\n }\n\n /**\n * This is used to initiate an attribute confirmation request\n * @param {string} attributeName User attribute that needs confirmation.\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {inputVerificationCode} callback.inputVerificationCode Called on success.\n * @returns {void}\n */\n getAttributeVerificationCode(attributeName, callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('getUserAttributeVerificationCode', {\n AttributeName: attributeName,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n if (typeof callback.inputVerificationCode === 'function') {\n return callback.inputVerificationCode(data);\n }\n return callback.onSuccess();\n });\n return undefined;\n }\n\n /**\n * This is used to confirm an attribute using a confirmation code\n * @param {string} attributeName Attribute being confirmed.\n * @param {string} confirmationCode Code entered by user.\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n verifyAttribute(attributeName, confirmationCode, callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('verifyUserAttribute', {\n AttributeName: attributeName,\n Code: confirmationCode,\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess('SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used to get the device information using the current device key\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess<*>} callback.onSuccess Called on success with device data.\n * @returns {void}\n */\n getDevice(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('getDevice', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n DeviceKey: this.deviceKey,\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess(data);\n });\n return undefined;\n }\n\n /**\n * This is used to forget a specific device\n * @param {string} deviceKey Device key.\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n forgetSpecificDevice(deviceKey, callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('forgetDevice', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n DeviceKey: deviceKey,\n }, err => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess('SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used to forget the current device\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n forgetDevice(callback) {\n this.forgetSpecificDevice(this.deviceKey, {\n onFailure: callback.onFailure,\n onSuccess: result => {\n this.deviceKey = null;\n this.deviceGroupKey = null;\n this.randomPassword = null;\n this.clearCachedDeviceKeyAndPassword();\n return callback.onSuccess(result);\n },\n });\n }\n\n /**\n * This is used to set the device status as remembered\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n setDeviceStatusRemembered(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('updateDeviceStatus', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n DeviceKey: this.deviceKey,\n DeviceRememberedStatus: 'remembered',\n }, err => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess('SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used to set the device status as not remembered\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n setDeviceStatusNotRemembered(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('updateDeviceStatus', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n DeviceKey: this.deviceKey,\n DeviceRememberedStatus: 'not_remembered',\n }, err => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess('SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used to list all devices for a user\n *\n * @param {int} limit the number of devices returned in a call\n * @param {string} paginationToken the pagination token in case any was returned before\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess<*>} callback.onSuccess Called on success with device list.\n * @returns {void}\n */\n listDevices(limit, paginationToken, callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('listDevices', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n Limit: limit,\n PaginationToken: paginationToken,\n }, (err, data) => {\n if (err) {\n return callback.onFailure(err);\n }\n return callback.onSuccess(data);\n });\n return undefined;\n }\n\n /**\n * This is used to globally revoke all tokens issued to a user\n * @param {object} callback Result callback map.\n * @param {onFailure} callback.onFailure Called on any error.\n * @param {onSuccess} callback.onSuccess Called on success.\n * @returns {void}\n */\n globalSignOut(callback) {\n if (this.signInUserSession == null || !this.signInUserSession.isValid()) {\n return callback.onFailure(new Error('User is not authenticated'));\n }\n\n this.client.makeUnauthenticatedRequest('globalSignOut', {\n AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),\n }, err => {\n if (err) {\n return callback.onFailure(err);\n }\n this.clearCachedTokens();\n return callback.onSuccess('SUCCESS');\n });\n return undefined;\n }\n\n /**\n * This is used for the user to signOut of the application and clear the cached tokens.\n * @returns {void}\n */\n signOut() {\n this.signInUserSession = null;\n this.clearCachedTokens();\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoUser.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @class */\nexport default class CognitoUserAttribute {\n /**\n * Constructs a new CognitoUserAttribute object\n * @param {string=} Name The record's name\n * @param {string=} Value The record's value\n */\n constructor({ Name, Value } = {}) {\n this.Name = Name || '';\n this.Value = Value || '';\n }\n\n /**\n * @returns {string} the record's value.\n */\n getValue() {\n return this.Value;\n }\n\n /**\n * Sets the record's value.\n * @param {string} value The new value.\n * @returns {CognitoUserAttribute} The record for method chaining.\n */\n setValue(value) {\n this.Value = value;\n return this;\n }\n\n /**\n * @returns {string} the record's name.\n */\n getName() {\n return this.Name;\n }\n\n /**\n * Sets the record's name\n * @param {string} name The new name.\n * @returns {CognitoUserAttribute} The record for method chaining.\n */\n setName(name) {\n this.Name = name;\n return this;\n }\n\n /**\n * @returns {string} a string representation of the record.\n */\n toString() {\n return JSON.stringify(this);\n }\n\n /**\n * @returns {object} a flat object representing the record.\n */\n toJSON() {\n return {\n Name: this.Name,\n Value: this.Value,\n };\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoUserAttribute.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @class */\nexport default class CognitoUserSession {\n /**\n * Constructs a new CognitoUserSession object\n * @param {string} IdToken The session's Id token.\n * @param {string=} RefreshToken The session's refresh token.\n * @param {string} AccessToken The session's access token.\n */\n constructor({ IdToken, RefreshToken, AccessToken } = {}) {\n if (AccessToken == null || IdToken == null) {\n throw new Error('Id token and Access Token must be present.');\n }\n\n this.idToken = IdToken;\n this.refreshToken = RefreshToken;\n this.accessToken = AccessToken;\n }\n\n /**\n * @returns {CognitoIdToken} the session's Id token\n */\n getIdToken() {\n return this.idToken;\n }\n\n /**\n * @returns {CognitoRefreshToken} the session's refresh token\n */\n getRefreshToken() {\n return this.refreshToken;\n }\n\n /**\n * @returns {CognitoAccessToken} the session's access token\n */\n getAccessToken() {\n return this.accessToken;\n }\n\n /**\n * Checks to see if the session is still valid based on session expiry information found\n * in tokens and the current time\n * @returns {boolean} if the session is still valid\n */\n isValid() {\n const now = Math.floor(new Date() / 1000);\n\n return now < this.accessToken.getExpiration() && now < this.idToken.getExpiration();\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoUserSession.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst monthNames =\n ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\nconst weekNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];\n\n/** @class */\nexport default class DateHelper {\n /**\n * @returns {string} The current time in \"ddd MMM D HH:mm:ss UTC YYYY\" format.\n */\n getNowString() {\n const now = new Date();\n\n const weekDay = weekNames[now.getUTCDay()];\n const month = monthNames[now.getUTCMonth()];\n const day = now.getUTCDate();\n\n let hours = now.getUTCHours();\n if (hours < 10) {\n hours = `0${hours}`;\n }\n\n let minutes = now.getUTCMinutes();\n if (minutes < 10) {\n minutes = `0${minutes}`;\n }\n\n let seconds = now.getUTCSeconds();\n if (seconds < 10) {\n seconds = `0${seconds}`;\n }\n\n const year = now.getUTCFullYear();\n\n // ddd MMM D HH:mm:ss UTC YYYY\n const dateNow = `${weekDay} ${month} ${day} ${hours}:${minutes}:${seconds} UTC ${year}`;\n\n return dateNow;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/DateHelper.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nlet dataMemory = {};\n\n/** @class */\nclass MemoryStorage {\n\n /**\n * This is used to set a specific item in storage\n * @param {string} key - the key for the item\n * @param {object} value - the value\n * @returns {string} value that was set\n */\n static setItem(key, value) {\n dataMemory[key] = value;\n return dataMemory[key];\n }\n\n /**\n * This is used to get a specific key from storage\n * @param {string} key - the key for the item\n * This is used to clear the storage\n * @returns {string} the data item\n */\n static getItem(key) {\n return Object.prototype.hasOwnProperty.call(dataMemory, key) ? dataMemory[key] : undefined;\n }\n\n /**\n * This is used to remove an item from storage\n * @param {string} key - the key being set\n * @returns {string} value - value that was deleted\n */\n static removeItem(key) {\n return delete dataMemory[key];\n }\n\n /**\n * This is used to clear the storage\n * @returns {string} nothing\n */\n static clear() {\n dataMemory = {};\n return dataMemory;\n }\n}\n\n/** @class */\nexport default class StorageHelper {\n\n /**\n * This is used to get a storage object\n * @returns {object} the storage\n */\n constructor() {\n try {\n this.storageWindow = window.localStorage;\n this.storageWindow.setItem('aws.cognito.test-ls', 1);\n this.storageWindow.removeItem('aws.cognito.test-ls');\n } catch (exception) {\n this.storageWindow = MemoryStorage;\n }\n }\n\n /**\n * This is used to return the storage\n * @returns {object} the storage\n */\n getStorage() {\n return this.storageWindow;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/StorageHelper.js","module.exports = __WEBPACK_EXTERNAL_MODULE_12__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":[\"AWSCognito\",\"CognitoIdentityServiceProvider\"],\"commonjs2\":\"aws-sdk/clients/cognitoidentityserviceprovider\",\"commonjs\":\"aws-sdk/clients/cognitoidentityserviceprovider\",\"amd\":\"aws-sdk/clients/cognitoidentityserviceprovider\"}\n// module id = 12\n// module chunks = 0","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @class */\nexport default class AuthenticationDetails {\n /**\n * Constructs a new AuthenticationDetails object\n * @param {object=} data Creation options.\n * @param {string} data.Username User being authenticated.\n * @param {string} data.Password Plain-text password to authenticate with.\n * @param {(AttributeArg[])?} data.ValidationData Application extra metadata.\n */\n constructor(data) {\n const { ValidationData, Username, Password } = data || {};\n this.validationData = ValidationData || [];\n this.username = Username;\n this.password = Password;\n }\n\n /**\n * @returns {string} the record's username\n */\n getUsername() {\n return this.username;\n }\n\n /**\n * @returns {string} the record's password\n */\n getPassword() {\n return this.password;\n }\n\n /**\n * @returns {Array} the record's validationData\n */\n getValidationData() {\n return this.validationData;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/AuthenticationDetails.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport CognitoIdentityServiceProvider from 'aws-sdk/clients/cognitoidentityserviceprovider';\n\nimport CognitoUser from './CognitoUser';\nimport StorageHelper from './StorageHelper';\n\n/** @class */\nexport default class CognitoUserPool {\n /**\n * Constructs a new CognitoUserPool object\n * @param {object} data Creation options.\n * @param {string} data.UserPoolId Cognito user pool id.\n * @param {string} data.ClientId User pool application client id.\n * @param {object} data.Storage Optional storage object.\n */\n constructor(data) {\n const { UserPoolId, ClientId } = data || {};\n if (!UserPoolId || !ClientId) {\n throw new Error('Both UserPoolId and ClientId are required.');\n }\n if (!/^[\\w-]+_.+$/.test(UserPoolId)) {\n throw new Error('Invalid UserPoolId format.');\n }\n const region = UserPoolId.split('_')[0];\n\n this.userPoolId = UserPoolId;\n this.clientId = ClientId;\n\n this.client = new CognitoIdentityServiceProvider({ apiVersion: '2016-04-19', region });\n\n this.storage = data.Storage || new StorageHelper().getStorage();\n }\n\n /**\n * @returns {string} the user pool id\n */\n getUserPoolId() {\n return this.userPoolId;\n }\n\n /**\n * @returns {string} the client id\n */\n getClientId() {\n return this.clientId;\n }\n\n /**\n * @typedef {object} SignUpResult\n * @property {CognitoUser} user New user.\n * @property {bool} userConfirmed If the user is already confirmed.\n */\n /**\n * method for signing up a user\n * @param {string} username User's username.\n * @param {string} password Plain-text initial password entered by user.\n * @param {(AttributeArg[])=} userAttributes New user attributes.\n * @param {(AttributeArg[])=} validationData Application metadata.\n * @param {nodeCallback} callback Called on error or with the new user.\n * @returns {void}\n */\n signUp(username, password, userAttributes, validationData, callback) {\n this.client.makeUnauthenticatedRequest('signUp', {\n ClientId: this.clientId,\n Username: username,\n Password: password,\n UserAttributes: userAttributes,\n ValidationData: validationData,\n }, (err, data) => {\n if (err) {\n return callback(err, null);\n }\n\n const cognitoUser = {\n Username: username,\n Pool: this\n };\n\n const returnData = {\n user: new CognitoUser(cognitoUser),\n userConfirmed: data.UserConfirmed,\n };\n\n return callback(null, returnData);\n });\n }\n\n\n /**\n * method for getting the current user of the application from the local storage\n *\n * @returns {CognitoUser} the user retrieved from storage\n */\n getCurrentUser() {\n const lastUserKey = `CognitoIdentityServiceProvider.${this.clientId}.LastAuthUser`;\n\n const lastAuthUser = this.storage.getItem(lastUserKey);\n if (lastAuthUser) {\n const cognitoUser = {\n Username: lastAuthUser,\n Pool: this\n };\n\n return new CognitoUser(cognitoUser);\n }\n\n return null;\n }\n\n /**\n * This is used to return the storage\n * @returns {object} the storage\n */\n getStorage() {\n return this.storage;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/CognitoUserPool.js","/*!\n * Copyright 2016 Amazon.com,\n * Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Amazon Software License (the \"License\").\n * You may not use this file except in compliance with the\n * License. A copy of the License is located at\n *\n * http://aws.amazon.com/asl/\n *\n * or in the \"license\" file accompanying this file. This file is\n * distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, express or implied. See the License\n * for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { default as AuthenticationDetails } from './AuthenticationDetails';\nexport { default as AuthenticationHelper } from './AuthenticationHelper';\nexport { default as CognitoAccessToken } from './CognitoAccessToken';\nexport { default as CognitoIdToken } from './CognitoIdToken';\nexport { default as CognitoRefreshToken } from './CognitoRefreshToken';\nexport { default as CognitoUser } from './CognitoUser';\nexport { default as CognitoUserAttribute } from './CognitoUserAttribute';\nexport { default as CognitoUserPool } from './CognitoUserPool';\nexport { default as CognitoUserSession } from './CognitoUserSession';\nexport { default as DateHelper } from './DateHelper';\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js"],"sourceRoot":""} \ No newline at end of file diff --git a/index.d.ts b/index.d.ts index 40da4aa9..523c7b30 100644 --- a/index.d.ts +++ b/index.d.ts @@ -27,7 +27,6 @@ declare module "amazon-cognito-identity-js" { export interface ICognitoUserData { Username: string; Pool: CognitoUserPool; - Storage?: ICognitoStorage; } export class CognitoUser { @@ -112,6 +111,7 @@ declare module "amazon-cognito-identity-js" { public signUp(username: string, password: string, userAttributes: CognitoUserAttribute[], validationData: CognitoUserAttribute[], callback: NodeCallback): void; public getCurrentUser(): CognitoUser | null; + public getStorage(): ICognitoStorage; } export interface ICognitoUserSessionData { diff --git a/src/CognitoUser.js b/src/CognitoUser.js index 606f3b1f..943abcd1 100644 --- a/src/CognitoUser.js +++ b/src/CognitoUser.js @@ -90,7 +90,7 @@ export default class CognitoUser { this.signInUserSession = null; this.authenticationFlowType = 'USER_SRP_AUTH'; - this.storage = data.Storage || new StorageHelper().getStorage(); + this.storage = this.pool.getStorage(); } /** diff --git a/src/CognitoUserPool.js b/src/CognitoUserPool.js index 98907f0b..1d15919e 100644 --- a/src/CognitoUserPool.js +++ b/src/CognitoUserPool.js @@ -89,8 +89,7 @@ export default class CognitoUserPool { const cognitoUser = { Username: username, - Pool: this, - Storage: this.storage, + Pool: this }; const returnData = { @@ -115,8 +114,7 @@ export default class CognitoUserPool { if (lastAuthUser) { const cognitoUser = { Username: lastAuthUser, - Pool: this, - Storage: this.storage, + Pool: this }; return new CognitoUser(cognitoUser); @@ -124,4 +122,12 @@ export default class CognitoUserPool { return null; } + + /** + * This is used to return the storage + * @returns {object} the storage + */ + getStorage() { + return this.storage; + } }