Skip to content

Instantly share code, notes, and snippets.

@hugotkk
Last active April 13, 2023 23:12
Show Gist options
  • Save hugotkk/21385eb08a366b587f1f434eff43f381 to your computer and use it in GitHub Desktop.
Save hugotkk/21385eb08a366b587f1f434eff43f381 to your computer and use it in GitHub Desktop.
Update file to S3 with Cognito: Login and Non-Login Approaches
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(function(){try{return require("crypto")}catch(t){}}()):"function"==typeof define&&define.amd?define(["crypto"],e):"object"==typeof exports?exports.AmazonCognitoIdentity=e(function(){try{return require("crypto")}catch(t){}}()):t.AmazonCognitoIdentity=e(t.crypto)}("undefined"!=typeof self?self:this,function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=20)}([function(t,e,n){"use strict";(function(t){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
var r=n(22),i=n(23),o=n(24);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,n){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,n);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return h(this,t)}return c(this,t,e,n)}function c(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,n,r){if(e.byteLength,n<0||e.byteLength<n)throw new RangeError("'offset' is out of bounds");if(e.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=l(t,e);return t}(t,e,n,r):"string"==typeof e?function(t,e,n){"string"==typeof n&&""!==n||(n="utf8");if(!u.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|g(e,n),i=(t=a(t,r)).write(e,n);i!==r&&(t=t.slice(0,i));return t}(t,e,n):function(t,e){if(u.isBuffer(e)){var n=0|d(e.length);return 0===(t=a(t,n)).length?t:(e.copy(t,0,0,n),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||function(t){return t!=t}(e.length)?a(t,0):l(t,e);if("Buffer"===e.type&&o(e.data))return l(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function h(t,e){if(f(e),t=a(t,e<0?0:0|d(e)),!u.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function l(t,e){var n=e.length<0?0:0|d(e.length);t=a(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function d(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function g(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return V(t).length;default:if(r)return L(t).length;e=(""+e).toLowerCase(),r=!0}}function p(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function v(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=u.from(e,r)),u.isBuffer(e))return 0===e.length?-1:y(t,e,n,r,i);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):y(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,n,r,i){var o,s=1,a=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var f=-1;for(o=n;o<a;o++)if(c(t,o)===c(e,-1===f?0:o-f)){if(-1===f&&(f=o),o-f+1===u)return f*s}else-1!==f&&(o-=o-f),f=-1}else for(n+u>a&&(n=a-u),o=n;o>=0;o--){for(var h=!0,l=0;l<u;l++)if(c(t,o+l)!==c(e,l)){h=!1;break}if(h)return o}return-1}function m(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[n+s]=a}return s}function S(t,e,n,r){return j(L(e,t.length-n),t,n,r)}function w(t,e,n,r){return j(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function C(t,e,n,r){return w(t,e,n,r)}function A(t,e,n,r){return j(V(e),t,n,r)}function U(t,e,n,r){return j(function(t,e){for(var n,r,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function E(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function T(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i<n;){var o,s,a,u,c=t[i],f=null,h=c>239?4:c>223?3:c>191?2:1;if(i+h<=n)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),i+=h}return function(t){var e=t.length;if(e<=D)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=D));return n}(r)}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,n){return c(null,t,e,n)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,n){return function(t,e,n,r){return f(e),e<=0?a(t,e):void 0!==n?"string"==typeof r?a(t,e).fill(n,r):a(t,e).fill(n):a(t,e)}(null,t,e,n)},u.allocUnsafe=function(t){return h(null,t)},u.allocUnsafeSlow=function(t){return h(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=u.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var s=t[n];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},u.byteLength=g,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)p(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)p(this,e,e+3),p(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)p(this,e,e+7),p(this,e+1,e+6),p(this,e+2,e+5),p(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?T(this,0,t):function(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,n);case"utf8":case"utf-8":return T(this,e,n);case"ascii":return b(this,e,n);case"latin1":case"binary":return I(this,e,n);case"base64":return E(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,n,r,i){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,i>>>=0,this===t)return 0;for(var o=i-r,s=n-e,a=Math.min(o,s),c=this.slice(r,i),f=t.slice(e,n),h=0;h<a;++h)if(c[h]!==f[h]){o=c[h],s=f[h];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},u.prototype.indexOf=function(t,e,n){return v(this,t,e,n,!0)},u.prototype.lastIndexOf=function(t,e,n){return v(this,t,e,n,!1)},u.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return m(this,t,e,n);case"utf8":case"utf-8":return S(this,t,e,n);case"ascii":return w(this,t,e,n);case"latin1":case"binary":return C(this,t,e,n);case"base64":return A(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var D=4096;function b(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function I(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function _(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=e;o<n;++o)i+=K(t[o]);return i}function P(t,e,n){for(var r=t.slice(e,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function R(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function k(t,e,n,r,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function O(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i<o;++i)t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function B(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i<o;++i)t[n+i]=e>>>8*(r?i:3-i)&255}function F(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function M(t,e,n,r,o){return o||F(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function x(t,e,n,r,o){return o||F(t,0,n,8),i.write(t,e,n,r,52,8),n+8}u.prototype.slice=function(t,e){var n,r=this.length;if(t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=u.prototype;else{var i=e-t;n=new u(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+t]}return n},u.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||R(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r},u.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||R(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);)r+=this[t+--e]*i;return r},u.prototype.readUInt8=function(t,e){return e||R(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||R(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||R(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||R(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*e)),r},u.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||R(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||R(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(t,e){e||R(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(t,e){return e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||R(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||R(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||R(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||R(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||k(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},u.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||k(this,t,e,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},u.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||k(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||k(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||k(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):O(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||k(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):B(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||k(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);k(this,t,e,n,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o<n&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+n},u.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);k(this,t,e,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+n},u.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||k(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||k(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||k(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):O(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||k(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):B(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||k(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,n){return M(this,t,e,!0,n)},u.prototype.writeFloatBE=function(t,e,n){return M(this,t,e,!1,n)},u.prototype.writeDoubleLE=function(t,e,n){return x(this,t,e,!0,n)},u.prototype.writeDoubleBE=function(t,e,n){return x(this,t,e,!1,n)},u.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var i,o=r-n;if(this===t&&n<e&&e<r)for(i=o-1;i>=0;--i)t[i+e]=this[i+n];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),e);return o},u.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var o;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o<n;++o)this[o]=t;else{var s=u.isBuffer(t)?t:L(new u(t,r).toString()),a=s.length;for(o=0;o<n-e;++o)this[o+e]=s[o%a]}return this};var N=/[^+\/0-9A-Za-z-_]/g;function K(t){return t<16?"0"+t.toString(16):t.toString(16)}function L(t,e){var n;e=e||1/0;for(var r=t.length,i=null,o=[],s=0;s<r;++s){if((n=t.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function V(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(N,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function j(t,e,n,r){for(var i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}}).call(e,n(2))},function(t,e,n){"use strict";n.d(e,"a",function(){return f});var r=n(0),i=(n.n(r),n(3)),o=n(4),s=(n.n(o),n(7));
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
function a(t){return r.Buffer.from((new i.a).random(t).toString(),"hex")}var u=/^[89a-f]/i,c="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",f=function(){function t(t){this.N=new s.a(c,16),this.g=new s.a("2",16),this.k=new s.a(this.hexHash(""+this.padHex(this.N)+this.padHex(this.g)),16),this.smallAValue=this.generateRandomSmallA(),this.getLargeAValue(function(){}),this.infoBits=r.Buffer.from("Caldera Derived Key","utf8"),this.poolName=t}var e=t.prototype;return e.getSmallAValue=function(){return this.smallAValue},e.getLargeAValue=function(t){var e=this;this.largeAValue?t(null,this.largeAValue):this.calculateA(this.smallAValue,function(n,r){n&&t(n,null),e.largeAValue=r,t(null,e.largeAValue)})},e.generateRandomSmallA=function(){var t=a(128).toString("hex");return new s.a(t,16)},e.generateRandomString=function(){return a(40).toString("base64")},e.getRandomPassword=function(){return this.randomPassword},e.getSaltDevices=function(){return this.SaltToHashDevices},e.getVerifierDevices=function(){return this.verifierDevices},e.generateHashDevice=function(t,e,n){var r=this;this.randomPassword=this.generateRandomString();var i=""+t+e+":"+this.randomPassword,o=this.hash(i),u=a(16).toString("hex");this.SaltToHashDevices=this.padHex(new s.a(u,16)),this.g.modPow(new s.a(this.hexHash(this.SaltToHashDevices+o),16),this.N,function(t,e){t&&n(t,null),r.verifierDevices=r.padHex(e),n(null,null)})},e.calculateA=function(t,e){var n=this;this.g.modPow(t,this.N,function(t,r){t&&e(t,null),r.mod(n.N).equals(s.a.ZERO)&&e(new Error("Illegal paramater. A mod N cannot be 0."),null),e(null,r)})},e.calculateU=function(t,e){return this.UHexHash=this.hexHash(this.padHex(t)+this.padHex(e)),new s.a(this.UHexHash,16)},e.hash=function(t){var e=new o.Sha256;e.update(t);var n=e.digestSync(),i=r.Buffer.from(n).toString("hex");return new Array(64-i.length).join("0")+i},e.hexHash=function(t){return this.hash(r.Buffer.from(t,"hex"))},e.computehkdf=function(t,e){var n=r.Buffer.concat([this.infoBits,r.Buffer.from(String.fromCharCode(1),"utf8")]),i=new o.Sha256(e);i.update(t);var s=i.digestSync(),a=new o.Sha256(s);return a.update(n),a.digestSync().slice(0,16)},e.getPasswordAuthenticationKey=function(t,e,n,i,o){var a=this;if(n.mod(this.N).equals(s.a.ZERO))throw new Error("B cannot be zero.");if(this.UValue=this.calculateU(this.largeAValue,n),this.UValue.equals(s.a.ZERO))throw new Error("U cannot be zero.");var u=""+this.poolName+t+":"+e,c=this.hash(u),f=new s.a(this.hexHash(this.padHex(i)+c),16);this.calculateS(f,n,function(t,e){t&&o(t,null);var n=a.computehkdf(r.Buffer.from(a.padHex(e),"hex"),r.Buffer.from(a.padHex(a.UValue),"hex"));o(null,n)})},e.calculateS=function(t,e,n){var r=this;this.g.modPow(t,this.N,function(i,o){i&&n(i,null),e.subtract(r.k.multiply(o)).modPow(r.smallAValue.add(r.UValue.multiply(t)),r.N,function(t,e){t&&n(t,null),n(null,e.mod(r.N))})})},e.getNewPasswordRequiredChallengeUserAttributePrefix=function(){return"userAttributes."},e.padHex=function(t){if(!(t instanceof s.a))throw new Error("Not a BigInteger");var e=t.compareTo(s.a.ZERO)<0,n=t.abs().toString(16);if(n=n.length%2!=0?"0"+n:n,n=u.test(n)?"00"+n:n,e){var r=n.split("").map(function(t){var e=15&~parseInt(t,16);return"0123456789ABCDEF".charAt(e)}).join("");(n=new s.a(r,16).add(s.a.ONE).toString(16)).toUpperCase().startsWith("FF8")&&(n=n.substring(2))}return n},t}()},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.d(e,"a",function(){return i});var r=n(25);var i=function(){function t(t,e){t=this.words=t||[],this.sigBytes=void 0!=e?e:4*t.length}var e=t.prototype;return e.random=function(e){for(var n=[],i=0;i<e;i+=4)n.push(Object(r.a)());return new t(n,e)},e.toString=function(){return function(t){for(var e=t.words,n=t.sigBytes,r=[],i=0;i<n;i++){var o=e[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")}(this)},t}()},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),(0,n(5).__exportStar)(n(27),e)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.__extends=function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},n.d(e,"__assign",function(){return i}),e.__rest=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n},e.__decorate=function(t,e,n,r){var i,o=arguments.length,s=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},e.__param=function(t,e){return function(n,r){e(n,r,t)}},e.__metadata=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},e.__awaiter=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){t.done?i(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}u((r=r.apply(t,e||[])).next())})},e.__generator=function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},e.__createBinding=function(t,e,n,r){void 0===r&&(r=n);t[r]=e[n]},e.__exportStar=function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||(e[n]=t[n])},e.__values=o,e.__read=s,e.__spread=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t},e.__spreadArrays=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var r=Array(t),i=0,e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r},e.__await=a,e.__asyncGenerator=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(t,e||[]),o=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(t){i[t]&&(r[t]=function(e){return new Promise(function(n,r){o.push([t,e,n,r])>1||u(t,e)})})}function u(t,e){try{!function(t){t.value instanceof a?Promise.resolve(t.value.v).then(c,f):h(o[0][2],t)}(i[t](e))}catch(t){h(o[0][3],t)}}function c(t){u("next",t)}function f(t){u("throw",t)}function h(t,e){t(e),o.shift(),o.length&&u(o[0][0],o[0][1])}},e.__asyncDelegator=function(t){var e,n;return e={},r("next"),r("throw",function(t){throw t}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(r,i){e[r]=t[r]?function(e){return(n=!n)?{value:a(t[r](e)),done:"return"===r}:i?i(e):e}:i}},e.__asyncValues=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=o(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise(function(r,i){e=t[n](e),function(t,e,n,r){Promise.resolve(r).then(function(e){t({value:e,done:n})},e)}(r,i,e.done,e.value)})}}},e.__makeTemplateObject=function(t,e){Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e;return t},e.__importStar=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e},e.__importDefault=function(t){return t&&t.__esModule?t:{default:t}},e.__classPrivateFieldGet=function(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)},e.__classPrivateFieldSet=function(t,e,n){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,n),n};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function o(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function a(t){return this instanceof a?(this.v=t,this):new a(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MAX_HASHABLE_LENGTH=e.INIT=e.KEY=e.DIGEST_LENGTH=e.BLOCK_SIZE=void 0,e.BLOCK_SIZE=64,e.DIGEST_LENGTH=32,e.KEY=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),e.INIT=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],e.MAX_HASHABLE_LENGTH=Math.pow(2,53)-1},function(t,e,n){"use strict";function r(t,e){null!=t&&this.fromString(t,e)}function i(){return new r(null)}var o;e.a=r;var s="undefined"!=typeof navigator;s&&"Microsoft Internet Explorer"==navigator.appName?(r.prototype.am=function(t,e,n,r,i,o){for(var s=32767&e,a=e>>15;--o>=0;){var u=32767&this[t],c=this[t++]>>15,f=a*u+c*s;i=((u=s*u+((32767&f)<<15)+n[r]+(1073741823&i))>>>30)+(f>>>15)+a*c+(i>>>30),n[r++]=1073741823&u}return i},o=30):s&&"Netscape"!=navigator.appName?(r.prototype.am=function(t,e,n,r,i,o){for(;--o>=0;){var s=e*this[t++]+n[r]+i;i=Math.floor(s/67108864),n[r++]=67108863&s}return i},o=26):(r.prototype.am=function(t,e,n,r,i,o){for(var s=16383&e,a=e>>14;--o>=0;){var u=16383&this[t],c=this[t++]>>14,f=a*u+c*s;i=((u=s*u+((16383&f)<<14)+n[r]+i)>>28)+(f>>14)+a*c,n[r++]=268435455&u}return i},o=28),r.prototype.DB=o,r.prototype.DM=(1<<o)-1,r.prototype.DV=1<<o;r.prototype.FV=Math.pow(2,52),r.prototype.F1=52-o,r.prototype.F2=2*o-52;var a,u,c="0123456789abcdefghijklmnopqrstuvwxyz",f=new Array;for(a="0".charCodeAt(0),u=0;u<=9;++u)f[a++]=u;for(a="a".charCodeAt(0),u=10;u<36;++u)f[a++]=u;for(a="A".charCodeAt(0),u=10;u<36;++u)f[a++]=u;function h(t){return c.charAt(t)}function l(t,e){var n=f[t.charCodeAt(e)];return null==n?-1:n}function d(t){var e=i();return e.fromInt(t),e}function g(t){var e,n=1;return 0!=(e=t>>>16)&&(t=e,n+=16),0!=(e=t>>8)&&(t=e,n+=8),0!=(e=t>>4)&&(t=e,n+=4),0!=(e=t>>2)&&(t=e,n+=2),0!=(e=t>>1)&&(t=e,n+=1),n}function p(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}p.prototype.convert=function(t){var e=i();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(r.ZERO)>0&&this.m.subTo(e,e),e},p.prototype.revert=function(t){var e=i();return t.copyTo(e),this.reduce(e),e},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var n=32767&t[e],r=n*this.mpl+((n*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[n=e+this.m.t]+=this.m.am(0,r,t,e,0,this.m.t);t[n]>=t.DV;)t[n]-=t.DV,t[++n]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},r.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},r.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},r.prototype.fromString=function(t,e){var n;if(16==e)n=4;else if(8==e)n=3;else if(2==e)n=1;else if(32==e)n=5;else{if(4!=e)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");n=2}this.t=0,this.s=0;for(var i=t.length,o=!1,s=0;--i>=0;){var a=l(t,i);a<0?"-"==t.charAt(i)&&(o=!0):(o=!1,0==s?this[this.t++]=a:s+n>this.DB?(this[this.t-1]|=(a&(1<<this.DB-s)-1)<<s,this[this.t++]=a>>this.DB-s):this[this.t-1]|=a<<s,(s+=n)>=this.DB&&(s-=this.DB))}this.clamp(),o&&r.ZERO.subTo(this,this)},r.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},r.prototype.dlShiftTo=function(t,e){var n;for(n=this.t-1;n>=0;--n)e[n+t]=this[n];for(n=t-1;n>=0;--n)e[n]=0;e.t=this.t+t,e.s=this.s},r.prototype.drShiftTo=function(t,e){for(var n=t;n<this.t;++n)e[n-t]=this[n];e.t=Math.max(this.t-t,0),e.s=this.s},r.prototype.lShiftTo=function(t,e){var n,r=t%this.DB,i=this.DB-r,o=(1<<i)-1,s=Math.floor(t/this.DB),a=this.s<<r&this.DM;for(n=this.t-1;n>=0;--n)e[n+s+1]=this[n]>>i|a,a=(this[n]&o)<<r;for(n=s-1;n>=0;--n)e[n]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},r.prototype.rShiftTo=function(t,e){e.s=this.s;var n=Math.floor(t/this.DB);if(n>=this.t)e.t=0;else{var r=t%this.DB,i=this.DB-r,o=(1<<r)-1;e[0]=this[n]>>r;for(var s=n+1;s<this.t;++s)e[s-n-1]|=(this[s]&o)<<i,e[s-n]=this[s]>>r;r>0&&(e[this.t-n-1]|=(this.s&o)<<i),e.t=this.t-n,e.clamp()}},r.prototype.subTo=function(t,e){for(var n=0,r=0,i=Math.min(t.t,this.t);n<i;)r+=this[n]-t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r-=t[n],e[n++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[n++]=this.DV+r:r>0&&(e[n++]=r),e.t=n,e.clamp()},r.prototype.multiplyTo=function(t,e){var n=this.abs(),i=t.abs(),o=n.t;for(e.t=o+i.t;--o>=0;)e[o]=0;for(o=0;o<i.t;++o)e[o+n.t]=n.am(0,i[o],e,o,0,n.t);e.s=0,e.clamp(),this.s!=t.s&&r.ZERO.subTo(e,e)},r.prototype.squareTo=function(t){for(var e=this.abs(),n=t.t=2*e.t;--n>=0;)t[n]=0;for(n=0;n<e.t-1;++n){var r=e.am(n,e[n],t,2*n,0,1);(t[n+e.t]+=e.am(n+1,2*e[n],t,2*n+1,r,e.t-n-1))>=e.DV&&(t[n+e.t]-=e.DV,t[n+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(n,e[n],t,2*n,0,1)),t.s=0,t.clamp()},r.prototype.divRemTo=function(t,e,n){var o=t.abs();if(!(o.t<=0)){var s=this.abs();if(s.t<o.t)return null!=e&&e.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=i());var a=i(),u=this.s,c=t.s,f=this.DB-g(o[o.t-1]);f>0?(o.lShiftTo(f,a),s.lShiftTo(f,n)):(o.copyTo(a),s.copyTo(n));var h=a.t,l=a[h-1];if(0!=l){var d=l*(1<<this.F1)+(h>1?a[h-2]>>this.F2:0),p=this.FV/d,v=(1<<this.F1)/d,y=1<<this.F2,m=n.t,S=m-h,w=null==e?i():e;for(a.dlShiftTo(S,w),n.compareTo(w)>=0&&(n[n.t++]=1,n.subTo(w,n)),r.ONE.dlShiftTo(h,w),w.subTo(a,a);a.t<h;)a[a.t++]=0;for(;--S>=0;){var C=n[--m]==l?this.DM:Math.floor(n[m]*p+(n[m-1]+y)*v);if((n[m]+=a.am(0,C,n,S,0,h))<C)for(a.dlShiftTo(S,w),n.subTo(w,n);n[m]<--C;)n.subTo(w,n)}null!=e&&(n.drShiftTo(h,e),u!=c&&r.ZERO.subTo(e,e)),n.t=h,n.clamp(),f>0&&n.rShiftTo(f,n),u<0&&r.ZERO.subTo(n,n)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},r.prototype.addTo=function(t,e){for(var n=0,r=0,i=Math.min(t.t,this.t);n<i;)r+=this[n]+t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r+=t[n],e[n++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[n++]=r:r<-1&&(e[n++]=this.DV+r),e.t=n,e.clamp()},r.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");e=2}var n,r=(1<<e)-1,i=!1,o="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(n=this[s]>>a)>0&&(i=!0,o=h(n));s>=0;)a<e?(n=(this[s]&(1<<a)-1)<<e-a,n|=this[--s]>>(a+=this.DB-e)):(n=this[s]>>(a-=e)&r,a<=0&&(a+=this.DB,--s)),n>0&&(i=!0),i&&(o+=h(n));return i?o:"0"},r.prototype.negate=function(){var t=i();return r.ZERO.subTo(this,t),t},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var n=this.t;if(0!=(e=n-t.t))return this.s<0?-e:e;for(;--n>=0;)if(0!=(e=this[n]-t[n]))return e;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+g(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(t){var e=i();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(r.ZERO)>0&&t.subTo(e,e),e},r.prototype.equals=function(t){return 0==this.compareTo(t)},r.prototype.add=function(t){var e=i();return this.addTo(t,e),e},r.prototype.subtract=function(t){var e=i();return this.subTo(t,e),e},r.prototype.multiply=function(t){var e=i();return this.multiplyTo(t,e),e},r.prototype.divide=function(t){var e=i();return this.divRemTo(t,e,null),e},r.prototype.modPow=function(t,e,n){var r,o=t.bitLength(),s=d(1),a=new p(e);if(o<=0)return s;r=o<18?1:o<48?3:o<144?4:o<768?5:6;var u=new Array,c=3,f=r-1,h=(1<<r)-1;if(u[1]=a.convert(this),r>1){var l=i();for(a.sqrTo(u[1],l);c<=h;)u[c]=i(),a.mulTo(l,u[c-2],u[c]),c+=2}var v,y,m=t.t-1,S=!0,w=i();for(o=g(t[m])-1;m>=0;){for(o>=f?v=t[m]>>o-f&h:(v=(t[m]&(1<<o+1)-1)<<f-o,m>0&&(v|=t[m-1]>>this.DB+o-f)),c=r;0==(1&v);)v>>=1,--c;if((o-=c)<0&&(o+=this.DB,--m),S)u[v].copyTo(s),S=!1;else{for(;c>1;)a.sqrTo(s,w),a.sqrTo(w,s),c-=2;c>0?a.sqrTo(s,w):(y=s,s=w,w=y),a.mulTo(w,u[v],s)}for(;m>=0&&0==(t[m]&1<<o);)a.sqrTo(s,w),y=s,s=w,w=y,--o<0&&(o=this.DB-1,--m)}var C=a.revert(s);return n(null,C),C},r.ZERO=d(0),r.ONE=d(1)},function(t,e,n){"use strict";function r(t,e){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/n.d(e,"a",function(){return i});var i=function(t){function e(e){var n=(void 0===e?{}:e).AccessToken;return t.call(this,n||"")||this}return function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}(e,t),e}(n(9).a)},function(t,e,n){"use strict";n.d(e,"a",function(){return i});var r=n(0),i=(n.n(r),function(){function t(t){this.jwtToken=t||"",this.payload=this.decodePayload()}var e=t.prototype;return e.getJwtToken=function(){return this.jwtToken},e.getExpiration=function(){return this.payload.exp},e.getIssuedAt=function(){return this.payload.iat},e.decodePayload=function(){var t=this.jwtToken.split(".")[1];try{return JSON.parse(r.Buffer.from(t,"base64").toString("utf8"))}catch(t){return{}}},t}())},function(t,e,n){"use strict";function r(t,e){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/n.d(e,"a",function(){return i});var i=function(t){function e(e){var n=(void 0===e?{}:e).IdToken;return t.call(this,n||"")||this}return function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}(e,t),e}(n(9).a)},function(t,e,n){"use strict";n.d(e,"a",function(){return r});
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
var r=function(){function t(t){var e=(void 0===t?{}:t).RefreshToken;this.token=e||""}return t.prototype.getToken=function(){return this.token},t}()},function(t,e,n){"use strict";n.d(e,"a",function(){return v});var r=n(0),i=(n.n(r),n(4)),o=(n.n(i),n(13)),s=n(7),a=n(1),u=n(8),c=n(10),f=n(11),h=n(14),l=n(15),d=n(16),g=n(17),p="undefined"!=typeof navigator?o.a.isReactNative?"react-native":navigator.userAgent:"nodejs",v=function(){function t(t){if(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 g.a).getStorage(),this.keyPrefix="CognitoIdentityServiceProvider."+this.pool.getClientId(),this.userDataKey=this.keyPrefix+"."+this.username+".userData"}var e=t.prototype;return e.setSignInUserSession=function(t){this.clearCachedUserData(),this.signInUserSession=t,this.cacheTokens()},e.getSignInUserSession=function(){return this.signInUserSession},e.getUsername=function(){return this.username},e.getAuthenticationFlowType=function(){return this.authenticationFlowType},e.setAuthenticationFlowType=function(t){this.authenticationFlowType=t},e.initiateAuth=function(t,e){var n=this,r=t.getAuthParameters();r.USERNAME=this.username;var i=0!==Object.keys(t.getValidationData()).length?t.getValidationData():t.getClientMetadata(),o={AuthFlow:"CUSTOM_AUTH",ClientId:this.pool.getClientId(),AuthParameters:r,ClientMetadata:i};this.getUserContextData()&&(o.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",o,function(t,r){if(t)return e.onFailure(t);var i=r.ChallengeName,o=r.ChallengeParameters;return"CUSTOM_CHALLENGE"===i?(n.Session=r.Session,e.customChallenge(o)):(n.signInUserSession=n.getCognitoUserSession(r.AuthenticationResult),n.cacheTokens(),e.onSuccess(n.signInUserSession))})},e.authenticateUser=function(t,e){return"USER_PASSWORD_AUTH"===this.authenticationFlowType?this.authenticateUserPlainUsernamePassword(t,e):"USER_SRP_AUTH"===this.authenticationFlowType||"CUSTOM_AUTH"===this.authenticationFlowType?this.authenticateUserDefaultAuth(t,e):e.onFailure(new Error("Authentication flow type is invalid."))},e.authenticateUserDefaultAuth=function(t,e){var n,o,u=this,c=new a.a(this.pool.getUserPoolName()),f=new l.a,h={};null!=this.deviceKey&&(h.DEVICE_KEY=this.deviceKey),h.USERNAME=this.username,c.getLargeAValue(function(a,l){a&&e.onFailure(a),h.SRP_A=l.toString(16),"CUSTOM_AUTH"===u.authenticationFlowType&&(h.CHALLENGE_NAME="SRP_A");var d=0!==Object.keys(t.getValidationData()).length?t.getValidationData():t.getClientMetadata(),g={AuthFlow:u.authenticationFlowType,ClientId:u.pool.getClientId(),AuthParameters:h,ClientMetadata:d};u.getUserContextData(u.username)&&(g.UserContextData=u.getUserContextData(u.username)),u.client.request("InitiateAuth",g,function(a,h){if(a)return e.onFailure(a);var l=h.ChallengeParameters;u.username=l.USER_ID_FOR_SRP,u.userDataKey=u.keyPrefix+"."+u.username+".userData",n=new s.a(l.SRP_B,16),o=new s.a(l.SALT,16),u.getCachedDeviceKeyAndPassword(),c.getPasswordAuthenticationKey(u.username,t.getPassword(),n,o,function(t,n){t&&e.onFailure(t);var o=f.getNowString(),s=r.Buffer.concat([r.Buffer.from(u.pool.getUserPoolName(),"utf8"),r.Buffer.from(u.username,"utf8"),r.Buffer.from(l.SECRET_BLOCK,"base64"),r.Buffer.from(o,"utf8")]),a=new i.Sha256(n);a.update(s);var g=a.digestSync(),p=r.Buffer.from(g).toString("base64"),v={};v.USERNAME=u.username,v.PASSWORD_CLAIM_SECRET_BLOCK=l.SECRET_BLOCK,v.TIMESTAMP=o,v.PASSWORD_CLAIM_SIGNATURE=p,null!=u.deviceKey&&(v.DEVICE_KEY=u.deviceKey);var y={ChallengeName:"PASSWORD_VERIFIER",ClientId:u.pool.getClientId(),ChallengeResponses:v,Session:h.Session,ClientMetadata:d};u.getUserContextData()&&(y.UserContextData=u.getUserContextData()),function t(e,n){return u.client.request("RespondToAuthChallenge",e,function(r,i){return r&&"ResourceNotFoundException"===r.code&&-1!==r.message.toLowerCase().indexOf("device")?(v.DEVICE_KEY=null,u.deviceKey=null,u.randomPassword=null,u.deviceGroupKey=null,u.clearCachedDeviceKeyAndPassword(),t(e,n)):n(r,i)})}(y,function(t,n){return t?e.onFailure(t):u.authenticateUserInternal(n,c,e)})})})})},e.authenticateUserPlainUsernamePassword=function(t,e){var n=this,r={};if(r.USERNAME=this.username,r.PASSWORD=t.getPassword(),r.PASSWORD){var i=new a.a(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(r.DEVICE_KEY=this.deviceKey);var o=0!==Object.keys(t.getValidationData()).length?t.getValidationData():t.getClientMetadata(),s={AuthFlow:"USER_PASSWORD_AUTH",ClientId:this.pool.getClientId(),AuthParameters:r,ClientMetadata:o};this.getUserContextData(this.username)&&(s.UserContextData=this.getUserContextData(this.username)),this.client.request("InitiateAuth",s,function(t,r){return t?e.onFailure(t):n.authenticateUserInternal(r,i,e)})}else e.onFailure(new Error("PASSWORD parameter is required"))},e.authenticateUserInternal=function(t,e,n){var i=this,o=t.ChallengeName,s=t.ChallengeParameters;if("SMS_MFA"===o)return this.Session=t.Session,n.mfaRequired(o,s);if("SELECT_MFA_TYPE"===o)return this.Session=t.Session,n.selectMFAType(o,s);if("MFA_SETUP"===o)return this.Session=t.Session,n.mfaSetup(o,s);if("SOFTWARE_TOKEN_MFA"===o)return this.Session=t.Session,n.totpRequired(o,s);if("CUSTOM_CHALLENGE"===o)return this.Session=t.Session,n.customChallenge(s);if("NEW_PASSWORD_REQUIRED"===o){this.Session=t.Session;var a=null,u=null,c=[],f=e.getNewPasswordRequiredChallengeUserAttributePrefix();if(s&&(a=JSON.parse(t.ChallengeParameters.userAttributes),u=JSON.parse(t.ChallengeParameters.requiredAttributes)),u)for(var h=0;h<u.length;h++)c[h]=u[h].substr(f.length);return n.newPasswordRequired(a,c)}if("DEVICE_SRP_AUTH"===o)return this.Session=t.Session,void this.getDeviceResponse(n);this.signInUserSession=this.getCognitoUserSession(t.AuthenticationResult),this.challengeName=o,this.cacheTokens();var l=t.AuthenticationResult.NewDeviceMetadata;if(null==l)return n.onSuccess(this.signInUserSession);e.generateHashDevice(t.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,t.AuthenticationResult.NewDeviceMetadata.DeviceKey,function(o){if(o)return n.onFailure(o);var s={Salt:r.Buffer.from(e.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:r.Buffer.from(e.getVerifierDevices(),"hex").toString("base64")};i.verifierDevices=s.PasswordVerifier,i.deviceGroupKey=l.DeviceGroupKey,i.randomPassword=e.getRandomPassword(),i.client.request("ConfirmDevice",{DeviceKey:l.DeviceKey,AccessToken:i.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:s,DeviceName:p},function(e,r){return e?n.onFailure(e):(i.deviceKey=t.AuthenticationResult.NewDeviceMetadata.DeviceKey,i.cacheDeviceKeyAndPassword(),!0===r.UserConfirmationNecessary?n.onSuccess(i.signInUserSession,r.UserConfirmationNecessary):n.onSuccess(i.signInUserSession))})})},e.completeNewPasswordChallenge=function(t,e,n,r){var i=this;if(!t)return n.onFailure(new Error("New password is required."));var o=new a.a(this.pool.getUserPoolName()),s=o.getNewPasswordRequiredChallengeUserAttributePrefix(),u={};e&&Object.keys(e).forEach(function(t){u[s+t]=e[t]}),u.NEW_PASSWORD=t,u.USERNAME=this.username;var c={ChallengeName:"NEW_PASSWORD_REQUIRED",ClientId:this.pool.getClientId(),ChallengeResponses:u,Session:this.Session,ClientMetadata:r};this.getUserContextData()&&(c.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",c,function(t,e){return t?n.onFailure(t):i.authenticateUserInternal(e,o,n)})},e.getDeviceResponse=function(t,e){var n=this,o=new a.a(this.deviceGroupKey),u=new l.a,c={};c.USERNAME=this.username,c.DEVICE_KEY=this.deviceKey,o.getLargeAValue(function(a,f){a&&t.onFailure(a),c.SRP_A=f.toString(16);var h={ChallengeName:"DEVICE_SRP_AUTH",ClientId:n.pool.getClientId(),ChallengeResponses:c,ClientMetadata:e,Session:n.Session};n.getUserContextData()&&(h.UserContextData=n.getUserContextData()),n.client.request("RespondToAuthChallenge",h,function(e,a){if(e)return t.onFailure(e);var c=a.ChallengeParameters,f=new s.a(c.SRP_B,16),h=new s.a(c.SALT,16);o.getPasswordAuthenticationKey(n.deviceKey,n.randomPassword,f,h,function(e,o){if(e)return t.onFailure(e);var s=u.getNowString(),f=r.Buffer.concat([r.Buffer.from(n.deviceGroupKey,"utf8"),r.Buffer.from(n.deviceKey,"utf8"),r.Buffer.from(c.SECRET_BLOCK,"base64"),r.Buffer.from(s,"utf8")]),h=new i.Sha256(o);h.update(f);var l=h.digestSync(),d=r.Buffer.from(l).toString("base64"),g={};g.USERNAME=n.username,g.PASSWORD_CLAIM_SECRET_BLOCK=c.SECRET_BLOCK,g.TIMESTAMP=s,g.PASSWORD_CLAIM_SIGNATURE=d,g.DEVICE_KEY=n.deviceKey;var p={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:n.pool.getClientId(),ChallengeResponses:g,Session:a.Session};n.getUserContextData()&&(p.UserContextData=n.getUserContextData()),n.client.request("RespondToAuthChallenge",p,function(e,r){return e?t.onFailure(e):(n.signInUserSession=n.getCognitoUserSession(r.AuthenticationResult),n.cacheTokens(),t.onSuccess(n.signInUserSession))})})})})},e.confirmRegistration=function(t,e,n,r){var i={ClientId:this.pool.getClientId(),ConfirmationCode:t,Username:this.username,ForceAliasCreation:e,ClientMetadata:r};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmSignUp",i,function(t){return t?n(t,null):n(null,"SUCCESS")})},e.sendCustomChallengeAnswer=function(t,e,n){var r=this,i={};i.USERNAME=this.username,i.ANSWER=t;var o=new a.a(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(i.DEVICE_KEY=this.deviceKey);var s={ChallengeName:"CUSTOM_CHALLENGE",ChallengeResponses:i,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:n};this.getUserContextData()&&(s.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",s,function(t,n){return t?e.onFailure(t):r.authenticateUserInternal(n,o,e)})},e.sendMFACode=function(t,e,n,i){var o=this,s={};s.USERNAME=this.username,s.SMS_MFA_CODE=t;var u=n||"SMS_MFA";"SOFTWARE_TOKEN_MFA"===u&&(s.SOFTWARE_TOKEN_MFA_CODE=t),null!=this.deviceKey&&(s.DEVICE_KEY=this.deviceKey);var c={ChallengeName:u,ChallengeResponses:s,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:i};this.getUserContextData()&&(c.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",c,function(t,n){if(t)return e.onFailure(t);if("DEVICE_SRP_AUTH"!==n.ChallengeName){if(o.signInUserSession=o.getCognitoUserSession(n.AuthenticationResult),o.cacheTokens(),null==n.AuthenticationResult.NewDeviceMetadata)return e.onSuccess(o.signInUserSession);var i=new a.a(o.pool.getUserPoolName());i.generateHashDevice(n.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,n.AuthenticationResult.NewDeviceMetadata.DeviceKey,function(t){if(t)return e.onFailure(t);var s={Salt:r.Buffer.from(i.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:r.Buffer.from(i.getVerifierDevices(),"hex").toString("base64")};o.verifierDevices=s.PasswordVerifier,o.deviceGroupKey=n.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,o.randomPassword=i.getRandomPassword(),o.client.request("ConfirmDevice",{DeviceKey:n.AuthenticationResult.NewDeviceMetadata.DeviceKey,AccessToken:o.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:s,DeviceName:p},function(t,r){return t?e.onFailure(t):(o.deviceKey=n.AuthenticationResult.NewDeviceMetadata.DeviceKey,o.cacheDeviceKeyAndPassword(),!0===r.UserConfirmationNecessary?e.onSuccess(o.signInUserSession,r.UserConfirmationNecessary):e.onSuccess(o.signInUserSession))})})}else o.getDeviceResponse(e)})},e.changePassword=function(t,e,n,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n(new Error("User is not authenticated"),null);this.client.request("ChangePassword",{PreviousPassword:t,ProposedPassword:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:r},function(t){return t?n(t,null):n(null,"SUCCESS")})},e.enableMFA=function(t){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);var e=[];e.push({DeliveryMedium:"SMS",AttributeName:"phone_number"}),this.client.request("SetUserSettings",{MFAOptions:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(e){return e?t(e,null):t(null,"SUCCESS")})},e.setUserMfaPreference=function(t,e,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n(new Error("User is not authenticated"),null);this.client.request("SetUserMFAPreference",{SMSMfaSettings:t,SoftwareTokenMfaSettings:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(t){return t?n(t,null):n(null,"SUCCESS")})},e.disableMFA=function(t){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("SetUserSettings",{MFAOptions:[],AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(e){return e?t(e,null):t(null,"SUCCESS")})},e.deleteUser=function(t,e){var n=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("DeleteUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:e},function(e){return e?t(e,null):(n.clearCachedUser(),t(null,"SUCCESS"))})},e.updateAttributes=function(t,e,n){var r=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("UpdateUserAttributes",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserAttributes:t,ClientMetadata:n},function(t,n){return t?e(t,null):r.getUserData(function(){return e(null,"SUCCESS",n)},{bypassCache:!0})})},e.getUserAttributes=function(t){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(e,n){if(e)return t(e,null);for(var r=[],i=0;i<n.UserAttributes.length;i++){var o={Name:n.UserAttributes[i].Name,Value:n.UserAttributes[i].Value},s=new d.a(o);r.push(s)}return t(null,r)})},e.getMFAOptions=function(t){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(e,n){return e?t(e,null):t(null,n.MFAOptions)})},e.createGetUserRequest=function(){return this.client.promisifyRequest("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()})},e.refreshSessionIfPossible=function(t){var e=this;return void 0===t&&(t={}),new Promise(function(n){var r=e.signInUserSession.getRefreshToken();r&&r.getToken()?e.refreshSession(r,n,t.clientMetadata):n()})},e.getUserData=function(t,e){var n=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return this.clearCachedUserData(),t(new Error("User is not authenticated"),null);var r=this.getUserDataFromCache();if(r)if(this.isFetchUserDataAndTokenRequired(e))this.fetchUserData().then(function(t){return n.refreshSessionIfPossible(e).then(function(){return t})}).then(function(e){return t(null,e)}).catch(t);else try{return void t(null,JSON.parse(r))}catch(e){return this.clearCachedUserData(),void t(e,null)}else this.fetchUserData().then(function(e){t(null,e)}).catch(t)},e.getUserDataFromCache=function(){return this.storage.getItem(this.userDataKey)},e.isFetchUserDataAndTokenRequired=function(t){var e=(t||{}).bypassCache;return void 0!==e&&e},e.fetchUserData=function(){var t=this;return this.createGetUserRequest().then(function(e){return t.cacheUserData(e),e})},e.deleteAttributes=function(t,e){var n=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("DeleteUserAttributes",{UserAttributeNames:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(t){return t?e(t,null):n.getUserData(function(){return e(null,"SUCCESS")},{bypassCache:!0})})},e.resendConfirmationCode=function(t,e){var n={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:e};this.client.request("ResendConfirmationCode",n,function(e,n){return e?t(e,null):t(null,n)})},e.getSession=function(t,e){if(void 0===e&&(e={}),null==this.username)return t(new Error("Username is null. Cannot retrieve a new session"),null);if(null!=this.signInUserSession&&this.signInUserSession.isValid())return t(null,this.signInUserSession);var n="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,r=n+".idToken",i=n+".accessToken",o=n+".refreshToken",s=n+".clockDrift";if(this.storage.getItem(r)){var a=new c.a({IdToken:this.storage.getItem(r)}),l=new u.a({AccessToken:this.storage.getItem(i)}),d=new f.a({RefreshToken:this.storage.getItem(o)}),g={IdToken:a,AccessToken:l,RefreshToken:d,ClockDrift:parseInt(this.storage.getItem(s),0)||0},p=new h.a(g);if(p.isValid())return this.signInUserSession=p,t(null,this.signInUserSession);if(!d.getToken())return t(new Error("Cannot retrieve a new session. Please authenticate."),null);this.refreshSession(d,t,e.clientMetadata)}else t(new Error("Local storage is missing an ID Token, Please authenticate"),null)},e.refreshSession=function(t,e,n){var r=this,i=this.pool.wrapRefreshSessionCallback?this.pool.wrapRefreshSessionCallback(e):e,o={};o.REFRESH_TOKEN=t.getToken();var s="CognitoIdentityServiceProvider."+this.pool.getClientId(),a=s+".LastAuthUser";if(this.storage.getItem(a)){this.username=this.storage.getItem(a);var u=s+"."+this.username+".deviceKey";this.deviceKey=this.storage.getItem(u),o.DEVICE_KEY=this.deviceKey}var c={ClientId:this.pool.getClientId(),AuthFlow:"REFRESH_TOKEN_AUTH",AuthParameters:o,ClientMetadata:n};this.getUserContextData()&&(c.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",c,function(e,n){if(e)return"NotAuthorizedException"===e.code&&r.clearCachedUser(),i(e,null);if(n){var o=n.AuthenticationResult;return Object.prototype.hasOwnProperty.call(o,"RefreshToken")||(o.RefreshToken=t.getToken()),r.signInUserSession=r.getCognitoUserSession(o),r.cacheTokens(),i(null,r.signInUserSession)}})},e.cacheTokens=function(){var t="CognitoIdentityServiceProvider."+this.pool.getClientId(),e=t+"."+this.username+".idToken",n=t+"."+this.username+".accessToken",r=t+"."+this.username+".refreshToken",i=t+"."+this.username+".clockDrift",o=t+".LastAuthUser";this.storage.setItem(e,this.signInUserSession.getIdToken().getJwtToken()),this.storage.setItem(n,this.signInUserSession.getAccessToken().getJwtToken()),this.storage.setItem(r,this.signInUserSession.getRefreshToken().getToken()),this.storage.setItem(i,""+this.signInUserSession.getClockDrift()),this.storage.setItem(o,this.username)},e.cacheUserData=function(t){this.storage.setItem(this.userDataKey,JSON.stringify(t))},e.clearCachedUserData=function(){this.storage.removeItem(this.userDataKey)},e.clearCachedUser=function(){this.clearCachedTokens(),this.clearCachedUserData()},e.cacheDeviceKeyAndPassword=function(){var t="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,e=t+".deviceKey",n=t+".randomPasswordKey",r=t+".deviceGroupKey";this.storage.setItem(e,this.deviceKey),this.storage.setItem(n,this.randomPassword),this.storage.setItem(r,this.deviceGroupKey)},e.getCachedDeviceKeyAndPassword=function(){var t="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,e=t+".deviceKey",n=t+".randomPasswordKey",r=t+".deviceGroupKey";this.storage.getItem(e)&&(this.deviceKey=this.storage.getItem(e),this.randomPassword=this.storage.getItem(n),this.deviceGroupKey=this.storage.getItem(r))},e.clearCachedDeviceKeyAndPassword=function(){var t="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,e=t+".deviceKey",n=t+".randomPasswordKey",r=t+".deviceGroupKey";this.storage.removeItem(e),this.storage.removeItem(n),this.storage.removeItem(r)},e.clearCachedTokens=function(){var t="CognitoIdentityServiceProvider."+this.pool.getClientId(),e=t+"."+this.username+".idToken",n=t+"."+this.username+".accessToken",r=t+"."+this.username+".refreshToken",i=t+".LastAuthUser",o=t+"."+this.username+".clockDrift";this.storage.removeItem(e),this.storage.removeItem(n),this.storage.removeItem(r),this.storage.removeItem(i),this.storage.removeItem(o)},e.getCognitoUserSession=function(t){var e={IdToken:new c.a(t),AccessToken:new u.a(t),RefreshToken:new f.a(t)};return new h.a(e)},e.forgotPassword=function(t,e){var n={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:e};this.getUserContextData()&&(n.UserContextData=this.getUserContextData()),this.client.request("ForgotPassword",n,function(e,n){return e?t.onFailure(e):"function"==typeof t.inputVerificationCode?t.inputVerificationCode(n):t.onSuccess(n)})},e.confirmPassword=function(t,e,n,r){var i={ClientId:this.pool.getClientId(),Username:this.username,ConfirmationCode:t,Password:e,ClientMetadata:r};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmForgotPassword",i,function(t){return t?n.onFailure(t):n.onSuccess("SUCCESS")})},e.getAttributeVerificationCode=function(t,e,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GetUserAttributeVerificationCode",{AttributeName:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:n},function(t,n){return t?e.onFailure(t):"function"==typeof e.inputVerificationCode?e.inputVerificationCode(n):e.onSuccess("SUCCESS")})},e.verifyAttribute=function(t,e,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n.onFailure(new Error("User is not authenticated"));this.client.request("VerifyUserAttribute",{AttributeName:t,Code:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(t){return t?n.onFailure(t):n.onSuccess("SUCCESS")})},e.getDevice=function(t){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("GetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey},function(e,n){return e?t.onFailure(e):t.onSuccess(n)})},e.forgetSpecificDevice=function(t,e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("ForgetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:t},function(t){return t?e.onFailure(t):e.onSuccess("SUCCESS")})},e.forgetDevice=function(t){var e=this;this.forgetSpecificDevice(this.deviceKey,{onFailure:t.onFailure,onSuccess:function(n){return e.deviceKey=null,e.deviceGroupKey=null,e.randomPassword=null,e.clearCachedDeviceKeyAndPassword(),t.onSuccess(n)}})},e.setDeviceStatusRemembered=function(t){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"remembered"},function(e){return e?t.onFailure(e):t.onSuccess("SUCCESS")})},e.setDeviceStatusNotRemembered=function(t){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"not_remembered"},function(e){return e?t.onFailure(e):t.onSuccess("SUCCESS")})},e.listDevices=function(t,e,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n.onFailure(new Error("User is not authenticated"));var r={AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),Limit:t};e&&(r.PaginationToken=e),this.client.request("ListDevices",r,function(t,e){return t?n.onFailure(t):n.onSuccess(e)})},e.globalSignOut=function(t){var e=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("GlobalSignOut",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(n){return n?t.onFailure(n):(e.clearCachedUser(),t.onSuccess("SUCCESS"))})},e.signOut=function(t){var e=this;t&&"function"==typeof t?this.getSession(function(n,r){if(n)return t(n);e.revokeTokens(function(n){e.cleanClientData(),t(n)})}):this.cleanClientData()},e.revokeTokens=function(t){if(void 0===t&&(t=function(){}),"function"!=typeof t)throw new Error("Invalid revokeTokenCallback. It should be a function.");if(!this.signInUserSession)return t(new Error("User is not authenticated"));if(!this.signInUserSession.getAccessToken())return t(new Error("No Access token available"));var e=this.signInUserSession.getRefreshToken().getToken(),n=this.signInUserSession.getAccessToken();if(this.isSessionRevocable(n)&&e)return this.revokeToken({token:e,callback:t});t()},e.isSessionRevocable=function(t){if(t&&"function"==typeof t.decodePayload)try{return!!t.decodePayload().origin_jti}catch(t){}return!1},e.cleanClientData=function(){this.signInUserSession=null,this.clearCachedUser()},e.revokeToken=function(t){var e=t.token,n=t.callback;this.client.requestWithRetry("RevokeToken",{Token:e,ClientId:this.pool.getClientId()},function(t){if(t)return n(t);n()})},e.sendMFASelectionAnswer=function(t,e){var n=this,r={};r.USERNAME=this.username,r.ANSWER=t;var i={ChallengeName:"SELECT_MFA_TYPE",ChallengeResponses:r,ClientId:this.pool.getClientId(),Session:this.Session};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",i,function(r,i){return r?e.onFailure(r):(n.Session=i.Session,"SMS_MFA"===t?e.mfaRequired(i.ChallengeName,i.ChallengeParameters):"SOFTWARE_TOKEN_MFA"===t?e.totpRequired(i.ChallengeName,i.ChallengeParameters):void 0)})},e.getUserContextData=function(){return this.pool.getUserContextData(this.username)},e.associateSoftwareToken=function(t){var e=this;null!=this.signInUserSession&&this.signInUserSession.isValid()?this.client.request("AssociateSoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(e,n){return e?t.onFailure(e):t.associateSecretCode(n.SecretCode)}):this.client.request("AssociateSoftwareToken",{Session:this.Session},function(n,r){return n?t.onFailure(n):(e.Session=r.Session,t.associateSecretCode(r.SecretCode))})},e.verifySoftwareToken=function(t,e,n){var r=this;null!=this.signInUserSession&&this.signInUserSession.isValid()?this.client.request("VerifySoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserCode:t,FriendlyDeviceName:e},function(t,e){return t?n.onFailure(t):n.onSuccess(e)}):this.client.request("VerifySoftwareToken",{Session:this.Session,UserCode:t,FriendlyDeviceName:e},function(t,e){if(t)return n.onFailure(t);r.Session=e.Session;var i={};i.USERNAME=r.username;var o={ChallengeName:"MFA_SETUP",ClientId:r.pool.getClientId(),ChallengeResponses:i,Session:r.Session};r.getUserContextData()&&(o.UserContextData=r.getUserContextData()),r.client.request("RespondToAuthChallenge",o,function(t,e){return t?n.onFailure(t):(r.signInUserSession=r.getCognitoUserSession(e.AuthenticationResult),r.cacheTokens(),n.onSuccess(r.signInUserSession))})})},t}()},function(t,e,n){"use strict";n.d(e,"a",function(){return i}),n.d(e,"b",function(){return o});var r="aws-amplify/"+n(37).a,i={userAgent:r+" js",product:"",navigator:null,isReactNative:!1};
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/if("undefined"!=typeof navigator&&navigator.product)switch(i.product=navigator.product||"",i.navigator=navigator||null,navigator.product){case"ReactNative":i.userAgent=r+" react-native",i.isReactNative=!0;break;default:i.userAgent=r+" js",i.isReactNative=!1}var o=function(){return i.userAgent}},function(t,e,n){"use strict";n.d(e,"a",function(){return r});
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
var r=function(){function t(t){var e=void 0===t?{}:t,n=e.IdToken,r=e.RefreshToken,i=e.AccessToken,o=e.ClockDrift;if(null==i||null==n)throw new Error("Id token and Access Token must be present.");this.idToken=n,this.refreshToken=r,this.accessToken=i,this.clockDrift=void 0===o?this.calculateClockDrift():o}var e=t.prototype;return e.getIdToken=function(){return this.idToken},e.getRefreshToken=function(){return this.refreshToken},e.getAccessToken=function(){return this.accessToken},e.getClockDrift=function(){return this.clockDrift},e.calculateClockDrift=function(){return Math.floor(new Date/1e3)-Math.min(this.accessToken.getIssuedAt(),this.idToken.getIssuedAt())},e.isValid=function(){var t=Math.floor(new Date/1e3)-this.clockDrift;return t<this.accessToken.getExpiration()&&t<this.idToken.getExpiration()},t}()},function(t,e,n){"use strict";n.d(e,"a",function(){return o});
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
var r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o=function(){function t(){}return t.prototype.getNowString=function(){var t=new Date,e=i[t.getUTCDay()],n=r[t.getUTCMonth()],o=t.getUTCDate(),s=t.getUTCHours();s<10&&(s="0"+s);var a=t.getUTCMinutes();a<10&&(a="0"+a);var u=t.getUTCSeconds();return u<10&&(u="0"+u),e+" "+n+" "+o+" "+s+":"+a+":"+u+" UTC "+t.getUTCFullYear()},t}()},function(t,e,n){"use strict";n.d(e,"a",function(){return r});
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
var r=function(){function t(t){var e=void 0===t?{}:t,n=e.Name,r=e.Value;this.Name=n||"",this.Value=r||""}var e=t.prototype;return e.getValue=function(){return this.Value},e.setValue=function(t){return this.Value=t,this},e.getName=function(){return this.Name},e.setName=function(t){return this.Name=t,this},e.toString=function(){return JSON.stringify(this)},e.toJSON=function(){return{Name:this.Name,Value:this.Value}},t}()},function(t,e,n){"use strict";n.d(e,"a",function(){return o});
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
var r={},i=function(){function t(){}return t.setItem=function(t,e){return r[t]=e,r[t]},t.getItem=function(t){return Object.prototype.hasOwnProperty.call(r,t)?r[t]:void 0},t.removeItem=function(t){return delete r[t]},t.clear=function(){return r={}},t}(),o=function(){function t(){try{this.storageWindow=window.localStorage,this.storageWindow.setItem("aws.cognito.test-ls",1),this.storageWindow.removeItem("aws.cognito.test-ls")}catch(t){this.storageWindow=i}}return t.prototype.getStorage=function(){return this.storageWindow},t}()},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){return e=e||{},new Promise(function(n,r){var i=new XMLHttpRequest,o=[],s=[],a={},u=function(){return{ok:2==(i.status/100|0),statusText:i.statusText,status:i.status,url:i.responseURL,text:function(){return Promise.resolve(i.responseText)},json:function(){return Promise.resolve(i.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([i.response]))},clone:u,headers:{keys:function(){return o},entries:function(){return s},get:function(t){return a[t.toLowerCase()]},has:function(t){return t.toLowerCase()in a}}}};for(var c in i.open(e.method||"get",t,!0),i.onload=function(){i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(t,e,n){o.push(e=e.toLowerCase()),s.push([e,n]),a[e]=a[e]?a[e]+","+n:n}),n(u())},i.onerror=r,i.withCredentials="include"==e.credentials,e.headers)i.setRequestHeader(c,e.headers[c]);i.send(e.body||null)})}},function(t,e,n){"use strict";n.d(e,"a",function(){return o});var r=n(13);function i(){}i.prototype.userAgent=Object(r.b)();var o=function(t){t&&(i.prototype.userAgent&&!i.prototype.userAgent.includes(t)&&(i.prototype.userAgent=i.prototype.userAgent.concat(" ",t)),i.prototype.userAgent&&""!==i.prototype.userAgent||(i.prototype.userAgent=t))};e.b=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(21);n.d(e,"AuthenticationDetails",function(){return r.a});var i=n(1);n.d(e,"AuthenticationHelper",function(){return i.a});var o=n(8);n.d(e,"CognitoAccessToken",function(){return o.a});var s=n(10);n.d(e,"CognitoIdToken",function(){return s.a});var a=n(11);n.d(e,"CognitoRefreshToken",function(){return a.a});var u=n(12);n.d(e,"CognitoUser",function(){return u.a});var c=n(16);n.d(e,"CognitoUserAttribute",function(){return c.a});var f=n(38);n.d(e,"CognitoUserPool",function(){return f.a});var h=n(14);n.d(e,"CognitoUserSession",function(){return h.a});var l=n(41);n.d(e,"CookieStorage",function(){return l.a});var d=n(15);n.d(e,"DateHelper",function(){return d.a});var g=n(19);n.d(e,"appendToCognitoUserAgent",function(){return g.a});var p=n(3);n.d(e,"WordArray",function(){return p.a})},function(t,e,n){"use strict";n.d(e,"a",function(){return r});
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
var r=function(){function t(t){var e=t||{},n=e.ValidationData,r=e.Username,i=e.Password,o=e.AuthParameters,s=e.ClientMetadata;this.validationData=n||{},this.authParameters=o||{},this.clientMetadata=s||{},this.username=r,this.password=i}var e=t.prototype;return e.getUsername=function(){return this.username},e.getPassword=function(){return this.password},e.getValidationData=function(){return this.validationData},e.getAuthParameters=function(){return this.authParameters},e.getClientMetadata=function(){return this.clientMetadata},t}()},function(t,e,n){"use strict";e.byteLength=function(t){var e=c(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,r=c(t),s=r[0],a=r[1],u=new o(function(t,e,n){return 3*(e+n)/4-n}(0,s,a)),f=0,h=a>0?s-4:s;for(n=0;n<h;n+=4)e=i[t.charCodeAt(n)]<<18|i[t.charCodeAt(n+1)]<<12|i[t.charCodeAt(n+2)]<<6|i[t.charCodeAt(n+3)],u[f++]=e>>16&255,u[f++]=e>>8&255,u[f++]=255&e;2===a&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,u[f++]=255&e);1===a&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,u[f++]=e>>8&255,u[f++]=255&e);return u},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=0,a=n-i;s<a;s+=16383)o.push(h(t,s,s+16383>a?a:s+16383));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)r[a]=s[a],i[s.charCodeAt(a)]=a;function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function f(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function h(t,e,n){for(var r,i=[],o=e;o<n;o+=3)r=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(f(r));return i.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
e.read=function(t,e,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,c=u>>1,f=-7,h=n?i-1:0,l=n?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=c}return(d?-1:1)*s*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var s,a,u,c=8*o-i-1,f=(1<<c)-1,h=f>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,g=r?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[n+d]=255&a,d+=g,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;t[n+d]=255&s,d+=g,s/=256,c-=8);t[n+d-g]|=128*p}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){"use strict";(function(t){var r;if(e.a=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},"undefined"!=typeof window&&window.crypto&&(r=window.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&void 0!==t&&t.crypto&&(r=t.crypto),!r)try{r=n(26)}catch(t){}}).call(e,n(2))},function(e,n){if(void 0===t){var r=new Error('Cannot find module "crypto"');throw r.code="MODULE_NOT_FOUND",r}e.exports=t},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Sha256=void 0;var r=n(5),i=n(6),o=n(28),s=n(29),a=function(){function t(t){if(this.hash=new o.RawSha256,t){this.outer=new o.RawSha256;var e=function(t){var e=(0,s.convertToBuffer)(t);if(e.byteLength>i.BLOCK_SIZE){var n=new o.RawSha256;n.update(e),e=n.digest()}var r=new Uint8Array(i.BLOCK_SIZE);return r.set(e),r}(t),n=new Uint8Array(i.BLOCK_SIZE);n.set(e);for(var r=0;r<i.BLOCK_SIZE;r++)e[r]^=54,n[r]^=92;this.hash.update(e),this.outer.update(n);for(r=0;r<e.byteLength;r++)e[r]=0}}return t.prototype.update=function(t){if(!(0,s.isEmptyData)(t)&&!this.error)try{this.hash.update((0,s.convertToBuffer)(t))}catch(t){this.error=t}},t.prototype.digestSync=function(){if(this.error)throw this.error;return this.outer?(this.outer.finished||this.outer.update(this.hash.digest()),this.outer.digest()):this.hash.digest()},t.prototype.digest=function(){return(0,r.__awaiter)(this,void 0,void 0,function(){return(0,r.__generator)(this,function(t){return[2,this.digestSync()]})})},t}();e.Sha256=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RawSha256=void 0;var r=n(6),i=function(){function t(){this.state=Int32Array.from(r.INIT),this.temp=new Int32Array(64),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}return t.prototype.update=function(t){if(this.finished)throw new Error("Attempted to update an already finished hash.");var e=0,n=t.byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>r.MAX_HASHABLE_LENGTH)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;n>0;)this.buffer[this.bufferLength++]=t[e++],n--,this.bufferLength===r.BLOCK_SIZE&&(this.hashBuffer(),this.bufferLength=0)},t.prototype.digest=function(){if(!this.finished){var t=8*this.bytesHashed,e=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),n=this.bufferLength;if(e.setUint8(this.bufferLength++,128),n%r.BLOCK_SIZE>=r.BLOCK_SIZE-8){for(var i=this.bufferLength;i<r.BLOCK_SIZE;i++)e.setUint8(i,0);this.hashBuffer(),this.bufferLength=0}for(i=this.bufferLength;i<r.BLOCK_SIZE-8;i++)e.setUint8(i,0);e.setUint32(r.BLOCK_SIZE-8,Math.floor(t/4294967296),!0),e.setUint32(r.BLOCK_SIZE-4,t),this.hashBuffer(),this.finished=!0}var o=new Uint8Array(r.DIGEST_LENGTH);for(i=0;i<8;i++)o[4*i]=this.state[i]>>>24&255,o[4*i+1]=this.state[i]>>>16&255,o[4*i+2]=this.state[i]>>>8&255,o[4*i+3]=this.state[i]>>>0&255;return o},t.prototype.hashBuffer=function(){for(var t=this.buffer,e=this.state,n=e[0],i=e[1],o=e[2],s=e[3],a=e[4],u=e[5],c=e[6],f=e[7],h=0;h<r.BLOCK_SIZE;h++){if(h<16)this.temp[h]=(255&t[4*h])<<24|(255&t[4*h+1])<<16|(255&t[4*h+2])<<8|255&t[4*h+3];else{var l=this.temp[h-2],d=(l>>>17|l<<15)^(l>>>19|l<<13)^l>>>10,g=((l=this.temp[h-15])>>>7|l<<25)^(l>>>18|l<<14)^l>>>3;this.temp[h]=(d+this.temp[h-7]|0)+(g+this.temp[h-16]|0)}var p=(((a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7))+(a&u^~a&c)|0)+(f+(r.KEY[h]+this.temp[h]|0)|0)|0,v=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&i^n&o^i&o)|0;f=c,c=u,u=a,a=s+p|0,s=o,o=i,i=n,n=p+v|0}e[0]+=n,e[1]+=i,e[2]+=o,e[3]+=s,e[4]+=a,e[5]+=u,e[6]+=c,e[7]+=f},t}();e.RawSha256=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.uint32ArrayFrom=e.numToUint8=e.isEmptyData=e.convertToBuffer=void 0;var r=n(30);Object.defineProperty(e,"convertToBuffer",{enumerable:!0,get:function(){return r.convertToBuffer}});var i=n(34);Object.defineProperty(e,"isEmptyData",{enumerable:!0,get:function(){return i.isEmptyData}});var o=n(35);Object.defineProperty(e,"numToUint8",{enumerable:!0,get:function(){return o.numToUint8}});var s=n(36);Object.defineProperty(e,"uint32ArrayFrom",{enumerable:!0,get:function(){return s.uint32ArrayFrom}})},function(t,e,n){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.convertToBuffer=void 0;var r=n(31),i=void 0!==t&&t.from?function(e){return t.from(e,"utf8")}:r.fromUtf8;e.convertToBuffer=function(t){return t instanceof Uint8Array?t:"string"==typeof t?i(t):ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(t)}}).call(e,n(0).Buffer)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(32),i=n(33);e.fromUtf8=(t=>"function"==typeof TextEncoder?Object(i.a)(t):Object(r.a)(t));e.toUtf8=(t=>"function"==typeof TextDecoder?Object(i.b)(t):Object(r.b)(t))},function(t,e,n){"use strict";e.a=(t=>{const e=[];for(let n=0,r=t.length;n<r;n++){const r=t.charCodeAt(n);if(r<128)e.push(r);else if(r<2048)e.push(r>>6|192,63&r|128);else if(n+1<t.length&&55296==(64512&r)&&56320==(64512&t.charCodeAt(n+1))){const i=65536+((1023&r)<<10)+(1023&t.charCodeAt(++n));e.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}else e.push(r>>12|224,r>>6&63|128,63&r|128)}return Uint8Array.from(e)});e.b=(t=>{let e="";for(let n=0,r=t.length;n<r;n++){const r=t[n];if(r<128)e+=String.fromCharCode(r);else if(192<=r&&r<224){const i=t[++n];e+=String.fromCharCode((31&r)<<6|63&i)}else if(240<=r&&r<365){const i="%"+[r,t[++n],t[++n],t[++n]].map(t=>t.toString(16)).join("%");e+=decodeURIComponent(i)}else e+=String.fromCharCode((15&r)<<12|(63&t[++n])<<6|63&t[++n])}return e})},function(t,e,n){"use strict";e.a=function(t){return(new TextEncoder).encode(t)},e.b=function(t){return new TextDecoder("utf-8").decode(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isEmptyData=void 0,e.isEmptyData=function(t){return"string"==typeof t?0===t.length:0===t.byteLength}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.numToUint8=void 0,e.numToUint8=function(t){return new Uint8Array([(4278190080&t)>>24,(16711680&t)>>16,(65280&t)>>8,255&t])}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.uint32ArrayFrom=void 0,e.uint32ArrayFrom=function(t){if(!Array.from){for(var e=new Uint32Array(t.length);0<t.length;)e[0]=t[0];return e}return Uint32Array.from(t)}},function(t,e,n){"use strict";n.d(e,"a",function(){return r});var r="5.0.4"},function(t,e,n){"use strict";n.d(e,"a",function(){return a});var r=n(39),i=n(12),o=n(17),s=55,a=function(){function t(t,e){var n=t||{},i=n.UserPoolId,a=n.ClientId,u=n.endpoint,c=n.fetchOptions,f=n.AdvancedSecurityDataCollectionFlag;if(!i||!a)throw new Error("Both UserPoolId and ClientId are required.");if(i.length>s||!/^[\w-]+_[0-9a-zA-Z]+$/.test(i))throw new Error("Invalid UserPoolId format.");var h=i.split("_")[0];this.userPoolId=i,this.clientId=a,this.client=new r.a(h,u,c),this.advancedSecurityDataCollectionFlag=!1!==f,this.storage=t.Storage||(new o.a).getStorage(),e&&(this.wrapRefreshSessionCallback=e)}var e=t.prototype;return e.getUserPoolId=function(){return this.userPoolId},e.getUserPoolName=function(){return this.getUserPoolId().split("_")[1]},e.getClientId=function(){return this.clientId},e.signUp=function(t,e,n,r,o,s){var a=this,u={ClientId:this.clientId,Username:t,Password:e,UserAttributes:n,ValidationData:r,ClientMetadata:s};this.getUserContextData(t)&&(u.UserContextData=this.getUserContextData(t)),this.client.request("SignUp",u,function(e,n){if(e)return o(e,null);var r={Username:t,Pool:a,Storage:a.storage},s={user:new i.a(r),userConfirmed:n.UserConfirmed,userSub:n.UserSub,codeDeliveryDetails:n.CodeDeliveryDetails};return o(null,s)})},e.getCurrentUser=function(){var t="CognitoIdentityServiceProvider."+this.clientId+".LastAuthUser",e=this.storage.getItem(t);if(e){var n={Username:e,Pool:this,Storage:this.storage};return new i.a(n)}return null},e.getUserContextData=function(t){if("undefined"!=typeof AmazonCognitoAdvancedSecurityData){var e=AmazonCognitoAdvancedSecurityData;if(this.advancedSecurityDataCollectionFlag){var n=e.getData(t,this.userPoolId,this.clientId);if(n)return{EncodedData:n}}return{}}},t}()},function(t,e,n){"use strict";n.d(e,"a",function(){return h});var r=n(40),i=(n.n(r),n(19));function o(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,u(t,e)}function s(t){var e="function"==typeof Map?new Map:void 0;return(s=function(t){if(null===t||!function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return a(t,arguments,c(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,t)})(t)}function a(t,e,n){return(a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&u(i,n.prototype),i}).apply(null,arguments)}function u(t,e){return(u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function c(t){return(c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var f=function(t){function e(e,n,r,i){var o;return(o=t.call(this,e)||this).code=n,o.name=r,o.statusCode=i,o}return o(e,t),e}(s(Error)),h=function(){function t(t,e,n){this.endpoint=e||"https://cognito-idp."+t+".amazonaws.com/";var r=(n||{}).credentials;this.fetchOptions=r?{credentials:r}:{}}var e=t.prototype;return e.promisifyRequest=function(t,e){var n=this;return new Promise(function(r,i){n.request(t,e,function(t,e){t?i(new f(t.message,t.code,t.name,t.statusCode)):r(e)})})},e.requestWithRetry=function(t,e,n){var r=this;(function(t,e,n){void 0===n&&(n=g);return function t(e,n,r,i){void 0===i&&(i=1);if("function"!=typeof e)throw Error("functionToRetry must be a function");l.debug(e.name+" attempt #"+i+" with args: "+JSON.stringify(n));return e.apply(void 0,n).catch(function(o){if(l.debug("error on "+e.name,o),d(o))throw l.debug(e.name+" non retryable error",o),o;var s=r(i,n,o);if(l.debug(e.name+" retrying in "+s+" ms"),!1!==s)return new Promise(function(t){return setTimeout(t,s)}).then(function(){return t(e,n,r,i+1)});throw o})}(t,e,function(t){return function(e){var n=100*Math.pow(2,e)+100*Math.random();return!(n>t)&&n}}(n))})(function(e){return new Promise(function(n,i){r.request(t,e,function(t,e){t?i(t):n(e)})})},[e],5e3).then(function(t){return n(null,t)}).catch(function(t){return n(t)})},e.request=function(t,e,n){var r,o={"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityProviderService."+t,"X-Amz-User-Agent":i.b.prototype.userAgent,"Cache-Control":"no-store"},s=Object.assign({},this.fetchOptions,{headers:o,method:"POST",mode:"cors",body:JSON.stringify(e)});fetch(this.endpoint,s).then(function(t){return r=t,t},function(t){if(t instanceof TypeError)throw new Error("Network error");throw t}).then(function(t){return t.json().catch(function(){return{}})}).then(function(t){if(r.ok)return n(null,t);t;var e=(t.__type||t.code).split("#").pop(),i=new Error(t.message||t.Message||null);return i.name=e,i.code=e,n(i)}).catch(function(t){if(r&&r.headers&&r.headers.get("x-amzn-errortype"))try{var e=r.headers.get("x-amzn-errortype").split(":")[0],i=new Error(r.status?r.status.toString():null);return i.code=e,i.name=e,i.statusCode=r.status,n(i)}catch(e){return n(t)}else t instanceof Error&&"Network error"===t.message&&(t.code="NetworkError");return n(t)})},t}(),l={debug:function(){}},d=(Error,function(t){return t&&t.nonRetryable});var g=3e5},function(t,e,n){t.exports=self.fetch||(self.fetch=n(18).default||n(18))},function(t,e,n){"use strict";n.d(e,"a",function(){return i});var r=n(42),i=(n.n(r),function(){function t(t){if(void 0===t&&(t={}),t.domain&&(this.domain=t.domain),t.path?this.path=t.path:this.path="/",Object.prototype.hasOwnProperty.call(t,"expires")?this.expires=t.expires:this.expires=365,Object.prototype.hasOwnProperty.call(t,"secure")?this.secure=t.secure:this.secure=!0,Object.prototype.hasOwnProperty.call(t,"sameSite")){if(!["strict","lax","none"].includes(t.sameSite))throw new Error('The sameSite value of cookieStorage must be "lax", "strict" or "none".');if("none"===t.sameSite&&!this.secure)throw new Error("sameSite = None requires the Secure attribute in latest browser versions.");this.sameSite=t.sameSite}else this.sameSite=null}var e=t.prototype;return e.setItem=function(t,e){var n={path:this.path,expires:this.expires,domain:this.domain,secure:this.secure};return this.sameSite&&(n.sameSite=this.sameSite),r.set(t,e,n),r.get(t)},e.getItem=function(t){return r.get(t)},e.removeItem=function(t){var e={path:this.path,expires:this.expires,domain:this.domain,secure:this.secure};return this.sameSite&&(e.sameSite=this.sameSite),r.remove(t,e)},e.clear=function(){for(var t=r.get(),e=Object.keys(t).length,n=0;n<e;++n)this.removeItem(Object.keys(t)[n]);return{}},t}())},function(t,e,n){var r,i;
/*!
* JavaScript Cookie v2.2.1
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/!function(o){if(void 0===(i="function"==typeof(r=o)?r.call(e,n,e,t):r)||(t.exports=i),!0,t.exports=o(),!!0){var s=window.Cookies,a=window.Cookies=o();a.noConflict=function(){return window.Cookies=s,a}}}(function(){function t(){for(var t=0,e={};t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}function e(t){return t.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function n(r){function i(){}function o(e,n,o){if("undefined"!=typeof document){"number"==typeof(o=t({path:"/"},i.defaults,o)).expires&&(o.expires=new Date(1*new Date+864e5*o.expires)),o.expires=o.expires?o.expires.toUTCString():"";try{var s=JSON.stringify(n);/^[\{\[]/.test(s)&&(n=s)}catch(t){}n=r.write?r.write(n,e):encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),e=encodeURIComponent(String(e)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var a="";for(var u in o)o[u]&&(a+="; "+u,!0!==o[u]&&(a+="="+o[u].split(";")[0]));return document.cookie=e+"="+n+a}}function s(t,n){if("undefined"!=typeof document){for(var i={},o=document.cookie?document.cookie.split("; "):[],s=0;s<o.length;s++){var a=o[s].split("="),u=a.slice(1).join("=");n||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var c=e(a[0]);if(u=(r.read||r)(u,c)||e(u),n)try{u=JSON.parse(u)}catch(t){}if(i[c]=u,t===c)break}catch(t){}}return t?i[t]:i}}return i.set=o,i.get=function(t){return s(t,!1)},i.getJSON=function(t){return s(t,!0)},i.remove=function(e,n){o(e,"",t(n,{expires:-1}))},i.defaults={},i.withConverter=n,i}(function(){})})}])});
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"PUT",
"POST",
"DELETE"
],
"AllowedOrigins": [
"http://localhost:8000"
],
"ExposeHeaders": []
}
]
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"mobileanalytics:PutEvents",
"cognito-sync:*",
"cognito-identity:*"
],
"Resource": [
"*"
]
},
{
"Sid": "S3PutObjectAccess",
"Effect": "Allow",
"Action": [
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::mybucket-2023a/*"
]
}
]
}
<!DOCTYPE html>
<html>
<head>
<title>Upload to S3 (with login)</title>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.966.0.min.js"></script>
<script src="amazon-cognito-identity.min.js"></script>
</head>
<body>
<div>
<label for="username">Username:</label>
<input type="text" id="username">
</div>
<div>
<label for="password">Password:</label>
<input type="password" id="password">
</div>
<button onclick="login()">Login</button>
<br><br>
<input type="file" id="file" accept=".txt">
<button onclick="upload()">Upload</button>
<br><br>
<p id="message"></p>
<script>
// Set the region and credentials for AWS SDK
AWS.config.region = 'us-east-1';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-east-1:44c00ea8-12b2-481a-b1a3-a007fd128ff3',
});
function login() {
var username = document.getElementById('username').value;
var password = document.getElementById('password').value;
var authenticationData = {
Username: username,
Password: password,
};
var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails(authenticationData);
var poolData = {
UserPoolId: 'us-east-1_4fcHu8bzl',
ClientId: '1dm91qgjlgmoab2sjgs3h9th5v',
};
var userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
var userData = {
Username: username,
Pool: userPool,
Storage: window.localStorage,
};
var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
var provider = "cognito-idp."+AWS.config.region+".amazonaws.com/"+poolData.UserPoolId;
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
console.log('access token + ' + result.getAccessToken().getJwtToken());
AWS.config.credentials.params.Logins = {};
AWS.config.credentials.params.Logins[provider] = result.getIdToken().getJwtToken();
AWS.config.credentials.refresh(function (err) {
if (err) {
console.log(err);
document.getElementById('message').innerHTML = err;
} else {
console.log('Successfully logged!');
document.getElementById('message').innerHTML = 'Successfully logged in!';
}
});
},
onFailure: function (err) {
console.log(err);
document.getElementById('message').innerHTML = err.message || JSON.stringify(err);
},
});
}
var s3 = new AWS.S3({
apiVersion: '2006-03-01',
params: {
Bucket: 'mybucket-2023a'
}
});
function upload() {
var file = document.getElementById('file').files[0];
var fileName = file.name;
var fileKey = 'uploads/' + fileName;
var params = {
Key: fileKey,
ContentType: file.type,
Body: file,
};
s3.upload(params, function (err, data) {
if (err) {
console.log(err, err.stack);
document.getElementById('message').innerHTML = err;
} else {
console.log('Uploaded successfully!');
document.getElementById('message').innerHTML = 'File uploaded successfully!';
}
});
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Upload File to S3 (no login)</title>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.966.0.min.js"></script>
<script>
AWS.config.update({
region: 'us-east-1',
credentials: new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-east-1:44c00ea8-12b2-481a-b1a3-a007fd128ff3'
})
});
var s3 = new AWS.S3({
apiVersion: '2006-03-01',
params: {Bucket: 'mybucket-2023a'}
});
function uploadFile() {
var file = document.getElementById('fileInput').files[0];
var fileName = file.name;
var fileKey = 'uploads/' + fileName;
s3.upload({
Key: fileKey,
Body: file
}, function(err, data) {
if (err) {
console.log('Error uploading file:', err);
} else {
console.log('File uploaded successfully:', data);
}
});
}
</script>
</head>
<body>
<input type="file" id="fileInput">
<button onclick="uploadFile()">Upload</button>
</body>
</html>
import http.server
import socketserver
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print(f"Serving on port {PORT}")
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment