@agentlang/lstudio 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{AwsJson1_1Protocol-Bs-KOF3u.js → AwsJson1_1Protocol-wsbyAvre.js} +1 -1
- package/assets/_commonjs-dynamic-modules-B7n8ZNar.js +1 -0
- package/assets/index-3_2F9LQx.js +1 -0
- package/assets/{index-2WvsM2Rj.js → index-BHDiPh0o.js} +6 -6
- package/assets/{index-R10cjt6U.js → index-BfWs6B7Z.js} +2 -2
- package/assets/index-Bzac4yPb.js +1 -0
- package/assets/index-CJzDmIha.js +1 -0
- package/assets/{index-CMyUHiQc.js → index-CPpeTRZB.js} +1 -1
- package/assets/{index-D_-sPexk.css → index-CUrde35K.css} +1 -1
- package/assets/{index-D4z_hbl0-BL_vRy6b.js → index-D4z_hbl0-DMpNs09k.js} +2 -2
- package/assets/{index-yIpMibae.js → index-DcfSUfKC.js} +300 -295
- package/assets/index.browser-CSfSj68l.js +6 -0
- package/assets/loadCognitoIdentity-yMbT3vM8.js +1 -0
- package/assets/{loadSts-C2Q5qCT1.js → loadSts-D2KuE3Wg.js} +1 -1
- package/assets/{replService-BOpSWnUZ.js → replService-BCjABThC.js} +1 -1
- package/assets/util-Cb5ErRuM.js +10 -0
- package/assets/{winston-1qzyIKCb-BdlBoF8R.js → winston-1qzyIKCb-CLvI85k0.js} +1 -1
- package/assets/{winston-DDcfL10c.js → winston-CfAk0yN1.js} +2 -2
- package/assets/winston-CtxF18qc-1uz0_uFI.js +1 -0
- package/assets/{winston-C4UOaon2.js → winston-DgHuUfbR.js} +1 -1
- package/index.html +3 -6
- package/package.json +1 -1
- package/assets/_commonjs-dynamic-modules-TDtrdbi3.js +0 -1
- package/assets/index-BLr5FjlG.js +0 -1
- package/assets/index-BOSgoMcw.js +0 -1
- package/assets/index-DVmya6p1.js +0 -1
- package/assets/index-DzJU27LV.js +0 -1
- package/assets/index-rEhqCN8O.js +0 -6
- package/assets/index.browser-BYRWACjF.js +0 -6
- package/assets/inherits_browser-5Fj3Mjxs.js +0 -1
- package/assets/loadCognitoIdentity-BtOy6bnr.js +0 -1
- package/assets/util-qaS8mbUT.js +0 -10
- package/assets/winston-CtxF18qc-Cn1Quo2c.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as h,c as T,S as y,b as u,d as N,L as w,e as b,f as _,v as R,R as z,P as E,h as J,T as M}from"./index-
|
|
1
|
+
import{N as h,c as T,S as y,b as u,d as N,L as w,e as b,f as _,v as R,R as z,P as E,h as J,T as M}from"./index-CPpeTRZB.js";import{t as D,a as I,p as j,b as O,c as A,d as S,e as k}from"./normalizeProvider-EC8cbfMc.js";function B(f,t,e){if(e?.source){const i=e.source;if(typeof t=="number"&&(t>Number.MAX_SAFE_INTEGER||t<Number.MIN_SAFE_INTEGER||i!==String(t)))return i.includes(".")?new h(i,"bigDecimal"):BigInt(i)}return t}const V=(f,t)=>T(f,t).then(e=>(t?.utf8Encoder??D)(e)),Q=(f,t)=>V(f,t).then(e=>{if(e.length)try{return JSON.parse(e)}catch(i){throw i?.name==="SyntaxError"&&Object.defineProperty(i,"$responseBodyText",{value:e}),i}return{}}),$=(f,t)=>{const e=(n,r)=>Object.keys(n).find(o=>o.toLowerCase()===r.toLowerCase()),i=n=>{let r=n;return typeof r=="number"&&(r=r.toString()),r.indexOf(",")>=0&&(r=r.split(",")[0]),r.indexOf(":")>=0&&(r=r.split(":")[0]),r.indexOf("#")>=0&&(r=r.split("#")[1]),r},s=e(f.headers,"x-amzn-errortype");if(s!==void 0)return i(f.headers[s]);if(t&&typeof t=="object"){const n=e(t,"code");if(n&&t[n]!==void 0)return i(t[n]);if(t.__type!==void 0)return i(t.__type)}};class L extends y{settings;constructor(t){super(),this.settings=t}async read(t,e){return this._read(t,typeof e=="string"?JSON.parse(e,B):await Q(e,this.serdeContext))}readObject(t,e){return this._read(t,e)}_read(t,e){const i=e!==null&&typeof e=="object",s=u.of(t);if(i){if(s.isStructSchema()){const r={};for(const[o,c]of N(s,e,this.settings.jsonName?"jsonName":!1)){const a=this.settings.jsonName?c.getMergedTraits().jsonName??o:o,m=this._read(c,e[a]);m!=null&&(r[o]=m)}return r}if(Array.isArray(e)&&s.isListSchema()){const r=s.getValueSchema(),o=[],c=!!s.getMergedTraits().sparse;for(const a of e)(c||a!=null)&&o.push(this._read(r,a));return o}if(s.isMapSchema()){const r=s.getValueSchema(),o={},c=!!s.getMergedTraits().sparse;for(const[a,m]of Object.entries(e))(c||m!=null)&&(o[a]=this._read(r,m));return o}}if(s.isBlobSchema()&&typeof e=="string")return I(e);const n=s.getMergedTraits().mediaType;if(s.isStringSchema()&&typeof e=="string"&&n)return n==="application/json"||n.endsWith("+json")?w.from(e):e;if(s.isTimestampSchema()&&e!=null)switch(b(s,this.settings)){case 5:return A(e);case 6:return O(e);case 7:return j(e);default:return console.warn("Missing timestamp format, parsing value with Date constructor:",e),new Date(e)}if(s.isBigIntegerSchema()&&(typeof e=="number"||typeof e=="string"))return BigInt(e);if(s.isBigDecimalSchema()&&e!=null){if(e instanceof h)return e;const r=e;return r.type==="bigDecimal"&&"string"in r?new h(r.string,r.type):new h(String(e),"bigDecimal")}if(s.isNumericSchema()&&typeof e=="string"){switch(e){case"Infinity":return 1/0;case"-Infinity":return-1/0;case"NaN":return NaN}return e}if(s.isDocumentSchema())if(i){const r=Array.isArray(e)?[]:{};for(const[o,c]of Object.entries(e))c instanceof h?r[o]=c:r[o]=this._read(s,c);return r}else return structuredClone(e);return e}}const l="Ν";class P{values=new Map;counter=0;stage=0;createReplacer(){if(this.stage===1)throw new Error("@aws-sdk/core/protocols - JsonReplacer already created.");if(this.stage===2)throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");return this.stage=1,(t,e)=>{if(e instanceof h){const i=`${l+"nv"+this.counter++}_`+e.string;return this.values.set(`"${i}"`,e.string),i}if(typeof e=="bigint"){const i=e.toString(),s=`${l+"b"+this.counter++}_`+i;return this.values.set(`"${s}"`,i),s}return e}}replaceInJson(t){if(this.stage===0)throw new Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");if(this.stage===2)throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");if(this.stage=2,this.counter===0)return t;for(const[e,i]of this.values)t=t.replace(e,i);return t}}class F extends y{settings;buffer;useReplacer=!1;rootSchema;constructor(t){super(),this.settings=t}write(t,e){this.rootSchema=u.of(t),this.buffer=this._write(this.rootSchema,e)}writeDiscriminatedDocument(t,e){this.write(t,e),typeof this.buffer=="object"&&(this.buffer.__type=u.of(t).getName(!0))}flush(){const{rootSchema:t,useReplacer:e}=this;if(this.rootSchema=void 0,this.useReplacer=!1,t?.isStructSchema()||t?.isDocumentSchema()){if(!e)return JSON.stringify(this.buffer);const i=new P;return i.replaceInJson(JSON.stringify(this.buffer,i.createReplacer(),0))}return this.buffer}_write(t,e,i){const s=e!==null&&typeof e=="object",n=u.of(t);if(s){if(n.isStructSchema()){const r={};for(const[o,c]of _(n,e)){const a=this._write(c,e[o],n);if(a!==void 0){const m=c.getMergedTraits().jsonName,p=this.settings.jsonName?m??o:o;r[p]=a}}return r}if(Array.isArray(e)&&n.isListSchema()){const r=n.getValueSchema(),o=[],c=!!n.getMergedTraits().sparse;for(const a of e)(c||a!=null)&&o.push(this._write(r,a));return o}if(n.isMapSchema()){const r=n.getValueSchema(),o={},c=!!n.getMergedTraits().sparse;for(const[a,m]of Object.entries(e))(c||m!=null)&&(o[a]=this._write(r,m));return o}if(e instanceof Uint8Array&&(n.isBlobSchema()||n.isDocumentSchema()))return n===this.rootSchema?e:(this.serdeContext?.base64Encoder??S)(e);if(e instanceof Date&&(n.isTimestampSchema()||n.isDocumentSchema()))switch(b(n,this.settings)){case 5:return e.toISOString().replace(".000Z","Z");case 6:return k(e);case 7:return e.getTime()/1e3;default:return console.warn("Missing timestamp format, using epoch seconds",e),e.getTime()/1e3}e instanceof h&&(this.useReplacer=!0)}if(!(e===null&&i?.isStructSchema())){if(n.isStringSchema()){if(typeof e>"u"&&n.isIdempotencyToken())return R();const r=n.getMergedTraits().mediaType;return e!=null&&r&&(r==="application/json"||r.endsWith("+json"))?w.from(e):e}if(typeof e=="number"&&n.isNumericSchema())return Math.abs(e)===1/0||isNaN(e)?String(e):e;if(typeof e=="string"&&n.isBlobSchema())return n===this.rootSchema?e:(this.serdeContext?.base64Encoder??S)(e);if(typeof e=="bigint"&&(this.useReplacer=!0),n.isDocumentSchema())if(s){const r=Array.isArray(e)?[]:{};for(const[o,c]of Object.entries(e))c instanceof h?(this.useReplacer=!0,r[o]=c):r[o]=this._write(n,c);return r}else return structuredClone(e);return e}}}class U extends y{settings;constructor(t){super(),this.settings=t}createSerializer(){const t=new F(this.settings);return t.setSerdeContext(this.serdeContext),t}createDeserializer(){const t=new L(this.settings);return t.setSerdeContext(this.serdeContext),t}}class q extends z{serializer;deserializer;serviceTarget;codec;mixin;awsQueryCompatible;constructor({defaultNamespace:t,serviceTarget:e,awsQueryCompatible:i,jsonCodec:s}){super({defaultNamespace:t}),this.serviceTarget=e,this.codec=s??new U({timestampFormat:{useTrait:!0,default:7},jsonName:!1}),this.serializer=this.codec.createSerializer(),this.deserializer=this.codec.createDeserializer(),this.awsQueryCompatible=!!i,this.mixin=new E(this.awsQueryCompatible)}async serializeRequest(t,e,i){const s=await super.serializeRequest(t,e,i);return s.path.endsWith("/")||(s.path+="/"),Object.assign(s.headers,{"content-type":`application/x-amz-json-${this.getJsonRpcVersion()}`,"x-amz-target":`${this.serviceTarget}.${t.name}`}),this.awsQueryCompatible&&(s.headers["x-amzn-query-mode"]="true"),(J(t.input)==="unit"||!s.body)&&(s.body="{}"),s}getPayloadCodec(){return this.codec}async handleError(t,e,i,s,n){this.awsQueryCompatible&&this.mixin.setQueryCompatError(s,i);const r=$(i,s)??"Unknown",{errorSchema:o,errorMetadata:c}=await this.mixin.getErrorSchemaOrThrowBaseException(r,this.options.defaultNamespace,i,s,n,this.awsQueryCompatible?this.mixin.findQueryCompatibleError:void 0),a=u.of(o),m=s.message??s.Message??"Unknown",p=M.for(o[1]).getErrorCtor(o)??Error,x=new p(m),d={};for(const[g,C]of a.structIterator())s[g]!=null&&(d[g]=this.codec.createDeserializer().readObject(C,s[g]));throw this.awsQueryCompatible&&this.mixin.queryCompatOutput(s,d),this.mixin.decorateServiceException(Object.assign(x,c,{$fault:a.getMergedTraits().error,message:m},d),s)}}class G extends q{constructor({defaultNamespace:t,serviceTarget:e,awsQueryCompatible:i,jsonCodec:s}){super({defaultNamespace:t,serviceTarget:e,awsQueryCompatible:i,jsonCodec:s})}getShapeId(){return"aws.protocols#awsJson1_1"}getJsonRpcVersion(){return"1.1"}getDefaultContentType(){return"application/x-amz-json-1.1"}}export{G as A};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as B}from"./__vite-browser-external-DLjrMatA.js";import{a as N}from"./_commonjsHelpers-D6-XlEtG.js";const R=N(B);var C={},m;function j(){if(m)return C;m=1,C.byteLength=p,C.toByteArray=y,C.fromByteArray=g;for(var n=[],a=[],A=typeof Uint8Array<"u"?Uint8Array:Array,x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,c=x.length;i<c;++i)n[i]=x[i],a[x.charCodeAt(i)]=i;a[45]=62,a[95]=63;function t(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var o=r.indexOf("=");o===-1&&(o=e);var f=o===e?0:4-o%4;return[o,f]}function p(r){var e=t(r),o=e[0],f=e[1];return(o+f)*3/4-f}function l(r,e,o){return(e+o)*3/4-o}function y(r){var e,o=t(r),f=o[0],d=o[1],s=new A(l(r,f,d)),u=0,w=d>0?f-4:f,F;for(F=0;F<w;F+=4)e=a[r.charCodeAt(F)]<<18|a[r.charCodeAt(F+1)]<<12|a[r.charCodeAt(F+2)]<<6|a[r.charCodeAt(F+3)],s[u++]=e>>16&255,s[u++]=e>>8&255,s[u++]=e&255;return d===2&&(e=a[r.charCodeAt(F)]<<2|a[r.charCodeAt(F+1)]>>4,s[u++]=e&255),d===1&&(e=a[r.charCodeAt(F)]<<10|a[r.charCodeAt(F+1)]<<4|a[r.charCodeAt(F+2)]>>2,s[u++]=e>>8&255,s[u++]=e&255),s}function h(r){return n[r>>18&63]+n[r>>12&63]+n[r>>6&63]+n[r&63]}function v(r,e,o){for(var f,d=[],s=e;s<o;s+=3)f=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),d.push(h(f));return d.join("")}function g(r){for(var e,o=r.length,f=o%3,d=[],s=16383,u=0,w=o-f;u<w;u+=s)d.push(v(r,u,u+s>w?w:u+s));return f===1?(e=r[o-1],d.push(n[e>>2]+n[e<<4&63]+"==")):f===2&&(e=(r[o-2]<<8)+r[o-1],d.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),d.join("")}return C}var M={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var q;function J(){return q||(q=1,M.read=function(n,a,A,x,i){var c,t,p=i*8-x-1,l=(1<<p)-1,y=l>>1,h=-7,v=A?i-1:0,g=A?-1:1,r=n[a+v];for(v+=g,c=r&(1<<-h)-1,r>>=-h,h+=p;h>0;c=c*256+n[a+v],v+=g,h-=8);for(t=c&(1<<-h)-1,c>>=-h,h+=x;h>0;t=t*256+n[a+v],v+=g,h-=8);if(c===0)c=1-y;else{if(c===l)return t?NaN:(r?-1:1)*(1/0);t=t+Math.pow(2,x),c=c-y}return(r?-1:1)*t*Math.pow(2,c-x)},M.write=function(n,a,A,x,i,c){var t,p,l,y=c*8-i-1,h=(1<<y)-1,v=h>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,r=x?0:c-1,e=x?1:-1,o=a<0||a===0&&1/a<0?1:0;for(a=Math.abs(a),isNaN(a)||a===1/0?(p=isNaN(a)?1:0,t=h):(t=Math.floor(Math.log(a)/Math.LN2),a*(l=Math.pow(2,-t))<1&&(t--,l*=2),t+v>=1?a+=g/l:a+=g*Math.pow(2,1-v),a*l>=2&&(t++,l/=2),t+v>=h?(p=0,t=h):t+v>=1?(p=(a*l-1)*Math.pow(2,i),t=t+v):(p=a*Math.pow(2,v-1)*Math.pow(2,i),t=0));i>=8;n[A+r]=p&255,r+=e,p/=256,i-=8);for(t=t<<i|p,y+=i;y>0;n[A+r]=t&255,r+=e,t/=256,y-=8);n[A+r-e]|=o*128}),M}function L(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}export{j as a,J as b,L as c,R as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as N}from"./_commonjsHelpers-D6-XlEtG.js";import{r as g}from"./_commonjs-dynamic-modules-B7n8ZNar.js";var p,S;function w(){if(S)return p;S=1;const u=g;class i{constructor(e,t){typeof e=="string"?this.#r(e):t!==void 0?this.#t(e,t):this.#e(e)}toPostgres(){const e=this.values,t=this.indices.map((s,n)=>u.format("%i:%f",s+1,e[n])).join(",");return u.format("{%s}/%d",t,this.dimensions)}toString(){return this.toPostgres()}toArray(){const e=Array(this.dimensions).fill(0);for(const[t,s]of this.indices.entries())e[s]=this.values[t];return e}#r(e){const t=e.split("/",2);this.dimensions=parseInt(t[1]),this.indices=[],this.values=[];const s=t[0].slice(1,-1).split(",");for(const n of s){const c=n.split(":",2);this.indices.push(parseInt(c[0])-1),this.values.push(parseFloat(c[1]))}}#e(e){this.dimensions=e.length,this.indices=[],this.values=[];for(const[t,s]of e.entries()){const n=Number(s);n!=0&&(this.indices.push(Number(t)),this.values.push(n))}}#t(e,t){this.dimensions=Number(t),this.indices=[],this.values=[];const s=e instanceof Map?e.entries():Object.entries(e);for(const[n,c]of s){const l=Number(c);l!=0&&(this.indices.push(Number(n)),this.values.push(l))}}}return p={SparseVector:i},p}var h,q;function A(){if(q)return h;q=1;const u=g,{SparseVector:i}=w();function f(r){return r===null?null:r.substring(1,r.length-1).split(",").map(o=>parseFloat(o))}function e(r){return Array.isArray(r)?JSON.stringify(r.map(o=>Number(o))):r}const t=f,s=e;function n(r){return r===null?null:new i(r)}function c(r){return r instanceof i?r.toPostgres():r}function l(r){if(r===null)return null;if(r[0]=="[")return f(r);if(r[0]=="{")return n(r);throw new Error("invalid text representation")}function b(r){if(r===null)return null;if(Array.isArray(r))return e(r);if(r instanceof i)return c(r);throw new Error("expected array or sparse vector")}function a(r,o){if(o==null)return r;if(!Number.isInteger(o))throw new Error("expected integer");return u.format("%s(%d)",r,o)}function d(r){return a("vector",r)}function v(r){return a("halfvec",r)}function T(r){return a("bit",r)}function x(r){return a("sparsevec",r)}return h={fromSql:l,toSql:b,vectorFromSql:f,vectorToSql:e,halfvecFromSql:t,halfvecToSql:s,sparsevecFromSql:n,sparsevecToSql:c,sqlType:d,vectorType:d,halfvecType:v,bitType:T,sparsevecType:x,SparseVector:i},h}var m,y;function F(){if(y)return m;y=1;const{fromSql:u,toSql:i,SparseVector:f}=A();return m={fromSql:u,toSql:i,SparseVector:f},m}var V=F();const j=N(V),_=Object.freeze(Object.defineProperty({__proto__:null,default:j},Symbol.toStringTag,{value:"Module"}));export{_ as i};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{c as We,a as Oe}from"./_commonjsHelpers-D6-XlEtG.js";import{
|
|
1
|
+
import{c as We,a as Oe}from"./_commonjsHelpers-D6-XlEtG.js";import{a as Ot,b as Nt,c as Kt,r as kt}from"./_commonjs-dynamic-modules-B7n8ZNar.js";import"./__vite-browser-external-DLjrMatA.js";/*!
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/var
|
|
4
|
+
*/var Vn=(function(){function o(r){var e=r||{},a=e.ValidationData,s=e.Username,f=e.Password,u=e.AuthParameters,l=e.ClientMetadata;this.validationData=a||{},this.authParameters=u||{},this.clientMetadata=l||{},this.username=s,this.password=f}var t=o.prototype;return t.getUsername=function(){return this.username},t.getPassword=function(){return this.password},t.getValidationData=function(){return this.validationData},t.getAuthParameters=function(){return this.authParameters},t.getClientMetadata=function(){return this.clientMetadata},o})(),Ae={},Ue,Je;function qt(){if(Je)return Ue;Je=1;var o={}.toString;return Ue=Array.isArray||function(t){return o.call(t)=="[object Array]"},Ue}/*!
|
|
5
5
|
* The buffer module from node.js, for the browser.
|
|
6
6
|
*
|
|
7
7
|
* @author Feross Aboukhadijeh <http://feross.org>
|
|
8
8
|
* @license MIT
|
|
9
|
-
*/var Ge;function Vt(){return Ge||(Ge=1,(function(o){var t=Ot(),r=Nt(),e=qt();o.Buffer=u,o.SlowBuffer=T,o.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=We.TYPED_ARRAY_SUPPORT!==void 0?We.TYPED_ARRAY_SUPPORT:a(),o.kMaxLength=s();function a(){try{var h=new Uint8Array(1);return h.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},h.foo()===42&&typeof h.subarray=="function"&&h.subarray(1,1).byteLength===0}catch{return!1}}function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(h,n){if(s()<n)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(h=new Uint8Array(n),h.__proto__=u.prototype):(h===null&&(h=new u(n)),h.length=n),h}function u(h,n,i){if(!u.TYPED_ARRAY_SUPPORT&&!(this instanceof u))return new u(h,n,i);if(typeof h=="number"){if(typeof n=="string")throw new Error("If encoding is specified then the first argument must be a string");return y(this,h)}return l(this,h,n,i)}u.poolSize=8192,u._augment=function(h){return h.__proto__=u.prototype,h};function l(h,n,i,c){if(typeof n=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&n instanceof ArrayBuffer?A(h,n,i,c):typeof n=="string"?S(h,n,i):C(h,n)}u.from=function(h,n,i){return l(null,h,n,i)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0}));function p(h){if(typeof h!="number")throw new TypeError('"size" argument must be a number');if(h<0)throw new RangeError('"size" argument must not be negative')}function d(h,n,i,c){return p(n),n<=0?f(h,n):i!==void 0?typeof c=="string"?f(h,n).fill(i,c):f(h,n).fill(i):f(h,n)}u.alloc=function(h,n,i){return d(null,h,n,i)};function y(h,n){if(p(n),h=f(h,n<0?0:D(n)|0),!u.TYPED_ARRAY_SUPPORT)for(var i=0;i<n;++i)h[i]=0;return h}u.allocUnsafe=function(h){return y(null,h)},u.allocUnsafeSlow=function(h){return y(null,h)};function S(h,n,i){if((typeof i!="string"||i==="")&&(i="utf8"),!u.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var c=P(n,i)|0;h=f(h,c);var g=h.write(n,i);return g!==c&&(h=h.slice(0,g)),h}function U(h,n){var i=n.length<0?0:D(n.length)|0;h=f(h,i);for(var c=0;c<i;c+=1)h[c]=n[c]&255;return h}function A(h,n,i,c){if(n.byteLength,i<0||n.byteLength<i)throw new RangeError("'offset' is out of bounds");if(n.byteLength<i+(c||0))throw new RangeError("'length' is out of bounds");return i===void 0&&c===void 0?n=new Uint8Array(n):c===void 0?n=new Uint8Array(n,i):n=new Uint8Array(n,i,c),u.TYPED_ARRAY_SUPPORT?(h=n,h.__proto__=u.prototype):h=U(h,n),h}function C(h,n){if(u.isBuffer(n)){var i=D(n.length)|0;return h=f(h,i),h.length===0||n.copy(h,0,0,i),h}if(n){if(typeof ArrayBuffer<"u"&&n.buffer instanceof ArrayBuffer||"length"in n)return typeof n.length!="number"||Mt(n.length)?f(h,0):U(h,n);if(n.type==="Buffer"&&e(n.data))return U(h,n.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function D(h){if(h>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return h|0}function T(h){return+h!=h&&(h=0),u.alloc(+h)}u.isBuffer=function(n){return!!(n!=null&&n._isBuffer)},u.compare=function(n,i){if(!u.isBuffer(n)||!u.isBuffer(i))throw new TypeError("Arguments must be Buffers");if(n===i)return 0;for(var c=n.length,g=i.length,v=0,m=Math.min(c,g);v<m;++v)if(n[v]!==i[v]){c=n[v],g=i[v];break}return c<g?-1:g<c?1:0},u.isEncoding=function(n){switch(String(n).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(n,i){if(!e(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return u.alloc(0);var c;if(i===void 0)for(i=0,c=0;c<n.length;++c)i+=n[c].length;var g=u.allocUnsafe(i),v=0;for(c=0;c<n.length;++c){var m=n[c];if(!u.isBuffer(m))throw new TypeError('"list" argument must be an Array of Buffers');m.copy(g,v),v+=m.length}return g};function P(h,n){if(u.isBuffer(h))return h.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(h)||h instanceof ArrayBuffer))return h.byteLength;typeof h!="string"&&(h=""+h);var i=h.length;if(i===0)return 0;for(var c=!1;;)switch(n){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return ve(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return je(h).length;default:if(c)return ve(h).length;n=(""+n).toLowerCase(),c=!0}}u.byteLength=P;function j(h,n,i){var c=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,n>>>=0,i<=n))return"";for(h||(h="utf8");;)switch(h){case"hex":return xt(this,n,i);case"utf8":case"utf-8":return ne(this,n,i);case"ascii":return Tt(this,n,i);case"latin1":case"binary":return Dt(this,n,i);case"base64":return $(this,n,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return It(this,n,i);default:if(c)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),c=!0}}u.prototype._isBuffer=!0;function k(h,n,i){var c=h[n];h[n]=h[i],h[i]=c}u.prototype.swap16=function(){var n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var i=0;i<n;i+=2)k(this,i,i+1);return this},u.prototype.swap32=function(){var n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var i=0;i<n;i+=4)k(this,i,i+3),k(this,i+1,i+2);return this},u.prototype.swap64=function(){var n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var i=0;i<n;i+=8)k(this,i,i+7),k(this,i+1,i+6),k(this,i+2,i+5),k(this,i+3,i+4);return this},u.prototype.toString=function(){var n=this.length|0;return n===0?"":arguments.length===0?ne(this,0,n):j.apply(this,arguments)},u.prototype.equals=function(n){if(!u.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:u.compare(this,n)===0},u.prototype.inspect=function(){var n="",i=o.INSPECT_MAX_BYTES;return this.length>0&&(n=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(n+=" ... ")),"<Buffer "+n+">"},u.prototype.compare=function(n,i,c,g,v){if(!u.isBuffer(n))throw new TypeError("Argument must be a Buffer");if(i===void 0&&(i=0),c===void 0&&(c=n?n.length:0),g===void 0&&(g=0),v===void 0&&(v=this.length),i<0||c>n.length||g<0||v>this.length)throw new RangeError("out of range index");if(g>=v&&i>=c)return 0;if(g>=v)return-1;if(i>=c)return 1;if(i>>>=0,c>>>=0,g>>>=0,v>>>=0,this===n)return 0;for(var m=v-g,E=c-i,x=Math.min(m,E),_=this.slice(g,v),B=n.slice(i,c),R=0;R<x;++R)if(_[R]!==B[R]){m=_[R],E=B[R];break}return m<E?-1:E<m?1:0};function Y(h,n,i,c,g){if(h.length===0)return-1;if(typeof i=="string"?(c=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=g?0:h.length-1),i<0&&(i=h.length+i),i>=h.length){if(g)return-1;i=h.length-1}else if(i<0)if(g)i=0;else return-1;if(typeof n=="string"&&(n=u.from(n,c)),u.isBuffer(n))return n.length===0?-1:W(h,n,i,c,g);if(typeof n=="number")return n=n&255,u.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?g?Uint8Array.prototype.indexOf.call(h,n,i):Uint8Array.prototype.lastIndexOf.call(h,n,i):W(h,[n],i,c,g);throw new TypeError("val must be string, number or Buffer")}function W(h,n,i,c,g){var v=1,m=h.length,E=n.length;if(c!==void 0&&(c=String(c).toLowerCase(),c==="ucs2"||c==="ucs-2"||c==="utf16le"||c==="utf-16le")){if(h.length<2||n.length<2)return-1;v=2,m/=2,E/=2,i/=2}function x(He,Ye){return v===1?He[Ye]:He.readUInt16BE(Ye*v)}var _;if(g){var B=-1;for(_=i;_<m;_++)if(x(h,_)===x(n,B===-1?0:_-B)){if(B===-1&&(B=_),_-B+1===E)return B*v}else B!==-1&&(_-=_-B),B=-1}else for(i+E>m&&(i=m-E),_=i;_>=0;_--){for(var R=!0,ye=0;ye<E;ye++)if(x(h,_+ye)!==x(n,ye)){R=!1;break}if(R)return _}return-1}u.prototype.includes=function(n,i,c){return this.indexOf(n,i,c)!==-1},u.prototype.indexOf=function(n,i,c){return Y(this,n,i,c,!0)},u.prototype.lastIndexOf=function(n,i,c){return Y(this,n,i,c,!1)};function te(h,n,i,c){i=Number(i)||0;var g=h.length-i;c?(c=Number(c),c>g&&(c=g)):c=g;var v=n.length;if(v%2!==0)throw new TypeError("Invalid hex string");c>v/2&&(c=v/2);for(var m=0;m<c;++m){var E=parseInt(n.substr(m*2,2),16);if(isNaN(E))return m;h[i+m]=E}return m}function L(h,n,i,c){return me(ve(n,h.length-i),h,i,c)}function O(h,n,i,c){return me(Bt(n),h,i,c)}function J(h,n,i,c){return O(h,n,i,c)}function z(h,n,i,c){return me(je(n),h,i,c)}function re(h,n,i,c){return me(bt(n,h.length-i),h,i,c)}u.prototype.write=function(n,i,c,g){if(i===void 0)g="utf8",c=this.length,i=0;else if(c===void 0&&typeof i=="string")g=i,c=this.length,i=0;else if(isFinite(i))i=i|0,isFinite(c)?(c=c|0,g===void 0&&(g="utf8")):(g=c,c=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var v=this.length-i;if((c===void 0||c>v)&&(c=v),n.length>0&&(c<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");for(var m=!1;;)switch(g){case"hex":return te(this,n,i,c);case"utf8":case"utf-8":return L(this,n,i,c);case"ascii":return O(this,n,i,c);case"latin1":case"binary":return J(this,n,i,c);case"base64":return z(this,n,i,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return re(this,n,i,c);default:if(m)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),m=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function $(h,n,i){return n===0&&i===h.length?t.fromByteArray(h):t.fromByteArray(h.slice(n,i))}function ne(h,n,i){i=Math.min(h.length,i);for(var c=[],g=n;g<i;){var v=h[g],m=null,E=v>239?4:v>223?3:v>191?2:1;if(g+E<=i){var x,_,B,R;switch(E){case 1:v<128&&(m=v);break;case 2:x=h[g+1],(x&192)===128&&(R=(v&31)<<6|x&63,R>127&&(m=R));break;case 3:x=h[g+1],_=h[g+2],(x&192)===128&&(_&192)===128&&(R=(v&15)<<12|(x&63)<<6|_&63,R>2047&&(R<55296||R>57343)&&(m=R));break;case 4:x=h[g+1],_=h[g+2],B=h[g+3],(x&192)===128&&(_&192)===128&&(B&192)===128&&(R=(v&15)<<18|(x&63)<<12|(_&63)<<6|B&63,R>65535&&R<1114112&&(m=R))}}m===null?(m=65533,E=1):m>65535&&(m-=65536,c.push(m>>>10&1023|55296),m=56320|m&1023),c.push(m),g+=E}return Ce(c)}var G=4096;function Ce(h){var n=h.length;if(n<=G)return String.fromCharCode.apply(String,h);for(var i="",c=0;c<n;)i+=String.fromCharCode.apply(String,h.slice(c,c+=G));return i}function Tt(h,n,i){var c="";i=Math.min(h.length,i);for(var g=n;g<i;++g)c+=String.fromCharCode(h[g]&127);return c}function Dt(h,n,i){var c="";i=Math.min(h.length,i);for(var g=n;g<i;++g)c+=String.fromCharCode(h[g]);return c}function xt(h,n,i){var c=h.length;(!n||n<0)&&(n=0),(!i||i<0||i>c)&&(i=c);for(var g="",v=n;v<i;++v)g+=Ft(h[v]);return g}function It(h,n,i){for(var c=h.slice(n,i),g="",v=0;v<c.length;v+=2)g+=String.fromCharCode(c[v]+c[v+1]*256);return g}u.prototype.slice=function(n,i){var c=this.length;n=~~n,i=i===void 0?c:~~i,n<0?(n+=c,n<0&&(n=0)):n>c&&(n=c),i<0?(i+=c,i<0&&(i=0)):i>c&&(i=c),i<n&&(i=n);var g;if(u.TYPED_ARRAY_SUPPORT)g=this.subarray(n,i),g.__proto__=u.prototype;else{var v=i-n;g=new u(v,void 0);for(var m=0;m<v;++m)g[m]=this[m+n]}return g};function F(h,n,i){if(h%1!==0||h<0)throw new RangeError("offset is not uint");if(h+n>i)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUIntLE=function(n,i,c){n=n|0,i=i|0,c||F(n,i,this.length);for(var g=this[n],v=1,m=0;++m<i&&(v*=256);)g+=this[n+m]*v;return g},u.prototype.readUIntBE=function(n,i,c){n=n|0,i=i|0,c||F(n,i,this.length);for(var g=this[n+--i],v=1;i>0&&(v*=256);)g+=this[n+--i]*v;return g},u.prototype.readUInt8=function(n,i){return i||F(n,1,this.length),this[n]},u.prototype.readUInt16LE=function(n,i){return i||F(n,2,this.length),this[n]|this[n+1]<<8},u.prototype.readUInt16BE=function(n,i){return i||F(n,2,this.length),this[n]<<8|this[n+1]},u.prototype.readUInt32LE=function(n,i){return i||F(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},u.prototype.readUInt32BE=function(n,i){return i||F(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},u.prototype.readIntLE=function(n,i,c){n=n|0,i=i|0,c||F(n,i,this.length);for(var g=this[n],v=1,m=0;++m<i&&(v*=256);)g+=this[n+m]*v;return v*=128,g>=v&&(g-=Math.pow(2,8*i)),g},u.prototype.readIntBE=function(n,i,c){n=n|0,i=i|0,c||F(n,i,this.length);for(var g=i,v=1,m=this[n+--g];g>0&&(v*=256);)m+=this[n+--g]*v;return v*=128,m>=v&&(m-=Math.pow(2,8*i)),m},u.prototype.readInt8=function(n,i){return i||F(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},u.prototype.readInt16LE=function(n,i){i||F(n,2,this.length);var c=this[n]|this[n+1]<<8;return c&32768?c|4294901760:c},u.prototype.readInt16BE=function(n,i){i||F(n,2,this.length);var c=this[n+1]|this[n]<<8;return c&32768?c|4294901760:c},u.prototype.readInt32LE=function(n,i){return i||F(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},u.prototype.readInt32BE=function(n,i){return i||F(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},u.prototype.readFloatLE=function(n,i){return i||F(n,4,this.length),r.read(this,n,!0,23,4)},u.prototype.readFloatBE=function(n,i){return i||F(n,4,this.length),r.read(this,n,!1,23,4)},u.prototype.readDoubleLE=function(n,i){return i||F(n,8,this.length),r.read(this,n,!0,52,8)},u.prototype.readDoubleBE=function(n,i){return i||F(n,8,this.length),r.read(this,n,!1,52,8)};function M(h,n,i,c,g,v){if(!u.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>g||n<v)throw new RangeError('"value" argument is out of bounds');if(i+c>h.length)throw new RangeError("Index out of range")}u.prototype.writeUIntLE=function(n,i,c,g){if(n=+n,i=i|0,c=c|0,!g){var v=Math.pow(2,8*c)-1;M(this,n,i,c,v,0)}var m=1,E=0;for(this[i]=n&255;++E<c&&(m*=256);)this[i+E]=n/m&255;return i+c},u.prototype.writeUIntBE=function(n,i,c,g){if(n=+n,i=i|0,c=c|0,!g){var v=Math.pow(2,8*c)-1;M(this,n,i,c,v,0)}var m=c-1,E=1;for(this[i+m]=n&255;--m>=0&&(E*=256);)this[i+m]=n/E&255;return i+c},u.prototype.writeUInt8=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,1,255,0),u.TYPED_ARRAY_SUPPORT||(n=Math.floor(n)),this[i]=n&255,i+1};function ge(h,n,i,c){n<0&&(n=65535+n+1);for(var g=0,v=Math.min(h.length-i,2);g<v;++g)h[i+g]=(n&255<<8*(c?g:1-g))>>>(c?g:1-g)*8}u.prototype.writeUInt16LE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[i]=n&255,this[i+1]=n>>>8):ge(this,n,i,!0),i+2},u.prototype.writeUInt16BE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[i]=n>>>8,this[i+1]=n&255):ge(this,n,i,!1),i+2};function de(h,n,i,c){n<0&&(n=4294967295+n+1);for(var g=0,v=Math.min(h.length-i,4);g<v;++g)h[i+g]=n>>>(c?g:3-g)*8&255}u.prototype.writeUInt32LE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[i+3]=n>>>24,this[i+2]=n>>>16,this[i+1]=n>>>8,this[i]=n&255):de(this,n,i,!0),i+4},u.prototype.writeUInt32BE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[i]=n>>>24,this[i+1]=n>>>16,this[i+2]=n>>>8,this[i+3]=n&255):de(this,n,i,!1),i+4},u.prototype.writeIntLE=function(n,i,c,g){if(n=+n,i=i|0,!g){var v=Math.pow(2,8*c-1);M(this,n,i,c,v-1,-v)}var m=0,E=1,x=0;for(this[i]=n&255;++m<c&&(E*=256);)n<0&&x===0&&this[i+m-1]!==0&&(x=1),this[i+m]=(n/E>>0)-x&255;return i+c},u.prototype.writeIntBE=function(n,i,c,g){if(n=+n,i=i|0,!g){var v=Math.pow(2,8*c-1);M(this,n,i,c,v-1,-v)}var m=c-1,E=1,x=0;for(this[i+m]=n&255;--m>=0&&(E*=256);)n<0&&x===0&&this[i+m+1]!==0&&(x=1),this[i+m]=(n/E>>0)-x&255;return i+c},u.prototype.writeInt8=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,1,127,-128),u.TYPED_ARRAY_SUPPORT||(n=Math.floor(n)),n<0&&(n=255+n+1),this[i]=n&255,i+1},u.prototype.writeInt16LE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[i]=n&255,this[i+1]=n>>>8):ge(this,n,i,!0),i+2},u.prototype.writeInt16BE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[i]=n>>>8,this[i+1]=n&255):ge(this,n,i,!1),i+2},u.prototype.writeInt32LE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[i]=n&255,this[i+1]=n>>>8,this[i+2]=n>>>16,this[i+3]=n>>>24):de(this,n,i,!0),i+4},u.prototype.writeInt32BE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),u.TYPED_ARRAY_SUPPORT?(this[i]=n>>>24,this[i+1]=n>>>16,this[i+2]=n>>>8,this[i+3]=n&255):de(this,n,i,!1),i+4};function qe(h,n,i,c,g,v){if(i+c>h.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function Ve(h,n,i,c,g){return g||qe(h,n,i,4),r.write(h,n,i,c,23,4),i+4}u.prototype.writeFloatLE=function(n,i,c){return Ve(this,n,i,!0,c)},u.prototype.writeFloatBE=function(n,i,c){return Ve(this,n,i,!1,c)};function Le(h,n,i,c,g){return g||qe(h,n,i,8),r.write(h,n,i,c,52,8),i+8}u.prototype.writeDoubleLE=function(n,i,c){return Le(this,n,i,!0,c)},u.prototype.writeDoubleBE=function(n,i,c){return Le(this,n,i,!1,c)},u.prototype.copy=function(n,i,c,g){if(c||(c=0),!g&&g!==0&&(g=this.length),i>=n.length&&(i=n.length),i||(i=0),g>0&&g<c&&(g=c),g===c||n.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(c<0||c>=this.length)throw new RangeError("sourceStart out of bounds");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),n.length-i<g-c&&(g=n.length-i+c);var v=g-c,m;if(this===n&&c<i&&i<g)for(m=v-1;m>=0;--m)n[m+i]=this[m+c];else if(v<1e3||!u.TYPED_ARRAY_SUPPORT)for(m=0;m<v;++m)n[m+i]=this[m+c];else Uint8Array.prototype.set.call(n,this.subarray(c,c+v),i);return v},u.prototype.fill=function(n,i,c,g){if(typeof n=="string"){if(typeof i=="string"?(g=i,i=0,c=this.length):typeof c=="string"&&(g=c,c=this.length),n.length===1){var v=n.charCodeAt(0);v<256&&(n=v)}if(g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!u.isEncoding(g))throw new TypeError("Unknown encoding: "+g)}else typeof n=="number"&&(n=n&255);if(i<0||this.length<i||this.length<c)throw new RangeError("Out of range index");if(c<=i)return this;i=i>>>0,c=c===void 0?this.length:c>>>0,n||(n=0);var m;if(typeof n=="number")for(m=i;m<c;++m)this[m]=n;else{var E=u.isBuffer(n)?n:ve(new u(n,g).toString()),x=E.length;for(m=0;m<c-i;++m)this[m+i]=E[m%x]}return this};var _t=/[^+\/0-9A-Za-z-_]/g;function Rt(h){if(h=Pt(h).replace(_t,""),h.length<2)return"";for(;h.length%4!==0;)h=h+"=";return h}function Pt(h){return h.trim?h.trim():h.replace(/^\s+|\s+$/g,"")}function Ft(h){return h<16?"0"+h.toString(16):h.toString(16)}function ve(h,n){n=n||1/0;for(var i,c=h.length,g=null,v=[],m=0;m<c;++m){if(i=h.charCodeAt(m),i>55295&&i<57344){if(!g){if(i>56319){(n-=3)>-1&&v.push(239,191,189);continue}else if(m+1===c){(n-=3)>-1&&v.push(239,191,189);continue}g=i;continue}if(i<56320){(n-=3)>-1&&v.push(239,191,189),g=i;continue}i=(g-55296<<10|i-56320)+65536}else g&&(n-=3)>-1&&v.push(239,191,189);if(g=null,i<128){if((n-=1)<0)break;v.push(i)}else if(i<2048){if((n-=2)<0)break;v.push(i>>6|192,i&63|128)}else if(i<65536){if((n-=3)<0)break;v.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((n-=4)<0)break;v.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return v}function Bt(h){for(var n=[],i=0;i<h.length;++i)n.push(h.charCodeAt(i)&255);return n}function bt(h,n){for(var i,c,g,v=[],m=0;m<h.length&&!((n-=2)<0);++m)i=h.charCodeAt(m),c=i>>8,g=i%256,v.push(g),v.push(c);return v}function je(h){return t.toByteArray(Rt(h))}function me(h,n,i,c){for(var g=0;g<c&&!(g+i>=n.length||g>=h.length);++g)n[g+i]=h[g];return g}function Mt(h){return h!==h}})(Ae)),Ae}var I=Vt(),q;typeof window<"u"&&window.crypto&&(q=window.crypto);!q&&typeof window<"u"&&window.msCrypto&&(q=window.msCrypto);!q&&typeof global<"u"&&global.crypto&&(q=global.crypto);if(!q&&typeof kt=="function")try{q=Kt}catch{}function Lt(){if(q){if(typeof q.getRandomValues=="function")try{return q.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof q.randomBytes=="function")try{return q.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")}function jt(o){for(var t=o.words,r=o.sigBytes,e=[],a=0;a<r;a++){var s=t[a>>>2]>>>24-a%4*8&255;e.push((s>>>4).toString(16)),e.push((s&15).toString(16))}return e.join("")}var Ht=(function(){function o(r,e){r=this.words=r||[],e!=null?this.sigBytes=e:this.sigBytes=r.length*4}var t=o.prototype;return t.random=function(e){for(var a=[],s=0;s<e;s+=4)a.push(Lt());return new o(a,e)},t.toString=function(){return jt(this)},o})(),Ee={};/*! *****************************************************************************
|
|
9
|
+
*/var Ge;function Vt(){return Ge||(Ge=1,(function(o){var t=Ot(),r=Nt(),e=qt();o.Buffer=u,o.SlowBuffer=T,o.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=We.TYPED_ARRAY_SUPPORT!==void 0?We.TYPED_ARRAY_SUPPORT:a(),o.kMaxLength=s();function a(){try{var h=new Uint8Array(1);return h.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},h.foo()===42&&typeof h.subarray=="function"&&h.subarray(1,1).byteLength===0}catch{return!1}}function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(h,n){if(s()<n)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(h=new Uint8Array(n),h.__proto__=u.prototype):(h===null&&(h=new u(n)),h.length=n),h}function u(h,n,i){if(!u.TYPED_ARRAY_SUPPORT&&!(this instanceof u))return new u(h,n,i);if(typeof h=="number"){if(typeof n=="string")throw new Error("If encoding is specified then the first argument must be a string");return y(this,h)}return l(this,h,n,i)}u.poolSize=8192,u._augment=function(h){return h.__proto__=u.prototype,h};function l(h,n,i,c){if(typeof n=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&n instanceof ArrayBuffer?A(h,n,i,c):typeof n=="string"?S(h,n,i):C(h,n)}u.from=function(h,n,i){return l(null,h,n,i)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0}));function p(h){if(typeof h!="number")throw new TypeError('"size" argument must be a number');if(h<0)throw new RangeError('"size" argument must not be negative')}function d(h,n,i,c){return p(n),n<=0?f(h,n):i!==void 0?typeof c=="string"?f(h,n).fill(i,c):f(h,n).fill(i):f(h,n)}u.alloc=function(h,n,i){return d(null,h,n,i)};function y(h,n){if(p(n),h=f(h,n<0?0:D(n)|0),!u.TYPED_ARRAY_SUPPORT)for(var i=0;i<n;++i)h[i]=0;return h}u.allocUnsafe=function(h){return y(null,h)},u.allocUnsafeSlow=function(h){return y(null,h)};function S(h,n,i){if((typeof i!="string"||i==="")&&(i="utf8"),!u.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var c=P(n,i)|0;h=f(h,c);var g=h.write(n,i);return g!==c&&(h=h.slice(0,g)),h}function U(h,n){var i=n.length<0?0:D(n.length)|0;h=f(h,i);for(var c=0;c<i;c+=1)h[c]=n[c]&255;return h}function A(h,n,i,c){if(n.byteLength,i<0||n.byteLength<i)throw new RangeError("'offset' is out of bounds");if(n.byteLength<i+(c||0))throw new RangeError("'length' is out of bounds");return i===void 0&&c===void 0?n=new Uint8Array(n):c===void 0?n=new Uint8Array(n,i):n=new Uint8Array(n,i,c),u.TYPED_ARRAY_SUPPORT?(h=n,h.__proto__=u.prototype):h=U(h,n),h}function C(h,n){if(u.isBuffer(n)){var i=D(n.length)|0;return h=f(h,i),h.length===0||n.copy(h,0,0,i),h}if(n){if(typeof ArrayBuffer<"u"&&n.buffer instanceof ArrayBuffer||"length"in n)return typeof n.length!="number"||Mt(n.length)?f(h,0):U(h,n);if(n.type==="Buffer"&&e(n.data))return U(h,n.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function D(h){if(h>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return h|0}function T(h){return+h!=h&&(h=0),u.alloc(+h)}u.isBuffer=function(n){return!!(n!=null&&n._isBuffer)},u.compare=function(n,i){if(!u.isBuffer(n)||!u.isBuffer(i))throw new TypeError("Arguments must be Buffers");if(n===i)return 0;for(var c=n.length,g=i.length,v=0,m=Math.min(c,g);v<m;++v)if(n[v]!==i[v]){c=n[v],g=i[v];break}return c<g?-1:g<c?1:0},u.isEncoding=function(n){switch(String(n).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(n,i){if(!e(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return u.alloc(0);var c;if(i===void 0)for(i=0,c=0;c<n.length;++c)i+=n[c].length;var g=u.allocUnsafe(i),v=0;for(c=0;c<n.length;++c){var m=n[c];if(!u.isBuffer(m))throw new TypeError('"list" argument must be an Array of Buffers');m.copy(g,v),v+=m.length}return g};function P(h,n){if(u.isBuffer(h))return h.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(h)||h instanceof ArrayBuffer))return h.byteLength;typeof h!="string"&&(h=""+h);var i=h.length;if(i===0)return 0;for(var c=!1;;)switch(n){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return ve(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return je(h).length;default:if(c)return ve(h).length;n=(""+n).toLowerCase(),c=!0}}u.byteLength=P;function j(h,n,i){var c=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,n>>>=0,i<=n))return"";for(h||(h="utf8");;)switch(h){case"hex":return xt(this,n,i);case"utf8":case"utf-8":return ne(this,n,i);case"ascii":return Tt(this,n,i);case"latin1":case"binary":return Dt(this,n,i);case"base64":return $(this,n,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return It(this,n,i);default:if(c)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),c=!0}}u.prototype._isBuffer=!0;function k(h,n,i){var c=h[n];h[n]=h[i],h[i]=c}u.prototype.swap16=function(){var n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var i=0;i<n;i+=2)k(this,i,i+1);return this},u.prototype.swap32=function(){var n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var i=0;i<n;i+=4)k(this,i,i+3),k(this,i+1,i+2);return this},u.prototype.swap64=function(){var n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var i=0;i<n;i+=8)k(this,i,i+7),k(this,i+1,i+6),k(this,i+2,i+5),k(this,i+3,i+4);return this},u.prototype.toString=function(){var n=this.length|0;return n===0?"":arguments.length===0?ne(this,0,n):j.apply(this,arguments)},u.prototype.equals=function(n){if(!u.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:u.compare(this,n)===0},u.prototype.inspect=function(){var n="",i=o.INSPECT_MAX_BYTES;return this.length>0&&(n=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(n+=" ... ")),"<Buffer "+n+">"},u.prototype.compare=function(n,i,c,g,v){if(!u.isBuffer(n))throw new TypeError("Argument must be a Buffer");if(i===void 0&&(i=0),c===void 0&&(c=n?n.length:0),g===void 0&&(g=0),v===void 0&&(v=this.length),i<0||c>n.length||g<0||v>this.length)throw new RangeError("out of range index");if(g>=v&&i>=c)return 0;if(g>=v)return-1;if(i>=c)return 1;if(i>>>=0,c>>>=0,g>>>=0,v>>>=0,this===n)return 0;for(var m=v-g,E=c-i,x=Math.min(m,E),_=this.slice(g,v),B=n.slice(i,c),R=0;R<x;++R)if(_[R]!==B[R]){m=_[R],E=B[R];break}return m<E?-1:E<m?1:0};function Y(h,n,i,c,g){if(h.length===0)return-1;if(typeof i=="string"?(c=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=g?0:h.length-1),i<0&&(i=h.length+i),i>=h.length){if(g)return-1;i=h.length-1}else if(i<0)if(g)i=0;else return-1;if(typeof n=="string"&&(n=u.from(n,c)),u.isBuffer(n))return n.length===0?-1:W(h,n,i,c,g);if(typeof n=="number")return n=n&255,u.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?g?Uint8Array.prototype.indexOf.call(h,n,i):Uint8Array.prototype.lastIndexOf.call(h,n,i):W(h,[n],i,c,g);throw new TypeError("val must be string, number or Buffer")}function W(h,n,i,c,g){var v=1,m=h.length,E=n.length;if(c!==void 0&&(c=String(c).toLowerCase(),c==="ucs2"||c==="ucs-2"||c==="utf16le"||c==="utf-16le")){if(h.length<2||n.length<2)return-1;v=2,m/=2,E/=2,i/=2}function x(He,Ye){return v===1?He[Ye]:He.readUInt16BE(Ye*v)}var _;if(g){var B=-1;for(_=i;_<m;_++)if(x(h,_)===x(n,B===-1?0:_-B)){if(B===-1&&(B=_),_-B+1===E)return B*v}else B!==-1&&(_-=_-B),B=-1}else for(i+E>m&&(i=m-E),_=i;_>=0;_--){for(var R=!0,ye=0;ye<E;ye++)if(x(h,_+ye)!==x(n,ye)){R=!1;break}if(R)return _}return-1}u.prototype.includes=function(n,i,c){return this.indexOf(n,i,c)!==-1},u.prototype.indexOf=function(n,i,c){return Y(this,n,i,c,!0)},u.prototype.lastIndexOf=function(n,i,c){return Y(this,n,i,c,!1)};function te(h,n,i,c){i=Number(i)||0;var g=h.length-i;c?(c=Number(c),c>g&&(c=g)):c=g;var v=n.length;if(v%2!==0)throw new TypeError("Invalid hex string");c>v/2&&(c=v/2);for(var m=0;m<c;++m){var E=parseInt(n.substr(m*2,2),16);if(isNaN(E))return m;h[i+m]=E}return m}function L(h,n,i,c){return me(ve(n,h.length-i),h,i,c)}function O(h,n,i,c){return me(Bt(n),h,i,c)}function J(h,n,i,c){return O(h,n,i,c)}function z(h,n,i,c){return me(je(n),h,i,c)}function re(h,n,i,c){return me(bt(n,h.length-i),h,i,c)}u.prototype.write=function(n,i,c,g){if(i===void 0)g="utf8",c=this.length,i=0;else if(c===void 0&&typeof i=="string")g=i,c=this.length,i=0;else if(isFinite(i))i=i|0,isFinite(c)?(c=c|0,g===void 0&&(g="utf8")):(g=c,c=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var v=this.length-i;if((c===void 0||c>v)&&(c=v),n.length>0&&(c<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");for(var m=!1;;)switch(g){case"hex":return te(this,n,i,c);case"utf8":case"utf-8":return L(this,n,i,c);case"ascii":return O(this,n,i,c);case"latin1":case"binary":return J(this,n,i,c);case"base64":return z(this,n,i,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return re(this,n,i,c);default:if(m)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),m=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function $(h,n,i){return n===0&&i===h.length?t.fromByteArray(h):t.fromByteArray(h.slice(n,i))}function ne(h,n,i){i=Math.min(h.length,i);for(var c=[],g=n;g<i;){var v=h[g],m=null,E=v>239?4:v>223?3:v>191?2:1;if(g+E<=i){var x,_,B,R;switch(E){case 1:v<128&&(m=v);break;case 2:x=h[g+1],(x&192)===128&&(R=(v&31)<<6|x&63,R>127&&(m=R));break;case 3:x=h[g+1],_=h[g+2],(x&192)===128&&(_&192)===128&&(R=(v&15)<<12|(x&63)<<6|_&63,R>2047&&(R<55296||R>57343)&&(m=R));break;case 4:x=h[g+1],_=h[g+2],B=h[g+3],(x&192)===128&&(_&192)===128&&(B&192)===128&&(R=(v&15)<<18|(x&63)<<12|(_&63)<<6|B&63,R>65535&&R<1114112&&(m=R))}}m===null?(m=65533,E=1):m>65535&&(m-=65536,c.push(m>>>10&1023|55296),m=56320|m&1023),c.push(m),g+=E}return Ce(c)}var G=4096;function Ce(h){var n=h.length;if(n<=G)return String.fromCharCode.apply(String,h);for(var i="",c=0;c<n;)i+=String.fromCharCode.apply(String,h.slice(c,c+=G));return i}function Tt(h,n,i){var c="";i=Math.min(h.length,i);for(var g=n;g<i;++g)c+=String.fromCharCode(h[g]&127);return c}function Dt(h,n,i){var c="";i=Math.min(h.length,i);for(var g=n;g<i;++g)c+=String.fromCharCode(h[g]);return c}function xt(h,n,i){var c=h.length;(!n||n<0)&&(n=0),(!i||i<0||i>c)&&(i=c);for(var g="",v=n;v<i;++v)g+=Ft(h[v]);return g}function It(h,n,i){for(var c=h.slice(n,i),g="",v=0;v<c.length;v+=2)g+=String.fromCharCode(c[v]+c[v+1]*256);return g}u.prototype.slice=function(n,i){var c=this.length;n=~~n,i=i===void 0?c:~~i,n<0?(n+=c,n<0&&(n=0)):n>c&&(n=c),i<0?(i+=c,i<0&&(i=0)):i>c&&(i=c),i<n&&(i=n);var g;if(u.TYPED_ARRAY_SUPPORT)g=this.subarray(n,i),g.__proto__=u.prototype;else{var v=i-n;g=new u(v,void 0);for(var m=0;m<v;++m)g[m]=this[m+n]}return g};function F(h,n,i){if(h%1!==0||h<0)throw new RangeError("offset is not uint");if(h+n>i)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUIntLE=function(n,i,c){n=n|0,i=i|0,c||F(n,i,this.length);for(var g=this[n],v=1,m=0;++m<i&&(v*=256);)g+=this[n+m]*v;return g},u.prototype.readUIntBE=function(n,i,c){n=n|0,i=i|0,c||F(n,i,this.length);for(var g=this[n+--i],v=1;i>0&&(v*=256);)g+=this[n+--i]*v;return g},u.prototype.readUInt8=function(n,i){return i||F(n,1,this.length),this[n]},u.prototype.readUInt16LE=function(n,i){return i||F(n,2,this.length),this[n]|this[n+1]<<8},u.prototype.readUInt16BE=function(n,i){return i||F(n,2,this.length),this[n]<<8|this[n+1]},u.prototype.readUInt32LE=function(n,i){return i||F(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},u.prototype.readUInt32BE=function(n,i){return i||F(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},u.prototype.readIntLE=function(n,i,c){n=n|0,i=i|0,c||F(n,i,this.length);for(var g=this[n],v=1,m=0;++m<i&&(v*=256);)g+=this[n+m]*v;return v*=128,g>=v&&(g-=Math.pow(2,8*i)),g},u.prototype.readIntBE=function(n,i,c){n=n|0,i=i|0,c||F(n,i,this.length);for(var g=i,v=1,m=this[n+--g];g>0&&(v*=256);)m+=this[n+--g]*v;return v*=128,m>=v&&(m-=Math.pow(2,8*i)),m},u.prototype.readInt8=function(n,i){return i||F(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},u.prototype.readInt16LE=function(n,i){i||F(n,2,this.length);var c=this[n]|this[n+1]<<8;return c&32768?c|4294901760:c},u.prototype.readInt16BE=function(n,i){i||F(n,2,this.length);var c=this[n+1]|this[n]<<8;return c&32768?c|4294901760:c},u.prototype.readInt32LE=function(n,i){return i||F(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},u.prototype.readInt32BE=function(n,i){return i||F(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},u.prototype.readFloatLE=function(n,i){return i||F(n,4,this.length),r.read(this,n,!0,23,4)},u.prototype.readFloatBE=function(n,i){return i||F(n,4,this.length),r.read(this,n,!1,23,4)},u.prototype.readDoubleLE=function(n,i){return i||F(n,8,this.length),r.read(this,n,!0,52,8)},u.prototype.readDoubleBE=function(n,i){return i||F(n,8,this.length),r.read(this,n,!1,52,8)};function M(h,n,i,c,g,v){if(!u.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>g||n<v)throw new RangeError('"value" argument is out of bounds');if(i+c>h.length)throw new RangeError("Index out of range")}u.prototype.writeUIntLE=function(n,i,c,g){if(n=+n,i=i|0,c=c|0,!g){var v=Math.pow(2,8*c)-1;M(this,n,i,c,v,0)}var m=1,E=0;for(this[i]=n&255;++E<c&&(m*=256);)this[i+E]=n/m&255;return i+c},u.prototype.writeUIntBE=function(n,i,c,g){if(n=+n,i=i|0,c=c|0,!g){var v=Math.pow(2,8*c)-1;M(this,n,i,c,v,0)}var m=c-1,E=1;for(this[i+m]=n&255;--m>=0&&(E*=256);)this[i+m]=n/E&255;return i+c},u.prototype.writeUInt8=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,1,255,0),u.TYPED_ARRAY_SUPPORT||(n=Math.floor(n)),this[i]=n&255,i+1};function ge(h,n,i,c){n<0&&(n=65535+n+1);for(var g=0,v=Math.min(h.length-i,2);g<v;++g)h[i+g]=(n&255<<8*(c?g:1-g))>>>(c?g:1-g)*8}u.prototype.writeUInt16LE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[i]=n&255,this[i+1]=n>>>8):ge(this,n,i,!0),i+2},u.prototype.writeUInt16BE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[i]=n>>>8,this[i+1]=n&255):ge(this,n,i,!1),i+2};function de(h,n,i,c){n<0&&(n=4294967295+n+1);for(var g=0,v=Math.min(h.length-i,4);g<v;++g)h[i+g]=n>>>(c?g:3-g)*8&255}u.prototype.writeUInt32LE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[i+3]=n>>>24,this[i+2]=n>>>16,this[i+1]=n>>>8,this[i]=n&255):de(this,n,i,!0),i+4},u.prototype.writeUInt32BE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[i]=n>>>24,this[i+1]=n>>>16,this[i+2]=n>>>8,this[i+3]=n&255):de(this,n,i,!1),i+4},u.prototype.writeIntLE=function(n,i,c,g){if(n=+n,i=i|0,!g){var v=Math.pow(2,8*c-1);M(this,n,i,c,v-1,-v)}var m=0,E=1,x=0;for(this[i]=n&255;++m<c&&(E*=256);)n<0&&x===0&&this[i+m-1]!==0&&(x=1),this[i+m]=(n/E>>0)-x&255;return i+c},u.prototype.writeIntBE=function(n,i,c,g){if(n=+n,i=i|0,!g){var v=Math.pow(2,8*c-1);M(this,n,i,c,v-1,-v)}var m=c-1,E=1,x=0;for(this[i+m]=n&255;--m>=0&&(E*=256);)n<0&&x===0&&this[i+m+1]!==0&&(x=1),this[i+m]=(n/E>>0)-x&255;return i+c},u.prototype.writeInt8=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,1,127,-128),u.TYPED_ARRAY_SUPPORT||(n=Math.floor(n)),n<0&&(n=255+n+1),this[i]=n&255,i+1},u.prototype.writeInt16LE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[i]=n&255,this[i+1]=n>>>8):ge(this,n,i,!0),i+2},u.prototype.writeInt16BE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[i]=n>>>8,this[i+1]=n&255):ge(this,n,i,!1),i+2},u.prototype.writeInt32LE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[i]=n&255,this[i+1]=n>>>8,this[i+2]=n>>>16,this[i+3]=n>>>24):de(this,n,i,!0),i+4},u.prototype.writeInt32BE=function(n,i,c){return n=+n,i=i|0,c||M(this,n,i,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),u.TYPED_ARRAY_SUPPORT?(this[i]=n>>>24,this[i+1]=n>>>16,this[i+2]=n>>>8,this[i+3]=n&255):de(this,n,i,!1),i+4};function qe(h,n,i,c,g,v){if(i+c>h.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function Ve(h,n,i,c,g){return g||qe(h,n,i,4),r.write(h,n,i,c,23,4),i+4}u.prototype.writeFloatLE=function(n,i,c){return Ve(this,n,i,!0,c)},u.prototype.writeFloatBE=function(n,i,c){return Ve(this,n,i,!1,c)};function Le(h,n,i,c,g){return g||qe(h,n,i,8),r.write(h,n,i,c,52,8),i+8}u.prototype.writeDoubleLE=function(n,i,c){return Le(this,n,i,!0,c)},u.prototype.writeDoubleBE=function(n,i,c){return Le(this,n,i,!1,c)},u.prototype.copy=function(n,i,c,g){if(c||(c=0),!g&&g!==0&&(g=this.length),i>=n.length&&(i=n.length),i||(i=0),g>0&&g<c&&(g=c),g===c||n.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(c<0||c>=this.length)throw new RangeError("sourceStart out of bounds");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),n.length-i<g-c&&(g=n.length-i+c);var v=g-c,m;if(this===n&&c<i&&i<g)for(m=v-1;m>=0;--m)n[m+i]=this[m+c];else if(v<1e3||!u.TYPED_ARRAY_SUPPORT)for(m=0;m<v;++m)n[m+i]=this[m+c];else Uint8Array.prototype.set.call(n,this.subarray(c,c+v),i);return v},u.prototype.fill=function(n,i,c,g){if(typeof n=="string"){if(typeof i=="string"?(g=i,i=0,c=this.length):typeof c=="string"&&(g=c,c=this.length),n.length===1){var v=n.charCodeAt(0);v<256&&(n=v)}if(g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!u.isEncoding(g))throw new TypeError("Unknown encoding: "+g)}else typeof n=="number"&&(n=n&255);if(i<0||this.length<i||this.length<c)throw new RangeError("Out of range index");if(c<=i)return this;i=i>>>0,c=c===void 0?this.length:c>>>0,n||(n=0);var m;if(typeof n=="number")for(m=i;m<c;++m)this[m]=n;else{var E=u.isBuffer(n)?n:ve(new u(n,g).toString()),x=E.length;for(m=0;m<c-i;++m)this[m+i]=E[m%x]}return this};var _t=/[^+\/0-9A-Za-z-_]/g;function Rt(h){if(h=Pt(h).replace(_t,""),h.length<2)return"";for(;h.length%4!==0;)h=h+"=";return h}function Pt(h){return h.trim?h.trim():h.replace(/^\s+|\s+$/g,"")}function Ft(h){return h<16?"0"+h.toString(16):h.toString(16)}function ve(h,n){n=n||1/0;for(var i,c=h.length,g=null,v=[],m=0;m<c;++m){if(i=h.charCodeAt(m),i>55295&&i<57344){if(!g){if(i>56319){(n-=3)>-1&&v.push(239,191,189);continue}else if(m+1===c){(n-=3)>-1&&v.push(239,191,189);continue}g=i;continue}if(i<56320){(n-=3)>-1&&v.push(239,191,189),g=i;continue}i=(g-55296<<10|i-56320)+65536}else g&&(n-=3)>-1&&v.push(239,191,189);if(g=null,i<128){if((n-=1)<0)break;v.push(i)}else if(i<2048){if((n-=2)<0)break;v.push(i>>6|192,i&63|128)}else if(i<65536){if((n-=3)<0)break;v.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((n-=4)<0)break;v.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return v}function Bt(h){for(var n=[],i=0;i<h.length;++i)n.push(h.charCodeAt(i)&255);return n}function bt(h,n){for(var i,c,g,v=[],m=0;m<h.length&&!((n-=2)<0);++m)i=h.charCodeAt(m),c=i>>8,g=i%256,v.push(g),v.push(c);return v}function je(h){return t.toByteArray(Rt(h))}function me(h,n,i,c){for(var g=0;g<c&&!(g+i>=n.length||g>=h.length);++g)n[g+i]=h[g];return g}function Mt(h){return h!==h}})(Ae)),Ae}var I=Vt(),q;typeof window<"u"&&window.crypto&&(q=window.crypto);!q&&typeof window<"u"&&window.msCrypto&&(q=window.msCrypto);!q&&typeof global<"u"&&global.crypto&&(q=global.crypto);if(!q&&typeof Kt=="function")try{q=kt}catch{}function Lt(){if(q){if(typeof q.getRandomValues=="function")try{return q.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof q.randomBytes=="function")try{return q.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")}function jt(o){for(var t=o.words,r=o.sigBytes,e=[],a=0;a<r;a++){var s=t[a>>>2]>>>24-a%4*8&255;e.push((s>>>4).toString(16)),e.push((s&15).toString(16))}return e.join("")}var Ht=(function(){function o(r,e){r=this.words=r||[],e!=null?this.sigBytes=e:this.sigBytes=r.length*4}var t=o.prototype;return t.random=function(e){for(var a=[],s=0;s<e;s+=4)a.push(Lt());return new o(a,e)},t.toString=function(){return jt(this)},o})(),Ee={};/*! *****************************************************************************
|
|
10
10
|
Copyright (c) Microsoft Corporation.
|
|
11
11
|
|
|
12
12
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -46,13 +46,13 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
46
46
|
*/var Z={},An=(function(){function o(){}return o.setItem=function(r,e){return Z[r]=e,Z[r]},o.getItem=function(r){return Object.prototype.hasOwnProperty.call(Z,r)?Z[r]:void 0},o.removeItem=function(r){return delete Z[r]},o.clear=function(){return Z={},Z},o})(),At=(function(){function o(){try{this.storageWindow=window.localStorage,this.storageWindow.setItem("aws.cognito.test-ls",1),this.storageWindow.removeItem("aws.cognito.test-ls")}catch{this.storageWindow=An}}var t=o.prototype;return t.getStorage=function(){return this.storageWindow},o})();/*!
|
|
47
47
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
48
48
|
* SPDX-License-Identifier: Apache-2.0
|
|
49
|
-
*/var Un=typeof navigator<"u",lt=Un?Ct.isReactNative?"react-native":navigator.userAgent:"nodejs",pt=(function(){function o(r){if(r==null||r.Username==null||r.Pool==null)throw new Error("Username and Pool information are required.");this.username=r.Username||"",this.pool=r.Pool,this.Session=null,this.client=r.Pool.client,this.signInUserSession=null,this.authenticationFlowType="USER_SRP_AUTH",this.storage=r.Storage||new At().getStorage(),this.keyPrefix="CognitoIdentityServiceProvider."+this.pool.getClientId(),this.userDataKey=this.keyPrefix+"."+this.username+".userData"}var t=o.prototype;return t.setSignInUserSession=function(e){this.clearCachedUserData(),this.signInUserSession=e,this.cacheTokens()},t.getSignInUserSession=function(){return this.signInUserSession},t.getUsername=function(){return this.username},t.getAuthenticationFlowType=function(){return this.authenticationFlowType},t.setAuthenticationFlowType=function(e){this.authenticationFlowType=e},t.initiateAuth=function(e,a){var s=this,f=e.getAuthParameters();f.USERNAME=this.username;var u=Object.keys(e.getValidationData()).length!==0?e.getValidationData():e.getClientMetadata(),l={AuthFlow:"CUSTOM_AUTH",ClientId:this.pool.getClientId(),AuthParameters:f,ClientMetadata:u};this.getUserContextData()&&(l.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",l,function(p,d){if(p)return a.onFailure(p);var y=d.ChallengeName,S=d.ChallengeParameters;return y==="CUSTOM_CHALLENGE"?(s.Session=d.Session,a.customChallenge(S)):(s.signInUserSession=s.getCognitoUserSession(d.AuthenticationResult),s.cacheTokens(),a.onSuccess(s.signInUserSession))})},t.authenticateUser=function(e,a){return this.authenticationFlowType==="USER_PASSWORD_AUTH"?this.authenticateUserPlainUsernamePassword(e,a):this.authenticationFlowType==="USER_SRP_AUTH"||this.authenticationFlowType==="CUSTOM_AUTH"?this.authenticateUserDefaultAuth(e,a):a.onFailure(new Error("Authentication flow type is invalid."))},t.authenticateUserDefaultAuth=function(e,a){var s=this,f=new X(this.pool.getUserPoolName()),u=new ct,l,p,d={};this.deviceKey!=null&&(d.DEVICE_KEY=this.deviceKey),d.USERNAME=this.username,f.getLargeAValue(function(y,S){y&&a.onFailure(y),d.SRP_A=S.toString(16),s.authenticationFlowType==="CUSTOM_AUTH"&&(d.CHALLENGE_NAME="SRP_A");var U=Object.keys(e.getValidationData()).length!==0?e.getValidationData():e.getClientMetadata(),A={AuthFlow:s.authenticationFlowType,ClientId:s.pool.getClientId(),AuthParameters:d,ClientMetadata:U};s.getUserContextData(s.username)&&(A.UserContextData=s.getUserContextData(s.username)),s.client.request("InitiateAuth",A,function(C,D){if(C)return a.onFailure(C);var T=D.ChallengeParameters;s.username=T.USER_ID_FOR_SRP,s.userDataKey=s.keyPrefix+"."+s.username+".userData",l=new w(T.SRP_B,16),p=new w(T.SALT,16),s.getCachedDeviceKeyAndPassword(),f.getPasswordAuthenticationKey(s.username,e.getPassword(),l,p,function(P,j){P&&a.onFailure(P);var k=u.getNowString(),Y=I.Buffer.concat([I.Buffer.from(s.pool.getUserPoolName(),"utf8"),I.Buffer.from(s.username,"utf8"),I.Buffer.from(T.SECRET_BLOCK,"base64"),I.Buffer.from(k,"utf8")]),W=new ce.Sha256(j);W.update(Y);var te=W.digestSync(),L=I.Buffer.from(te).toString("base64"),O={};O.USERNAME=s.username,O.PASSWORD_CLAIM_SECRET_BLOCK=T.SECRET_BLOCK,O.TIMESTAMP=k,O.PASSWORD_CLAIM_SIGNATURE=L,s.deviceKey!=null&&(O.DEVICE_KEY=s.deviceKey);var J=function($,ne){return s.client.request("RespondToAuthChallenge",$,function(G,Ce){return G&&G.code==="ResourceNotFoundException"&&G.message.toLowerCase().indexOf("device")!==-1?(O.DEVICE_KEY=null,s.deviceKey=null,s.randomPassword=null,s.deviceGroupKey=null,s.clearCachedDeviceKeyAndPassword(),J($,ne)):ne(G,Ce)})},z={ChallengeName:"PASSWORD_VERIFIER",ClientId:s.pool.getClientId(),ChallengeResponses:O,Session:D.Session,ClientMetadata:U};s.getUserContextData()&&(z.UserContextData=s.getUserContextData()),J(z,function(re,$){return re?a.onFailure(re):s.authenticateUserInternal($,f,a)})})})})},t.authenticateUserPlainUsernamePassword=function(e,a){var s=this,f={};if(f.USERNAME=this.username,f.PASSWORD=e.getPassword(),!f.PASSWORD){a.onFailure(new Error("PASSWORD parameter is required"));return}var u=new X(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),this.deviceKey!=null&&(f.DEVICE_KEY=this.deviceKey);var l=Object.keys(e.getValidationData()).length!==0?e.getValidationData():e.getClientMetadata(),p={AuthFlow:"USER_PASSWORD_AUTH",ClientId:this.pool.getClientId(),AuthParameters:f,ClientMetadata:l};this.getUserContextData(this.username)&&(p.UserContextData=this.getUserContextData(this.username)),this.client.request("InitiateAuth",p,function(d,y){return d?a.onFailure(d):s.authenticateUserInternal(y,u,a)})},t.authenticateUserInternal=function(e,a,s){var f=this,u=e.ChallengeName,l=e.ChallengeParameters;if(u==="SMS_MFA")return this.Session=e.Session,s.mfaRequired(u,l);if(u==="SELECT_MFA_TYPE")return this.Session=e.Session,s.selectMFAType(u,l);if(u==="MFA_SETUP")return this.Session=e.Session,s.mfaSetup(u,l);if(u==="SOFTWARE_TOKEN_MFA")return this.Session=e.Session,s.totpRequired(u,l);if(u==="CUSTOM_CHALLENGE")return this.Session=e.Session,s.customChallenge(l);if(u==="NEW_PASSWORD_REQUIRED"){this.Session=e.Session;var p=null,d=null,y=[],S=a.getNewPasswordRequiredChallengeUserAttributePrefix();if(l&&(p=JSON.parse(e.ChallengeParameters.userAttributes),d=JSON.parse(e.ChallengeParameters.requiredAttributes)),d)for(var U=0;U<d.length;U++)y[U]=d[U].substr(S.length);return s.newPasswordRequired(p,y)}if(u==="DEVICE_SRP_AUTH"){this.Session=e.Session,this.getDeviceResponse(s);return}this.signInUserSession=this.getCognitoUserSession(e.AuthenticationResult),this.challengeName=u,this.cacheTokens();var A=e.AuthenticationResult.NewDeviceMetadata;if(A==null)return s.onSuccess(this.signInUserSession);a.generateHashDevice(e.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,e.AuthenticationResult.NewDeviceMetadata.DeviceKey,function(C){if(C)return s.onFailure(C);var D={Salt:I.Buffer.from(a.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:I.Buffer.from(a.getVerifierDevices(),"hex").toString("base64")};f.verifierDevices=D.PasswordVerifier,f.deviceGroupKey=A.DeviceGroupKey,f.randomPassword=a.getRandomPassword(),f.client.request("ConfirmDevice",{DeviceKey:A.DeviceKey,AccessToken:f.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:D,DeviceName:lt},function(T,P){return T?s.onFailure(T):(f.deviceKey=e.AuthenticationResult.NewDeviceMetadata.DeviceKey,f.cacheDeviceKeyAndPassword(),P.UserConfirmationNecessary===!0?s.onSuccess(f.signInUserSession,P.UserConfirmationNecessary):s.onSuccess(f.signInUserSession))})})},t.completeNewPasswordChallenge=function(e,a,s,f){var u=this;if(!e)return s.onFailure(new Error("New password is required."));var l=new X(this.pool.getUserPoolName()),p=l.getNewPasswordRequiredChallengeUserAttributePrefix(),d={};a&&Object.keys(a).forEach(function(S){d[p+S]=a[S]}),d.NEW_PASSWORD=e,d.USERNAME=this.username;var y={ChallengeName:"NEW_PASSWORD_REQUIRED",ClientId:this.pool.getClientId(),ChallengeResponses:d,Session:this.Session,ClientMetadata:f};this.getUserContextData()&&(y.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",y,function(S,U){return S?s.onFailure(S):u.authenticateUserInternal(U,l,s)})},t.getDeviceResponse=function(e,a){var s=this,f=new X(this.deviceGroupKey),u=new ct,l={};l.USERNAME=this.username,l.DEVICE_KEY=this.deviceKey,f.getLargeAValue(function(p,d){p&&e.onFailure(p),l.SRP_A=d.toString(16);var y={ChallengeName:"DEVICE_SRP_AUTH",ClientId:s.pool.getClientId(),ChallengeResponses:l,ClientMetadata:a,Session:s.Session};s.getUserContextData()&&(y.UserContextData=s.getUserContextData()),s.client.request("RespondToAuthChallenge",y,function(S,U){if(S)return e.onFailure(S);var A=U.ChallengeParameters,C=new w(A.SRP_B,16),D=new w(A.SALT,16);f.getPasswordAuthenticationKey(s.deviceKey,s.randomPassword,C,D,function(T,P){if(T)return e.onFailure(T);var j=u.getNowString(),k=I.Buffer.concat([I.Buffer.from(s.deviceGroupKey,"utf8"),I.Buffer.from(s.deviceKey,"utf8"),I.Buffer.from(A.SECRET_BLOCK,"base64"),I.Buffer.from(j,"utf8")]),Y=new ce.Sha256(P);Y.update(k);var W=Y.digestSync(),te=I.Buffer.from(W).toString("base64"),L={};L.USERNAME=s.username,L.PASSWORD_CLAIM_SECRET_BLOCK=A.SECRET_BLOCK,L.TIMESTAMP=j,L.PASSWORD_CLAIM_SIGNATURE=te,L.DEVICE_KEY=s.deviceKey;var O={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:s.pool.getClientId(),ChallengeResponses:L,Session:U.Session};s.getUserContextData()&&(O.UserContextData=s.getUserContextData()),s.client.request("RespondToAuthChallenge",O,function(J,z){return J?e.onFailure(J):(s.signInUserSession=s.getCognitoUserSession(z.AuthenticationResult),s.cacheTokens(),e.onSuccess(s.signInUserSession))})})})})},t.confirmRegistration=function(e,a,s,f){var u={ClientId:this.pool.getClientId(),ConfirmationCode:e,Username:this.username,ForceAliasCreation:a,ClientMetadata:f};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("ConfirmSignUp",u,function(l){return l?s(l,null):s(null,"SUCCESS")})},t.sendCustomChallengeAnswer=function(e,a,s){var f=this,u={};u.USERNAME=this.username,u.ANSWER=e;var l=new X(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),this.deviceKey!=null&&(u.DEVICE_KEY=this.deviceKey);var p={ChallengeName:"CUSTOM_CHALLENGE",ChallengeResponses:u,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:s};this.getUserContextData()&&(p.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",p,function(d,y){return d?a.onFailure(d):f.authenticateUserInternal(y,l,a)})},t.sendMFACode=function(e,a,s,f){var u=this,l={};l.USERNAME=this.username,l.SMS_MFA_CODE=e;var p=s||"SMS_MFA";p==="SOFTWARE_TOKEN_MFA"&&(l.SOFTWARE_TOKEN_MFA_CODE=e),this.deviceKey!=null&&(l.DEVICE_KEY=this.deviceKey);var d={ChallengeName:p,ChallengeResponses:l,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:f};this.getUserContextData()&&(d.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",d,function(y,S){if(y)return a.onFailure(y);var U=S.ChallengeName;if(U==="DEVICE_SRP_AUTH"){u.getDeviceResponse(a);return}if(u.signInUserSession=u.getCognitoUserSession(S.AuthenticationResult),u.cacheTokens(),S.AuthenticationResult.NewDeviceMetadata==null)return a.onSuccess(u.signInUserSession);var A=new X(u.pool.getUserPoolName());A.generateHashDevice(S.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,S.AuthenticationResult.NewDeviceMetadata.DeviceKey,function(C){if(C)return a.onFailure(C);var D={Salt:I.Buffer.from(A.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:I.Buffer.from(A.getVerifierDevices(),"hex").toString("base64")};u.verifierDevices=D.PasswordVerifier,u.deviceGroupKey=S.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,u.randomPassword=A.getRandomPassword(),u.client.request("ConfirmDevice",{DeviceKey:S.AuthenticationResult.NewDeviceMetadata.DeviceKey,AccessToken:u.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:D,DeviceName:lt},function(T,P){return T?a.onFailure(T):(u.deviceKey=S.AuthenticationResult.NewDeviceMetadata.DeviceKey,u.cacheDeviceKeyAndPassword(),P.UserConfirmationNecessary===!0?a.onSuccess(u.signInUserSession,P.UserConfirmationNecessary):a.onSuccess(u.signInUserSession))})})})},t.changePassword=function(e,a,s,f){if(!(this.signInUserSession!=null&&this.signInUserSession.isValid()))return s(new Error("User is not authenticated"),null);this.client.request("ChangePassword",{PreviousPassword:e,ProposedPassword:a,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:f},function(u){return u?s(u,null):s(null,"SUCCESS")})},t.enableMFA=function(e){if(this.signInUserSession==null||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);var a=[],s={DeliveryMedium:"SMS",AttributeName:"phone_number"};a.push(s),this.client.request("SetUserSettings",{MFAOptions:a,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(f){return f?e(f,null):e(null,"SUCCESS")})},t.setUserMfaPreference=function(e,a,s){if(this.signInUserSession==null||!this.signInUserSession.isValid())return s(new Error("User is not authenticated"),null);this.client.request("SetUserMFAPreference",{SMSMfaSettings:e,SoftwareTokenMfaSettings:a,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(f){return f?s(f,null):s(null,"SUCCESS")})},t.disableMFA=function(e){if(this.signInUserSession==null||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);var a=[];this.client.request("SetUserSettings",{MFAOptions:a,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(s){return s?e(s,null):e(null,"SUCCESS")})},t.deleteUser=function(e,a){var s=this;if(this.signInUserSession==null||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("DeleteUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:a},function(f){return f?e(f,null):(s.clearCachedUser(),e(null,"SUCCESS"))})},t.updateAttributes=function(e,a,s){var f=this;if(this.signInUserSession==null||!this.signInUserSession.isValid())return a(new Error("User is not authenticated"),null);this.client.request("UpdateUserAttributes",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserAttributes:e,ClientMetadata:s},function(u,l){return u?a(u,null):f.getUserData(function(){return a(null,"SUCCESS",l)},{bypassCache:!0})})},t.getUserAttributes=function(e){if(!(this.signInUserSession!=null&&this.signInUserSession.isValid()))return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(a,s){if(a)return e(a,null);for(var f=[],u=0;u<s.UserAttributes.length;u++){var l={Name:s.UserAttributes[u].Name,Value:s.UserAttributes[u].Value},p=new Cn(l);f.push(p)}return e(null,f)})},t.getMFAOptions=function(e){if(!(this.signInUserSession!=null&&this.signInUserSession.isValid()))return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(a,s){return a?e(a,null):e(null,s.MFAOptions)})},t.createGetUserRequest=function(){return this.client.promisifyRequest("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()})},t.refreshSessionIfPossible=function(e){var a=this;return e===void 0&&(e={}),new Promise(function(s){var f=a.signInUserSession.getRefreshToken();f&&f.getToken()?a.refreshSession(f,s,e.clientMetadata):s()})},t.getUserData=function(e,a){var s=this;if(!(this.signInUserSession!=null&&this.signInUserSession.isValid()))return this.clearCachedUserData(),e(new Error("User is not authenticated"),null);var f=this.getUserDataFromCache();if(!f){this.fetchUserData().then(function(u){e(null,u)}).catch(e);return}if(this.isFetchUserDataAndTokenRequired(a)){this.fetchUserData().then(function(u){return s.refreshSessionIfPossible(a).then(function(){return u})}).then(function(u){return e(null,u)}).catch(e);return}try{e(null,JSON.parse(f));return}catch(u){this.clearCachedUserData(),e(u,null);return}},t.getUserDataFromCache=function(){var e=this.storage.getItem(this.userDataKey);return e},t.isFetchUserDataAndTokenRequired=function(e){var a=e||{},s=a.bypassCache,f=s===void 0?!1:s;return f},t.fetchUserData=function(){var e=this;return this.createGetUserRequest().then(function(a){return e.cacheUserData(a),a})},t.deleteAttributes=function(e,a){var s=this;if(!(this.signInUserSession!=null&&this.signInUserSession.isValid()))return a(new Error("User is not authenticated"),null);this.client.request("DeleteUserAttributes",{UserAttributeNames:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(f){return f?a(f,null):s.getUserData(function(){return a(null,"SUCCESS")},{bypassCache:!0})})},t.resendConfirmationCode=function(e,a){var s={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:a};this.client.request("ResendConfirmationCode",s,function(f,u){return f?e(f,null):e(null,u)})},t.getSession=function(e,a){if(a===void 0&&(a={}),this.username==null)return e(new Error("Username is null. Cannot retrieve a new session"),null);if(this.signInUserSession!=null&&this.signInUserSession.isValid())return e(null,this.signInUserSession);var s="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,f=s+".idToken",u=s+".accessToken",l=s+".refreshToken",p=s+".clockDrift";if(this.storage.getItem(f)){var d=new ut({IdToken:this.storage.getItem(f)}),y=new at({AccessToken:this.storage.getItem(u)}),S=new ft({RefreshToken:this.storage.getItem(l)}),U=parseInt(this.storage.getItem(p),0)||0,A={IdToken:d,AccessToken:y,RefreshToken:S,ClockDrift:U},C=new ht(A);if(C.isValid())return this.signInUserSession=C,e(null,this.signInUserSession);if(!S.getToken())return e(new Error("Cannot retrieve a new session. Please authenticate."),null);this.refreshSession(S,e,a.clientMetadata)}else e(new Error("Local storage is missing an ID Token, Please authenticate"),null)},t.refreshSession=function(e,a,s){var f=this,u=this.pool.wrapRefreshSessionCallback?this.pool.wrapRefreshSessionCallback(a):a,l={};l.REFRESH_TOKEN=e.getToken();var p="CognitoIdentityServiceProvider."+this.pool.getClientId(),d=p+".LastAuthUser";if(this.storage.getItem(d)){this.username=this.storage.getItem(d);var y=p+"."+this.username+".deviceKey";this.deviceKey=this.storage.getItem(y),l.DEVICE_KEY=this.deviceKey}var S={ClientId:this.pool.getClientId(),AuthFlow:"REFRESH_TOKEN_AUTH",AuthParameters:l,ClientMetadata:s};this.getUserContextData()&&(S.UserContextData=this.getUserContextData()),this.client.requestWithRetry("InitiateAuth",S,function(U,A){if(U)return U.code==="NotAuthorizedException"&&f.clearCachedUser(),u(U,null);if(A){var C=A.AuthenticationResult;return Object.prototype.hasOwnProperty.call(C,"RefreshToken")||(C.RefreshToken=e.getToken()),f.signInUserSession=f.getCognitoUserSession(C),f.cacheTokens(),u(null,f.signInUserSession)}})},t.cacheTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),a=e+"."+this.username+".idToken",s=e+"."+this.username+".accessToken",f=e+"."+this.username+".refreshToken",u=e+"."+this.username+".clockDrift",l=e+".LastAuthUser";this.storage.setItem(a,this.signInUserSession.getIdToken().getJwtToken()),this.storage.setItem(s,this.signInUserSession.getAccessToken().getJwtToken()),this.storage.setItem(f,this.signInUserSession.getRefreshToken().getToken()),this.storage.setItem(u,""+this.signInUserSession.getClockDrift()),this.storage.setItem(l,this.username)},t.cacheUserData=function(e){this.storage.setItem(this.userDataKey,JSON.stringify(e))},t.clearCachedUserData=function(){this.storage.removeItem(this.userDataKey)},t.clearCachedUser=function(){this.clearCachedTokens(),this.clearCachedUserData()},t.cacheDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,a=e+".deviceKey",s=e+".randomPasswordKey",f=e+".deviceGroupKey";this.storage.setItem(a,this.deviceKey),this.storage.setItem(s,this.randomPassword),this.storage.setItem(f,this.deviceGroupKey)},t.getCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,a=e+".deviceKey",s=e+".randomPasswordKey",f=e+".deviceGroupKey";this.storage.getItem(a)&&(this.deviceKey=this.storage.getItem(a),this.randomPassword=this.storage.getItem(s),this.deviceGroupKey=this.storage.getItem(f))},t.clearCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,a=e+".deviceKey",s=e+".randomPasswordKey",f=e+".deviceGroupKey";this.storage.removeItem(a),this.storage.removeItem(s),this.storage.removeItem(f)},t.clearCachedTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),a=e+"."+this.username+".idToken",s=e+"."+this.username+".accessToken",f=e+"."+this.username+".refreshToken",u=e+".LastAuthUser",l=e+"."+this.username+".clockDrift";this.storage.removeItem(a),this.storage.removeItem(s),this.storage.removeItem(f),this.storage.removeItem(u),this.storage.removeItem(l)},t.getCognitoUserSession=function(e){var a=new ut(e),s=new at(e),f=new ft(e),u={IdToken:a,AccessToken:s,RefreshToken:f};return new ht(u)},t.forgotPassword=function(e,a){var s={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:a};this.getUserContextData()&&(s.UserContextData=this.getUserContextData()),this.client.request("ForgotPassword",s,function(f,u){return f?e.onFailure(f):typeof e.inputVerificationCode=="function"?e.inputVerificationCode(u):e.onSuccess(u)})},t.confirmPassword=function(e,a,s,f){var u={ClientId:this.pool.getClientId(),Username:this.username,ConfirmationCode:e,Password:a,ClientMetadata:f};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("ConfirmForgotPassword",u,function(l){return l?s.onFailure(l):s.onSuccess("SUCCESS")})},t.getAttributeVerificationCode=function(e,a,s){if(this.signInUserSession==null||!this.signInUserSession.isValid())return a.onFailure(new Error("User is not authenticated"));this.client.request("GetUserAttributeVerificationCode",{AttributeName:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:s},function(f,u){return f?a.onFailure(f):typeof a.inputVerificationCode=="function"?a.inputVerificationCode(u):a.onSuccess("SUCCESS")})},t.verifyAttribute=function(e,a,s){if(this.signInUserSession==null||!this.signInUserSession.isValid())return s.onFailure(new Error("User is not authenticated"));this.client.request("VerifyUserAttribute",{AttributeName:e,Code:a,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(f){return f?s.onFailure(f):s.onSuccess("SUCCESS")})},t.getDevice=function(e){if(this.signInUserSession==null||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey},function(a,s){return a?e.onFailure(a):e.onSuccess(s)})},t.forgetSpecificDevice=function(e,a){if(this.signInUserSession==null||!this.signInUserSession.isValid())return a.onFailure(new Error("User is not authenticated"));this.client.request("ForgetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:e},function(s){return s?a.onFailure(s):a.onSuccess("SUCCESS")})},t.forgetDevice=function(e){var a=this;this.forgetSpecificDevice(this.deviceKey,{onFailure:e.onFailure,onSuccess:function(f){return a.deviceKey=null,a.deviceGroupKey=null,a.randomPassword=null,a.clearCachedDeviceKeyAndPassword(),e.onSuccess(f)}})},t.setDeviceStatusRemembered=function(e){if(this.signInUserSession==null||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"remembered"},function(a){return a?e.onFailure(a):e.onSuccess("SUCCESS")})},t.setDeviceStatusNotRemembered=function(e){if(this.signInUserSession==null||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"not_remembered"},function(a){return a?e.onFailure(a):e.onSuccess("SUCCESS")})},t.listDevices=function(e,a,s){if(this.signInUserSession==null||!this.signInUserSession.isValid())return s.onFailure(new Error("User is not authenticated"));var f={AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),Limit:e};a&&(f.PaginationToken=a),this.client.request("ListDevices",f,function(u,l){return u?s.onFailure(u):s.onSuccess(l)})},t.globalSignOut=function(e){var a=this;if(this.signInUserSession==null||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GlobalSignOut",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(s){return s?e.onFailure(s):(a.clearCachedUser(),e.onSuccess("SUCCESS"))})},t.signOut=function(e){var a=this;if(!e||typeof e!="function"){this.cleanClientData();return}this.getSession(function(s,f){if(s)return e(s);a.revokeTokens(function(u){a.cleanClientData(),e(u)})})},t.revokeTokens=function(e){if(e===void 0&&(e=function(){}),typeof e!="function")throw new Error("Invalid revokeTokenCallback. It should be a function.");if(!this.signInUserSession){var a=new Error("User is not authenticated");return e(a)}if(!this.signInUserSession.getAccessToken()){var s=new Error("No Access token available");return e(s)}var f=this.signInUserSession.getRefreshToken().getToken(),u=this.signInUserSession.getAccessToken();if(this.isSessionRevocable(u)&&f)return this.revokeToken({token:f,callback:e});e()},t.isSessionRevocable=function(e){if(e&&typeof e.decodePayload=="function")try{var a=e.decodePayload(),s=a.origin_jti;return!!s}catch{}return!1},t.cleanClientData=function(){this.signInUserSession=null,this.clearCachedUser()},t.revokeToken=function(e){var a=e.token,s=e.callback;this.client.requestWithRetry("RevokeToken",{Token:a,ClientId:this.pool.getClientId()},function(f){if(f)return s(f);s()})},t.sendMFASelectionAnswer=function(e,a){var s=this,f={};f.USERNAME=this.username,f.ANSWER=e;var u={ChallengeName:"SELECT_MFA_TYPE",ChallengeResponses:f,ClientId:this.pool.getClientId(),Session:this.Session};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",u,function(l,p){if(l)return a.onFailure(l);if(s.Session=p.Session,e==="SMS_MFA")return a.mfaRequired(p.ChallengeName,p.ChallengeParameters);if(e==="SOFTWARE_TOKEN_MFA")return a.totpRequired(p.ChallengeName,p.ChallengeParameters)})},t.getUserContextData=function(){var e=this.pool;return e.getUserContextData(this.username)},t.associateSoftwareToken=function(e){var a=this;this.signInUserSession!=null&&this.signInUserSession.isValid()?this.client.request("AssociateSoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(s,f){return s?e.onFailure(s):e.associateSecretCode(f.SecretCode)}):this.client.request("AssociateSoftwareToken",{Session:this.Session},function(s,f){return s?e.onFailure(s):(a.Session=f.Session,e.associateSecretCode(f.SecretCode))})},t.verifySoftwareToken=function(e,a,s){var f=this;this.signInUserSession!=null&&this.signInUserSession.isValid()?this.client.request("VerifySoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserCode:e,FriendlyDeviceName:a},function(u,l){return u?s.onFailure(u):s.onSuccess(l)}):this.client.request("VerifySoftwareToken",{Session:this.Session,UserCode:e,FriendlyDeviceName:a},function(u,l){if(u)return s.onFailure(u);f.Session=l.Session;var p={};p.USERNAME=f.username;var d={ChallengeName:"MFA_SETUP",ClientId:f.pool.getClientId(),ChallengeResponses:p,Session:f.Session};f.getUserContextData()&&(d.UserContextData=f.getUserContextData()),f.client.request("RespondToAuthChallenge",d,function(y,S){return y?s.onFailure(y):(f.signInUserSession=f.getCognitoUserSession(S.AuthenticationResult),f.cacheTokens(),s.onSuccess(f.signInUserSession))})})},o})();function En(o,t){return t=t||{},new Promise(function(r,e){var a=new XMLHttpRequest,s=[],f=[],u={},l=function(){return{ok:(a.status/100|0)==2,statusText:a.statusText,status:a.status,url:a.responseURL,text:function(){return Promise.resolve(a.responseText)},json:function(){return Promise.resolve(a.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([a.response]))},clone:l,headers:{keys:function(){return s},entries:function(){return f},get:function(d){return u[d.toLowerCase()]},has:function(d){return d.toLowerCase()in u}}}};for(var p in a.open(t.method||"get",o,!0),a.onload=function(){a.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(d,y,S){s.push(y=y.toLowerCase()),f.push([y,S]),u[y]=u[y]?u[y]+","+S:S}),r(l())},a.onerror=e,a.withCredentials=t.credentials=="include",t.headers)a.setRequestHeader(p,t.headers[p]);a.send(t.body||null)})}const Tn=Object.freeze(Object.defineProperty({__proto__:null,default:En},Symbol.toStringTag,{value:"Module"})),gt=Oe(Tn);var xe,dt;function Dn(){return dt||(dt=1,xe=self.fetch||(self.fetch=gt.default||gt)),xe}Dn();function K(){}K.prototype.userAgent=yn();var jn=function(t){t&&(K.prototype.userAgent&&!K.prototype.userAgent.includes(t)&&(K.prototype.userAgent=K.prototype.userAgent.concat(" ",t)),(!K.prototype.userAgent||K.prototype.userAgent==="")&&(K.prototype.userAgent=t))},xn=function(t){var r=K.category?" "+K.category:"",e=K.framework?" framework/"+K.framework:"",a=""+K.prototype.userAgent+r+e;return a};function In(o,t){o.prototype=Object.create(t.prototype),o.prototype.constructor=o,pe(o,t)}function be(o){var t=typeof Map=="function"?new Map:void 0;return be=function(e){if(e===null||!Rn(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(t!==void 0){if(t.has(e))return t.get(e);t.set(e,a)}function a(){return _n(e,arguments,Me(this).constructor)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),pe(a,e)},be(o)}function _n(o,t,r){if(Ut())return Reflect.construct.apply(null,arguments);var e=[null];e.push.apply(e,t);var a=new(o.bind.apply(o,e));return r&&pe(a,r.prototype),a}function Ut(){try{var o=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ut=function(){return!!o})()}function Rn(o){try{return Function.toString.call(o).indexOf("[native code]")!==-1}catch{return typeof o=="function"}}function pe(o,t){return pe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},pe(o,t)}function Me(o){return Me=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Me(o)}var Pn=(function(o){function t(r,e,a,s){var f;return f=o.call(this,r)||this,f.code=e,f.name=a,f.statusCode=s,f}return In(t,o),t})(be(Error)),Fn=(function(){function o(r,e,a){this.endpoint=e||"https://cognito-idp."+r+".amazonaws.com/";var s=a||{},f=s.credentials;this.fetchOptions=f?{credentials:f}:{}}var t=o.prototype;return t.promisifyRequest=function(e,a){var s=this;return new Promise(function(f,u){s.request(e,a,function(l,p){l?u(new Pn(l.message,l.code,l.name,l.statusCode)):f(p)})})},t.requestWithRetry=function(e,a,s){var f=this,u=5*1e3;Mn(function(l){return new Promise(function(p,d){f.request(e,l,function(y,S){y?d(y):p(S)})})},[a],u).then(function(l){return s(null,l)}).catch(function(l){return s(l)})},t.request=function(e,a,s){var f={"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityProviderService."+e,"X-Amz-User-Agent":xn(),"Cache-Control":"no-store"},u=Object.assign({},this.fetchOptions,{headers:f,method:"POST",mode:"cors",body:JSON.stringify(a)}),l;fetch(this.endpoint,u).then(function(p){return l=p,p},function(p){throw p instanceof TypeError?new Error("Network error"):p}).then(function(p){return p.json().catch(function(){return{}})}).then(function(p){if(l.ok)return s(null,p);var d=(p.__type||p.code).split("#").pop(),y=new Error(p.message||p.Message||null);return y.name=d,y.code=d,s(y)}).catch(function(p){if(l&&l.headers&&l.headers.get("x-amzn-errortype"))try{var d=l.headers.get("x-amzn-errortype").split(":")[0],y=new Error(l.status?l.status.toString():null);return y.code=d,y.name=d,y.statusCode=l.status,s(y)}catch{return s(p)}else p instanceof Error&&p.message==="Network error"&&(p.code="NetworkError");return s(p)})},o})(),Se={debug:function(){}},Bn=function(t){var r="nonRetryable";return t&&t[r]};function Et(o,t,r,e){if(e===void 0&&(e=1),typeof o!="function")throw Error("functionToRetry must be a function");return Se.debug(o.name+" attempt #"+e+" with args: "+JSON.stringify(t)),o.apply(void 0,t).catch(function(a){if(Se.debug("error on "+o.name,a),Bn(a))throw Se.debug(o.name+" non retryable error",a),a;var s=r(e,t,a);if(Se.debug(o.name+" retrying in "+s+" ms"),s!==!1)return new Promise(function(f){return setTimeout(f,s)}).then(function(){return Et(o,t,r,e+1)});throw a})}function bn(o){var t=100,r=100;return function(e){var a=Math.pow(2,e)*t+r*Math.random();return a>o?!1:a}}function Mn(o,t,r){return Et(o,t,bn(r))}/*!
|
|
49
|
+
*/var Un=typeof navigator<"u",lt=Un?Ct.isReactNative?"react-native":navigator.userAgent:"nodejs",pt=(function(){function o(r){if(r==null||r.Username==null||r.Pool==null)throw new Error("Username and Pool information are required.");this.username=r.Username||"",this.pool=r.Pool,this.Session=null,this.client=r.Pool.client,this.signInUserSession=null,this.authenticationFlowType="USER_SRP_AUTH",this.storage=r.Storage||new At().getStorage(),this.keyPrefix="CognitoIdentityServiceProvider."+this.pool.getClientId(),this.userDataKey=this.keyPrefix+"."+this.username+".userData"}var t=o.prototype;return t.setSignInUserSession=function(e){this.clearCachedUserData(),this.signInUserSession=e,this.cacheTokens()},t.getSignInUserSession=function(){return this.signInUserSession},t.getUsername=function(){return this.username},t.getAuthenticationFlowType=function(){return this.authenticationFlowType},t.setAuthenticationFlowType=function(e){this.authenticationFlowType=e},t.initiateAuth=function(e,a){var s=this,f=e.getAuthParameters();f.USERNAME=this.username;var u=Object.keys(e.getValidationData()).length!==0?e.getValidationData():e.getClientMetadata(),l={AuthFlow:"CUSTOM_AUTH",ClientId:this.pool.getClientId(),AuthParameters:f,ClientMetadata:u};this.getUserContextData()&&(l.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",l,function(p,d){if(p)return a.onFailure(p);var y=d.ChallengeName,S=d.ChallengeParameters;return y==="CUSTOM_CHALLENGE"?(s.Session=d.Session,a.customChallenge(S)):(s.signInUserSession=s.getCognitoUserSession(d.AuthenticationResult),s.cacheTokens(),a.onSuccess(s.signInUserSession))})},t.authenticateUser=function(e,a){return this.authenticationFlowType==="USER_PASSWORD_AUTH"?this.authenticateUserPlainUsernamePassword(e,a):this.authenticationFlowType==="USER_SRP_AUTH"||this.authenticationFlowType==="CUSTOM_AUTH"?this.authenticateUserDefaultAuth(e,a):a.onFailure(new Error("Authentication flow type is invalid."))},t.authenticateUserDefaultAuth=function(e,a){var s=this,f=new X(this.pool.getUserPoolName()),u=new ct,l,p,d={};this.deviceKey!=null&&(d.DEVICE_KEY=this.deviceKey),d.USERNAME=this.username,f.getLargeAValue(function(y,S){y&&a.onFailure(y),d.SRP_A=S.toString(16),s.authenticationFlowType==="CUSTOM_AUTH"&&(d.CHALLENGE_NAME="SRP_A");var U=Object.keys(e.getValidationData()).length!==0?e.getValidationData():e.getClientMetadata(),A={AuthFlow:s.authenticationFlowType,ClientId:s.pool.getClientId(),AuthParameters:d,ClientMetadata:U};s.getUserContextData(s.username)&&(A.UserContextData=s.getUserContextData(s.username)),s.client.request("InitiateAuth",A,function(C,D){if(C)return a.onFailure(C);var T=D.ChallengeParameters;s.username=T.USER_ID_FOR_SRP,s.userDataKey=s.keyPrefix+"."+s.username+".userData",l=new w(T.SRP_B,16),p=new w(T.SALT,16),s.getCachedDeviceKeyAndPassword(),f.getPasswordAuthenticationKey(s.username,e.getPassword(),l,p,function(P,j){P&&a.onFailure(P);var k=u.getNowString(),Y=I.Buffer.concat([I.Buffer.from(s.pool.getUserPoolName(),"utf8"),I.Buffer.from(s.username,"utf8"),I.Buffer.from(T.SECRET_BLOCK,"base64"),I.Buffer.from(k,"utf8")]),W=new ce.Sha256(j);W.update(Y);var te=W.digestSync(),L=I.Buffer.from(te).toString("base64"),O={};O.USERNAME=s.username,O.PASSWORD_CLAIM_SECRET_BLOCK=T.SECRET_BLOCK,O.TIMESTAMP=k,O.PASSWORD_CLAIM_SIGNATURE=L,s.deviceKey!=null&&(O.DEVICE_KEY=s.deviceKey);var J=function($,ne){return s.client.request("RespondToAuthChallenge",$,function(G,Ce){return G&&G.code==="ResourceNotFoundException"&&G.message.toLowerCase().indexOf("device")!==-1?(O.DEVICE_KEY=null,s.deviceKey=null,s.randomPassword=null,s.deviceGroupKey=null,s.clearCachedDeviceKeyAndPassword(),J($,ne)):ne(G,Ce)})},z={ChallengeName:"PASSWORD_VERIFIER",ClientId:s.pool.getClientId(),ChallengeResponses:O,Session:D.Session,ClientMetadata:U};s.getUserContextData()&&(z.UserContextData=s.getUserContextData()),J(z,function(re,$){return re?a.onFailure(re):s.authenticateUserInternal($,f,a)})})})})},t.authenticateUserPlainUsernamePassword=function(e,a){var s=this,f={};if(f.USERNAME=this.username,f.PASSWORD=e.getPassword(),!f.PASSWORD){a.onFailure(new Error("PASSWORD parameter is required"));return}var u=new X(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),this.deviceKey!=null&&(f.DEVICE_KEY=this.deviceKey);var l=Object.keys(e.getValidationData()).length!==0?e.getValidationData():e.getClientMetadata(),p={AuthFlow:"USER_PASSWORD_AUTH",ClientId:this.pool.getClientId(),AuthParameters:f,ClientMetadata:l};this.getUserContextData(this.username)&&(p.UserContextData=this.getUserContextData(this.username)),this.client.request("InitiateAuth",p,function(d,y){return d?a.onFailure(d):s.authenticateUserInternal(y,u,a)})},t.authenticateUserInternal=function(e,a,s){var f=this,u=e.ChallengeName,l=e.ChallengeParameters;if(u==="SMS_MFA")return this.Session=e.Session,s.mfaRequired(u,l);if(u==="SELECT_MFA_TYPE")return this.Session=e.Session,s.selectMFAType(u,l);if(u==="MFA_SETUP")return this.Session=e.Session,s.mfaSetup(u,l);if(u==="SOFTWARE_TOKEN_MFA")return this.Session=e.Session,s.totpRequired(u,l);if(u==="CUSTOM_CHALLENGE")return this.Session=e.Session,s.customChallenge(l);if(u==="NEW_PASSWORD_REQUIRED"){this.Session=e.Session;var p=null,d=null,y=[],S=a.getNewPasswordRequiredChallengeUserAttributePrefix();if(l&&(p=JSON.parse(e.ChallengeParameters.userAttributes),d=JSON.parse(e.ChallengeParameters.requiredAttributes)),d)for(var U=0;U<d.length;U++)y[U]=d[U].substr(S.length);return s.newPasswordRequired(p,y)}if(u==="DEVICE_SRP_AUTH"){this.Session=e.Session,this.getDeviceResponse(s);return}this.signInUserSession=this.getCognitoUserSession(e.AuthenticationResult),this.challengeName=u,this.cacheTokens();var A=e.AuthenticationResult.NewDeviceMetadata;if(A==null)return s.onSuccess(this.signInUserSession);a.generateHashDevice(e.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,e.AuthenticationResult.NewDeviceMetadata.DeviceKey,function(C){if(C)return s.onFailure(C);var D={Salt:I.Buffer.from(a.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:I.Buffer.from(a.getVerifierDevices(),"hex").toString("base64")};f.verifierDevices=D.PasswordVerifier,f.deviceGroupKey=A.DeviceGroupKey,f.randomPassword=a.getRandomPassword(),f.client.request("ConfirmDevice",{DeviceKey:A.DeviceKey,AccessToken:f.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:D,DeviceName:lt},function(T,P){return T?s.onFailure(T):(f.deviceKey=e.AuthenticationResult.NewDeviceMetadata.DeviceKey,f.cacheDeviceKeyAndPassword(),P.UserConfirmationNecessary===!0?s.onSuccess(f.signInUserSession,P.UserConfirmationNecessary):s.onSuccess(f.signInUserSession))})})},t.completeNewPasswordChallenge=function(e,a,s,f){var u=this;if(!e)return s.onFailure(new Error("New password is required."));var l=new X(this.pool.getUserPoolName()),p=l.getNewPasswordRequiredChallengeUserAttributePrefix(),d={};a&&Object.keys(a).forEach(function(S){d[p+S]=a[S]}),d.NEW_PASSWORD=e,d.USERNAME=this.username;var y={ChallengeName:"NEW_PASSWORD_REQUIRED",ClientId:this.pool.getClientId(),ChallengeResponses:d,Session:this.Session,ClientMetadata:f};this.getUserContextData()&&(y.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",y,function(S,U){return S?s.onFailure(S):u.authenticateUserInternal(U,l,s)})},t.getDeviceResponse=function(e,a){var s=this,f=new X(this.deviceGroupKey),u=new ct,l={};l.USERNAME=this.username,l.DEVICE_KEY=this.deviceKey,f.getLargeAValue(function(p,d){p&&e.onFailure(p),l.SRP_A=d.toString(16);var y={ChallengeName:"DEVICE_SRP_AUTH",ClientId:s.pool.getClientId(),ChallengeResponses:l,ClientMetadata:a,Session:s.Session};s.getUserContextData()&&(y.UserContextData=s.getUserContextData()),s.client.request("RespondToAuthChallenge",y,function(S,U){if(S)return e.onFailure(S);var A=U.ChallengeParameters,C=new w(A.SRP_B,16),D=new w(A.SALT,16);f.getPasswordAuthenticationKey(s.deviceKey,s.randomPassword,C,D,function(T,P){if(T)return e.onFailure(T);var j=u.getNowString(),k=I.Buffer.concat([I.Buffer.from(s.deviceGroupKey,"utf8"),I.Buffer.from(s.deviceKey,"utf8"),I.Buffer.from(A.SECRET_BLOCK,"base64"),I.Buffer.from(j,"utf8")]),Y=new ce.Sha256(P);Y.update(k);var W=Y.digestSync(),te=I.Buffer.from(W).toString("base64"),L={};L.USERNAME=s.username,L.PASSWORD_CLAIM_SECRET_BLOCK=A.SECRET_BLOCK,L.TIMESTAMP=j,L.PASSWORD_CLAIM_SIGNATURE=te,L.DEVICE_KEY=s.deviceKey;var O={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:s.pool.getClientId(),ChallengeResponses:L,Session:U.Session};s.getUserContextData()&&(O.UserContextData=s.getUserContextData()),s.client.request("RespondToAuthChallenge",O,function(J,z){return J?e.onFailure(J):(s.signInUserSession=s.getCognitoUserSession(z.AuthenticationResult),s.cacheTokens(),e.onSuccess(s.signInUserSession))})})})})},t.confirmRegistration=function(e,a,s,f){var u={ClientId:this.pool.getClientId(),ConfirmationCode:e,Username:this.username,ForceAliasCreation:a,ClientMetadata:f};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("ConfirmSignUp",u,function(l){return l?s(l,null):s(null,"SUCCESS")})},t.sendCustomChallengeAnswer=function(e,a,s){var f=this,u={};u.USERNAME=this.username,u.ANSWER=e;var l=new X(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),this.deviceKey!=null&&(u.DEVICE_KEY=this.deviceKey);var p={ChallengeName:"CUSTOM_CHALLENGE",ChallengeResponses:u,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:s};this.getUserContextData()&&(p.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",p,function(d,y){return d?a.onFailure(d):f.authenticateUserInternal(y,l,a)})},t.sendMFACode=function(e,a,s,f){var u=this,l={};l.USERNAME=this.username,l.SMS_MFA_CODE=e;var p=s||"SMS_MFA";p==="SOFTWARE_TOKEN_MFA"&&(l.SOFTWARE_TOKEN_MFA_CODE=e),this.deviceKey!=null&&(l.DEVICE_KEY=this.deviceKey);var d={ChallengeName:p,ChallengeResponses:l,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:f};this.getUserContextData()&&(d.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",d,function(y,S){if(y)return a.onFailure(y);var U=S.ChallengeName;if(U==="DEVICE_SRP_AUTH"){u.getDeviceResponse(a);return}if(u.signInUserSession=u.getCognitoUserSession(S.AuthenticationResult),u.cacheTokens(),S.AuthenticationResult.NewDeviceMetadata==null)return a.onSuccess(u.signInUserSession);var A=new X(u.pool.getUserPoolName());A.generateHashDevice(S.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,S.AuthenticationResult.NewDeviceMetadata.DeviceKey,function(C){if(C)return a.onFailure(C);var D={Salt:I.Buffer.from(A.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:I.Buffer.from(A.getVerifierDevices(),"hex").toString("base64")};u.verifierDevices=D.PasswordVerifier,u.deviceGroupKey=S.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,u.randomPassword=A.getRandomPassword(),u.client.request("ConfirmDevice",{DeviceKey:S.AuthenticationResult.NewDeviceMetadata.DeviceKey,AccessToken:u.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:D,DeviceName:lt},function(T,P){return T?a.onFailure(T):(u.deviceKey=S.AuthenticationResult.NewDeviceMetadata.DeviceKey,u.cacheDeviceKeyAndPassword(),P.UserConfirmationNecessary===!0?a.onSuccess(u.signInUserSession,P.UserConfirmationNecessary):a.onSuccess(u.signInUserSession))})})})},t.changePassword=function(e,a,s,f){if(!(this.signInUserSession!=null&&this.signInUserSession.isValid()))return s(new Error("User is not authenticated"),null);this.client.request("ChangePassword",{PreviousPassword:e,ProposedPassword:a,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:f},function(u){return u?s(u,null):s(null,"SUCCESS")})},t.enableMFA=function(e){if(this.signInUserSession==null||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);var a=[],s={DeliveryMedium:"SMS",AttributeName:"phone_number"};a.push(s),this.client.request("SetUserSettings",{MFAOptions:a,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(f){return f?e(f,null):e(null,"SUCCESS")})},t.setUserMfaPreference=function(e,a,s){if(this.signInUserSession==null||!this.signInUserSession.isValid())return s(new Error("User is not authenticated"),null);this.client.request("SetUserMFAPreference",{SMSMfaSettings:e,SoftwareTokenMfaSettings:a,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(f){return f?s(f,null):s(null,"SUCCESS")})},t.disableMFA=function(e){if(this.signInUserSession==null||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);var a=[];this.client.request("SetUserSettings",{MFAOptions:a,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(s){return s?e(s,null):e(null,"SUCCESS")})},t.deleteUser=function(e,a){var s=this;if(this.signInUserSession==null||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("DeleteUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:a},function(f){return f?e(f,null):(s.clearCachedUser(),e(null,"SUCCESS"))})},t.updateAttributes=function(e,a,s){var f=this;if(this.signInUserSession==null||!this.signInUserSession.isValid())return a(new Error("User is not authenticated"),null);this.client.request("UpdateUserAttributes",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserAttributes:e,ClientMetadata:s},function(u,l){return u?a(u,null):f.getUserData(function(){return a(null,"SUCCESS",l)},{bypassCache:!0})})},t.getUserAttributes=function(e){if(!(this.signInUserSession!=null&&this.signInUserSession.isValid()))return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(a,s){if(a)return e(a,null);for(var f=[],u=0;u<s.UserAttributes.length;u++){var l={Name:s.UserAttributes[u].Name,Value:s.UserAttributes[u].Value},p=new Cn(l);f.push(p)}return e(null,f)})},t.getMFAOptions=function(e){if(!(this.signInUserSession!=null&&this.signInUserSession.isValid()))return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(a,s){return a?e(a,null):e(null,s.MFAOptions)})},t.createGetUserRequest=function(){return this.client.promisifyRequest("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()})},t.refreshSessionIfPossible=function(e){var a=this;return e===void 0&&(e={}),new Promise(function(s){var f=a.signInUserSession.getRefreshToken();f&&f.getToken()?a.refreshSession(f,s,e.clientMetadata):s()})},t.getUserData=function(e,a){var s=this;if(!(this.signInUserSession!=null&&this.signInUserSession.isValid()))return this.clearCachedUserData(),e(new Error("User is not authenticated"),null);var f=this.getUserDataFromCache();if(!f){this.fetchUserData().then(function(u){e(null,u)}).catch(e);return}if(this.isFetchUserDataAndTokenRequired(a)){this.fetchUserData().then(function(u){return s.refreshSessionIfPossible(a).then(function(){return u})}).then(function(u){return e(null,u)}).catch(e);return}try{e(null,JSON.parse(f));return}catch(u){this.clearCachedUserData(),e(u,null);return}},t.getUserDataFromCache=function(){var e=this.storage.getItem(this.userDataKey);return e},t.isFetchUserDataAndTokenRequired=function(e){var a=e||{},s=a.bypassCache,f=s===void 0?!1:s;return f},t.fetchUserData=function(){var e=this;return this.createGetUserRequest().then(function(a){return e.cacheUserData(a),a})},t.deleteAttributes=function(e,a){var s=this;if(!(this.signInUserSession!=null&&this.signInUserSession.isValid()))return a(new Error("User is not authenticated"),null);this.client.request("DeleteUserAttributes",{UserAttributeNames:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(f){return f?a(f,null):s.getUserData(function(){return a(null,"SUCCESS")},{bypassCache:!0})})},t.resendConfirmationCode=function(e,a){var s={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:a};this.client.request("ResendConfirmationCode",s,function(f,u){return f?e(f,null):e(null,u)})},t.getSession=function(e,a){if(a===void 0&&(a={}),this.username==null)return e(new Error("Username is null. Cannot retrieve a new session"),null);if(this.signInUserSession!=null&&this.signInUserSession.isValid())return e(null,this.signInUserSession);var s="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,f=s+".idToken",u=s+".accessToken",l=s+".refreshToken",p=s+".clockDrift";if(this.storage.getItem(f)){var d=new ut({IdToken:this.storage.getItem(f)}),y=new at({AccessToken:this.storage.getItem(u)}),S=new ft({RefreshToken:this.storage.getItem(l)}),U=parseInt(this.storage.getItem(p),0)||0,A={IdToken:d,AccessToken:y,RefreshToken:S,ClockDrift:U},C=new ht(A);if(C.isValid())return this.signInUserSession=C,e(null,this.signInUserSession);if(!S.getToken())return e(new Error("Cannot retrieve a new session. Please authenticate."),null);this.refreshSession(S,e,a.clientMetadata)}else e(new Error("Local storage is missing an ID Token, Please authenticate"),null)},t.refreshSession=function(e,a,s){var f=this,u=this.pool.wrapRefreshSessionCallback?this.pool.wrapRefreshSessionCallback(a):a,l={};l.REFRESH_TOKEN=e.getToken();var p="CognitoIdentityServiceProvider."+this.pool.getClientId(),d=p+".LastAuthUser";if(this.storage.getItem(d)){this.username=this.storage.getItem(d);var y=p+"."+this.username+".deviceKey";this.deviceKey=this.storage.getItem(y),l.DEVICE_KEY=this.deviceKey}var S={ClientId:this.pool.getClientId(),AuthFlow:"REFRESH_TOKEN_AUTH",AuthParameters:l,ClientMetadata:s};this.getUserContextData()&&(S.UserContextData=this.getUserContextData()),this.client.requestWithRetry("InitiateAuth",S,function(U,A){if(U)return U.code==="NotAuthorizedException"&&f.clearCachedUser(),u(U,null);if(A){var C=A.AuthenticationResult;return Object.prototype.hasOwnProperty.call(C,"RefreshToken")||(C.RefreshToken=e.getToken()),f.signInUserSession=f.getCognitoUserSession(C),f.cacheTokens(),u(null,f.signInUserSession)}})},t.cacheTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),a=e+"."+this.username+".idToken",s=e+"."+this.username+".accessToken",f=e+"."+this.username+".refreshToken",u=e+"."+this.username+".clockDrift",l=e+".LastAuthUser";this.storage.setItem(a,this.signInUserSession.getIdToken().getJwtToken()),this.storage.setItem(s,this.signInUserSession.getAccessToken().getJwtToken()),this.storage.setItem(f,this.signInUserSession.getRefreshToken().getToken()),this.storage.setItem(u,""+this.signInUserSession.getClockDrift()),this.storage.setItem(l,this.username)},t.cacheUserData=function(e){this.storage.setItem(this.userDataKey,JSON.stringify(e))},t.clearCachedUserData=function(){this.storage.removeItem(this.userDataKey)},t.clearCachedUser=function(){this.clearCachedTokens(),this.clearCachedUserData()},t.cacheDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,a=e+".deviceKey",s=e+".randomPasswordKey",f=e+".deviceGroupKey";this.storage.setItem(a,this.deviceKey),this.storage.setItem(s,this.randomPassword),this.storage.setItem(f,this.deviceGroupKey)},t.getCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,a=e+".deviceKey",s=e+".randomPasswordKey",f=e+".deviceGroupKey";this.storage.getItem(a)&&(this.deviceKey=this.storage.getItem(a),this.randomPassword=this.storage.getItem(s),this.deviceGroupKey=this.storage.getItem(f))},t.clearCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,a=e+".deviceKey",s=e+".randomPasswordKey",f=e+".deviceGroupKey";this.storage.removeItem(a),this.storage.removeItem(s),this.storage.removeItem(f)},t.clearCachedTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),a=e+"."+this.username+".idToken",s=e+"."+this.username+".accessToken",f=e+"."+this.username+".refreshToken",u=e+".LastAuthUser",l=e+"."+this.username+".clockDrift";this.storage.removeItem(a),this.storage.removeItem(s),this.storage.removeItem(f),this.storage.removeItem(u),this.storage.removeItem(l)},t.getCognitoUserSession=function(e){var a=new ut(e),s=new at(e),f=new ft(e),u={IdToken:a,AccessToken:s,RefreshToken:f};return new ht(u)},t.forgotPassword=function(e,a){var s={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:a};this.getUserContextData()&&(s.UserContextData=this.getUserContextData()),this.client.request("ForgotPassword",s,function(f,u){return f?e.onFailure(f):typeof e.inputVerificationCode=="function"?e.inputVerificationCode(u):e.onSuccess(u)})},t.confirmPassword=function(e,a,s,f){var u={ClientId:this.pool.getClientId(),Username:this.username,ConfirmationCode:e,Password:a,ClientMetadata:f};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("ConfirmForgotPassword",u,function(l){return l?s.onFailure(l):s.onSuccess("SUCCESS")})},t.getAttributeVerificationCode=function(e,a,s){if(this.signInUserSession==null||!this.signInUserSession.isValid())return a.onFailure(new Error("User is not authenticated"));this.client.request("GetUserAttributeVerificationCode",{AttributeName:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:s},function(f,u){return f?a.onFailure(f):typeof a.inputVerificationCode=="function"?a.inputVerificationCode(u):a.onSuccess("SUCCESS")})},t.verifyAttribute=function(e,a,s){if(this.signInUserSession==null||!this.signInUserSession.isValid())return s.onFailure(new Error("User is not authenticated"));this.client.request("VerifyUserAttribute",{AttributeName:e,Code:a,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(f){return f?s.onFailure(f):s.onSuccess("SUCCESS")})},t.getDevice=function(e){if(this.signInUserSession==null||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey},function(a,s){return a?e.onFailure(a):e.onSuccess(s)})},t.forgetSpecificDevice=function(e,a){if(this.signInUserSession==null||!this.signInUserSession.isValid())return a.onFailure(new Error("User is not authenticated"));this.client.request("ForgetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:e},function(s){return s?a.onFailure(s):a.onSuccess("SUCCESS")})},t.forgetDevice=function(e){var a=this;this.forgetSpecificDevice(this.deviceKey,{onFailure:e.onFailure,onSuccess:function(f){return a.deviceKey=null,a.deviceGroupKey=null,a.randomPassword=null,a.clearCachedDeviceKeyAndPassword(),e.onSuccess(f)}})},t.setDeviceStatusRemembered=function(e){if(this.signInUserSession==null||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"remembered"},function(a){return a?e.onFailure(a):e.onSuccess("SUCCESS")})},t.setDeviceStatusNotRemembered=function(e){if(this.signInUserSession==null||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"not_remembered"},function(a){return a?e.onFailure(a):e.onSuccess("SUCCESS")})},t.listDevices=function(e,a,s){if(this.signInUserSession==null||!this.signInUserSession.isValid())return s.onFailure(new Error("User is not authenticated"));var f={AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),Limit:e};a&&(f.PaginationToken=a),this.client.request("ListDevices",f,function(u,l){return u?s.onFailure(u):s.onSuccess(l)})},t.globalSignOut=function(e){var a=this;if(this.signInUserSession==null||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GlobalSignOut",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(s){return s?e.onFailure(s):(a.clearCachedUser(),e.onSuccess("SUCCESS"))})},t.signOut=function(e){var a=this;if(!e||typeof e!="function"){this.cleanClientData();return}this.getSession(function(s,f){if(s)return e(s);a.revokeTokens(function(u){a.cleanClientData(),e(u)})})},t.revokeTokens=function(e){if(e===void 0&&(e=function(){}),typeof e!="function")throw new Error("Invalid revokeTokenCallback. It should be a function.");if(!this.signInUserSession){var a=new Error("User is not authenticated");return e(a)}if(!this.signInUserSession.getAccessToken()){var s=new Error("No Access token available");return e(s)}var f=this.signInUserSession.getRefreshToken().getToken(),u=this.signInUserSession.getAccessToken();if(this.isSessionRevocable(u)&&f)return this.revokeToken({token:f,callback:e});e()},t.isSessionRevocable=function(e){if(e&&typeof e.decodePayload=="function")try{var a=e.decodePayload(),s=a.origin_jti;return!!s}catch{}return!1},t.cleanClientData=function(){this.signInUserSession=null,this.clearCachedUser()},t.revokeToken=function(e){var a=e.token,s=e.callback;this.client.requestWithRetry("RevokeToken",{Token:a,ClientId:this.pool.getClientId()},function(f){if(f)return s(f);s()})},t.sendMFASelectionAnswer=function(e,a){var s=this,f={};f.USERNAME=this.username,f.ANSWER=e;var u={ChallengeName:"SELECT_MFA_TYPE",ChallengeResponses:f,ClientId:this.pool.getClientId(),Session:this.Session};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",u,function(l,p){if(l)return a.onFailure(l);if(s.Session=p.Session,e==="SMS_MFA")return a.mfaRequired(p.ChallengeName,p.ChallengeParameters);if(e==="SOFTWARE_TOKEN_MFA")return a.totpRequired(p.ChallengeName,p.ChallengeParameters)})},t.getUserContextData=function(){var e=this.pool;return e.getUserContextData(this.username)},t.associateSoftwareToken=function(e){var a=this;this.signInUserSession!=null&&this.signInUserSession.isValid()?this.client.request("AssociateSoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},function(s,f){return s?e.onFailure(s):e.associateSecretCode(f.SecretCode)}):this.client.request("AssociateSoftwareToken",{Session:this.Session},function(s,f){return s?e.onFailure(s):(a.Session=f.Session,e.associateSecretCode(f.SecretCode))})},t.verifySoftwareToken=function(e,a,s){var f=this;this.signInUserSession!=null&&this.signInUserSession.isValid()?this.client.request("VerifySoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserCode:e,FriendlyDeviceName:a},function(u,l){return u?s.onFailure(u):s.onSuccess(l)}):this.client.request("VerifySoftwareToken",{Session:this.Session,UserCode:e,FriendlyDeviceName:a},function(u,l){if(u)return s.onFailure(u);f.Session=l.Session;var p={};p.USERNAME=f.username;var d={ChallengeName:"MFA_SETUP",ClientId:f.pool.getClientId(),ChallengeResponses:p,Session:f.Session};f.getUserContextData()&&(d.UserContextData=f.getUserContextData()),f.client.request("RespondToAuthChallenge",d,function(y,S){return y?s.onFailure(y):(f.signInUserSession=f.getCognitoUserSession(S.AuthenticationResult),f.cacheTokens(),s.onSuccess(f.signInUserSession))})})},o})();function En(o,t){return t=t||{},new Promise(function(r,e){var a=new XMLHttpRequest,s=[],f=[],u={},l=function(){return{ok:(a.status/100|0)==2,statusText:a.statusText,status:a.status,url:a.responseURL,text:function(){return Promise.resolve(a.responseText)},json:function(){return Promise.resolve(a.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([a.response]))},clone:l,headers:{keys:function(){return s},entries:function(){return f},get:function(d){return u[d.toLowerCase()]},has:function(d){return d.toLowerCase()in u}}}};for(var p in a.open(t.method||"get",o,!0),a.onload=function(){a.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(d,y,S){s.push(y=y.toLowerCase()),f.push([y,S]),u[y]=u[y]?u[y]+","+S:S}),r(l())},a.onerror=e,a.withCredentials=t.credentials=="include",t.headers)a.setRequestHeader(p,t.headers[p]);a.send(t.body||null)})}const Tn=Object.freeze(Object.defineProperty({__proto__:null,default:En},Symbol.toStringTag,{value:"Module"})),gt=Oe(Tn);var xe,dt;function Dn(){return dt||(dt=1,xe=self.fetch||(self.fetch=gt.default||gt)),xe}Dn();function K(){}K.prototype.userAgent=yn();var Ln=function(t){t&&(K.prototype.userAgent&&!K.prototype.userAgent.includes(t)&&(K.prototype.userAgent=K.prototype.userAgent.concat(" ",t)),(!K.prototype.userAgent||K.prototype.userAgent==="")&&(K.prototype.userAgent=t))},xn=function(t){var r=K.category?" "+K.category:"",e=K.framework?" framework/"+K.framework:"",a=""+K.prototype.userAgent+r+e;return a};function In(o,t){o.prototype=Object.create(t.prototype),o.prototype.constructor=o,pe(o,t)}function be(o){var t=typeof Map=="function"?new Map:void 0;return be=function(e){if(e===null||!Rn(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(t!==void 0){if(t.has(e))return t.get(e);t.set(e,a)}function a(){return _n(e,arguments,Me(this).constructor)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),pe(a,e)},be(o)}function _n(o,t,r){if(Ut())return Reflect.construct.apply(null,arguments);var e=[null];e.push.apply(e,t);var a=new(o.bind.apply(o,e));return r&&pe(a,r.prototype),a}function Ut(){try{var o=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ut=function(){return!!o})()}function Rn(o){try{return Function.toString.call(o).indexOf("[native code]")!==-1}catch{return typeof o=="function"}}function pe(o,t){return pe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},pe(o,t)}function Me(o){return Me=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Me(o)}var Pn=(function(o){function t(r,e,a,s){var f;return f=o.call(this,r)||this,f.code=e,f.name=a,f.statusCode=s,f}return In(t,o),t})(be(Error)),Fn=(function(){function o(r,e,a){this.endpoint=e||"https://cognito-idp."+r+".amazonaws.com/";var s=a||{},f=s.credentials;this.fetchOptions=f?{credentials:f}:{}}var t=o.prototype;return t.promisifyRequest=function(e,a){var s=this;return new Promise(function(f,u){s.request(e,a,function(l,p){l?u(new Pn(l.message,l.code,l.name,l.statusCode)):f(p)})})},t.requestWithRetry=function(e,a,s){var f=this,u=5*1e3;Mn(function(l){return new Promise(function(p,d){f.request(e,l,function(y,S){y?d(y):p(S)})})},[a],u).then(function(l){return s(null,l)}).catch(function(l){return s(l)})},t.request=function(e,a,s){var f={"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityProviderService."+e,"X-Amz-User-Agent":xn(),"Cache-Control":"no-store"},u=Object.assign({},this.fetchOptions,{headers:f,method:"POST",mode:"cors",body:JSON.stringify(a)}),l;fetch(this.endpoint,u).then(function(p){return l=p,p},function(p){throw p instanceof TypeError?new Error("Network error"):p}).then(function(p){return p.json().catch(function(){return{}})}).then(function(p){if(l.ok)return s(null,p);var d=(p.__type||p.code).split("#").pop(),y=new Error(p.message||p.Message||null);return y.name=d,y.code=d,s(y)}).catch(function(p){if(l&&l.headers&&l.headers.get("x-amzn-errortype"))try{var d=l.headers.get("x-amzn-errortype").split(":")[0],y=new Error(l.status?l.status.toString():null);return y.code=d,y.name=d,y.statusCode=l.status,s(y)}catch{return s(p)}else p instanceof Error&&p.message==="Network error"&&(p.code="NetworkError");return s(p)})},o})(),Se={debug:function(){}},Bn=function(t){var r="nonRetryable";return t&&t[r]};function Et(o,t,r,e){if(e===void 0&&(e=1),typeof o!="function")throw Error("functionToRetry must be a function");return Se.debug(o.name+" attempt #"+e+" with args: "+JSON.stringify(t)),o.apply(void 0,t).catch(function(a){if(Se.debug("error on "+o.name,a),Bn(a))throw Se.debug(o.name+" non retryable error",a),a;var s=r(e,t,a);if(Se.debug(o.name+" retrying in "+s+" ms"),s!==!1)return new Promise(function(f){return setTimeout(f,s)}).then(function(){return Et(o,t,r,e+1)});throw a})}function bn(o){var t=100,r=100;return function(e){var a=Math.pow(2,e)*t+r*Math.random();return a>o?!1:a}}function Mn(o,t,r){return Et(o,t,bn(r))}/*!
|
|
50
50
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
51
51
|
* SPDX-License-Identifier: Apache-2.0
|
|
52
|
-
*/var On=55,
|
|
52
|
+
*/var On=55,jn=(function(){function o(r,e){var a=r||{},s=a.UserPoolId,f=a.ClientId,u=a.endpoint,l=a.fetchOptions,p=a.AdvancedSecurityDataCollectionFlag;if(!s||!f)throw new Error("Both UserPoolId and ClientId are required.");if(s.length>On||!/^[\w-]+_[0-9a-zA-Z]+$/.test(s))throw new Error("Invalid UserPoolId format.");var d=s.split("_")[0];this.userPoolId=s,this.clientId=f,this.client=new Fn(d,u,l),this.advancedSecurityDataCollectionFlag=p!==!1,this.storage=r.Storage||new At().getStorage(),e&&(this.wrapRefreshSessionCallback=e)}var t=o.prototype;return t.getUserPoolId=function(){return this.userPoolId},t.getUserPoolName=function(){return this.getUserPoolId().split("_")[1]},t.getClientId=function(){return this.clientId},t.signUp=function(e,a,s,f,u,l){var p=this,d={ClientId:this.clientId,Username:e,Password:a,UserAttributes:s,ValidationData:f,ClientMetadata:l};this.getUserContextData(e)&&(d.UserContextData=this.getUserContextData(e)),this.client.request("SignUp",d,function(y,S){if(y)return u(y,null);var U={Username:e,Pool:p,Storage:p.storage},A={user:new pt(U),userConfirmed:S.UserConfirmed,userSub:S.UserSub,codeDeliveryDetails:S.CodeDeliveryDetails};return u(null,A)})},t.getCurrentUser=function(){var e="CognitoIdentityServiceProvider."+this.clientId+".LastAuthUser",a=this.storage.getItem(e);if(a){var s={Username:a,Pool:this,Storage:this.storage};return new pt(s)}return null},t.getUserContextData=function(e){if(!(typeof AmazonCognitoAdvancedSecurityData>"u")){var a=AmazonCognitoAdvancedSecurityData;if(this.advancedSecurityDataCollectionFlag){var s=a.getData(e,this.userPoolId,this.clientId);if(s){var f={EncodedData:s};return f}}return{}}},o})(),Ie={exports:{}};/*!
|
|
53
53
|
* JavaScript Cookie v2.2.1
|
|
54
54
|
* https://github.com/js-cookie/js-cookie
|
|
55
55
|
*
|
|
56
56
|
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
|
57
57
|
* Released under the MIT license
|
|
58
|
-
*/var vt;function Nn(){return vt||(vt=1,(function(o,t){(function(r){var e;if(o.exports=r(),e=!0,!e){var a=window.Cookies,s=window.Cookies=r();s.noConflict=function(){return window.Cookies=a,s}}})(function(){function r(){for(var s=0,f={};s<arguments.length;s++){var u=arguments[s];for(var l in u)f[l]=u[l]}return f}function e(s){return s.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}function a(s){function f(){}function u(p,d,y){if(!(typeof document>"u")){y=r({path:"/"},f.defaults,y),typeof y.expires=="number"&&(y.expires=new Date(new Date*1+y.expires*864e5)),y.expires=y.expires?y.expires.toUTCString():"";try{var S=JSON.stringify(d);/^[\{\[]/.test(S)&&(d=S)}catch{}d=s.write?s.write(d,p):encodeURIComponent(String(d)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),p=encodeURIComponent(String(p)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var U="";for(var A in y)y[A]&&(U+="; "+A,y[A]!==!0&&(U+="="+y[A].split(";")[0]));return document.cookie=p+"="+d+U}}function l(p,d){if(!(typeof document>"u")){for(var y={},S=document.cookie?document.cookie.split("; "):[],U=0;U<S.length;U++){var A=S[U].split("="),C=A.slice(1).join("=");!d&&C.charAt(0)==='"'&&(C=C.slice(1,-1));try{var D=e(A[0]);if(C=(s.read||s)(C,D)||e(C),d)try{C=JSON.parse(C)}catch{}if(y[D]=C,p===D)break}catch{}}return p?y[p]:y}}return f.set=u,f.get=function(p){return l(p,!1)},f.getJSON=function(p){return l(p,!0)},f.remove=function(p,d){u(p,"",r(d,{expires:-1}))},f.defaults={},f.withConverter=a,f}return a(function(){})})})(Ie)),Ie.exports}var he=Nn(),
|
|
58
|
+
*/var vt;function Nn(){return vt||(vt=1,(function(o,t){(function(r){var e;if(o.exports=r(),e=!0,!e){var a=window.Cookies,s=window.Cookies=r();s.noConflict=function(){return window.Cookies=a,s}}})(function(){function r(){for(var s=0,f={};s<arguments.length;s++){var u=arguments[s];for(var l in u)f[l]=u[l]}return f}function e(s){return s.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}function a(s){function f(){}function u(p,d,y){if(!(typeof document>"u")){y=r({path:"/"},f.defaults,y),typeof y.expires=="number"&&(y.expires=new Date(new Date*1+y.expires*864e5)),y.expires=y.expires?y.expires.toUTCString():"";try{var S=JSON.stringify(d);/^[\{\[]/.test(S)&&(d=S)}catch{}d=s.write?s.write(d,p):encodeURIComponent(String(d)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),p=encodeURIComponent(String(p)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var U="";for(var A in y)y[A]&&(U+="; "+A,y[A]!==!0&&(U+="="+y[A].split(";")[0]));return document.cookie=p+"="+d+U}}function l(p,d){if(!(typeof document>"u")){for(var y={},S=document.cookie?document.cookie.split("; "):[],U=0;U<S.length;U++){var A=S[U].split("="),C=A.slice(1).join("=");!d&&C.charAt(0)==='"'&&(C=C.slice(1,-1));try{var D=e(A[0]);if(C=(s.read||s)(C,D)||e(C),d)try{C=JSON.parse(C)}catch{}if(y[D]=C,p===D)break}catch{}}return p?y[p]:y}}return f.set=u,f.get=function(p){return l(p,!1)},f.getJSON=function(p){return l(p,!0)},f.remove=function(p,d){u(p,"",r(d,{expires:-1}))},f.defaults={},f.withConverter=a,f}return a(function(){})})})(Ie)),Ie.exports}var he=Nn(),Hn=(function(){function o(r){if(r===void 0&&(r={}),r.domain&&(this.domain=r.domain),r.path?this.path=r.path:this.path="/",Object.prototype.hasOwnProperty.call(r,"expires")?this.expires=r.expires:this.expires=365,Object.prototype.hasOwnProperty.call(r,"secure")?this.secure=r.secure:this.secure=!0,Object.prototype.hasOwnProperty.call(r,"sameSite")){if(!["strict","lax","none"].includes(r.sameSite))throw new Error('The sameSite value of cookieStorage must be "lax", "strict" or "none".');if(r.sameSite==="none"&&!this.secure)throw new Error("sameSite = None requires the Secure attribute in latest browser versions.");this.sameSite=r.sameSite}else this.sameSite=null}var t=o.prototype;return t.setItem=function(e,a){var s={path:this.path,expires:this.expires,domain:this.domain,secure:this.secure};return this.sameSite&&(s.sameSite=this.sameSite),he.set(e,a,s),he.get(e)},t.getItem=function(e){return he.get(e)},t.removeItem=function(e){var a={path:this.path,expires:this.expires,domain:this.domain,secure:this.secure};return this.sameSite&&(a.sameSite=this.sameSite),he.remove(e,a)},t.clear=function(){for(var e=he.get(),a=Object.keys(e).length,s=0;s<a;++s)this.removeItem(Object.keys(e)[s]);return{}},o})();export{Vn as AuthenticationDetails,X as AuthenticationHelper,at as CognitoAccessToken,ut as CognitoIdToken,ft as CognitoRefreshToken,pt as CognitoUser,Cn as CognitoUserAttribute,jn as CognitoUserPool,ht as CognitoUserSession,Hn as CookieStorage,ct as DateHelper,Ht as WordArray,Ln as appendToCognitoUserAgent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as On,g as Tn}from"./_commonjsHelpers-D6-XlEtG.js";import{a as En,b as Nn,c as In,r as An}from"./winston-
|
|
1
|
+
import{a as On,g as Tn}from"./_commonjsHelpers-D6-XlEtG.js";import{a as En,b as Nn,c as In,r as An}from"./winston-CfAk0yN1.js";import{c as it,r as Pe}from"./_commonjs-dynamic-modules-B7n8ZNar.js";import{r as Fr}from"./util-Cb5ErRuM.js";function Fn(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const s in n)if(s!=="default"&&!(s in e)){const u=Object.getOwnPropertyDescriptor(n,s);u&&Object.defineProperty(e,s,u.get?u:{enumerable:!0,get:()=>n[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var Ut={exports:{}},Dr;function Rn(){return Dr||(Dr=1,(function(e,t){(function(r){e.exports=r()})(function(){return(function r(n,s,u){function g(L,j){if(!s[L]){if(!n[L]){var ee=typeof it=="function"&⁢if(!j&&ee)return ee(L,!0);if(T)return T(L,!0);throw new Error("Cannot find module '"+L+"'")}j=s[L]={exports:{}},n[L][0].call(j.exports,function(k){var Q=n[L][1][k];return g(Q||k)},j,j.exports,r,n,s,u)}return s[L].exports}for(var T=typeof it=="function"&&it,F=0;F<u.length;F++)g(u[F]);return g})({1:[function(r,n,s){(function(u,g,T,F,L,j,ee,k,Q){var M=r("crypto");function _(c,w){w=v(c,w);var o;return(o=w.algorithm!=="passthrough"?M.createHash(w.algorithm):new D).write===void 0&&(o.write=o.update,o.end=o.update),b(w,o).dispatch(c),o.update||o.end(""),o.digest?o.digest(w.encoding==="buffer"?void 0:w.encoding):(c=o.read(),w.encoding!=="buffer"?c.toString(w.encoding):c)}(s=n.exports=_).sha1=function(c){return _(c)},s.keys=function(c){return _(c,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},s.MD5=function(c){return _(c,{algorithm:"md5",encoding:"hex"})},s.keysMD5=function(c){return _(c,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var d=M.getHashes?M.getHashes().slice():["sha1","md5"],m=(d.push("passthrough"),["buffer","hex","binary","base64"]);function v(c,w){var o={};if(o.algorithm=(w=w||{}).algorithm||"sha1",o.encoding=w.encoding||"hex",o.excludeValues=!!w.excludeValues,o.algorithm=o.algorithm.toLowerCase(),o.encoding=o.encoding.toLowerCase(),o.ignoreUnknown=w.ignoreUnknown===!0,o.respectType=w.respectType!==!1,o.respectFunctionNames=w.respectFunctionNames!==!1,o.respectFunctionProperties=w.respectFunctionProperties!==!1,o.unorderedArrays=w.unorderedArrays===!0,o.unorderedSets=w.unorderedSets!==!1,o.unorderedObjects=w.unorderedObjects!==!1,o.replacer=w.replacer||void 0,o.excludeKeys=w.excludeKeys||void 0,c===void 0)throw new Error("Object argument required.");for(var f=0;f<d.length;++f)d[f].toLowerCase()===o.algorithm.toLowerCase()&&(o.algorithm=d[f]);if(d.indexOf(o.algorithm)===-1)throw new Error('Algorithm "'+o.algorithm+'" not supported. supported values: '+d.join(", "));if(m.indexOf(o.encoding)===-1&&o.algorithm!=="passthrough")throw new Error('Encoding "'+o.encoding+'" not supported. supported values: '+m.join(", "));return o}function S(c){if(typeof c=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(c))!=null}function b(c,w,o){o=o||[];function f(a){return w.update?w.update(a,"utf8"):w.write(a,"utf8")}return{dispatch:function(a){return this["_"+((a=c.replacer?c.replacer(a):a)===null?"null":typeof a)](a)},_object:function(a){var y,p=Object.prototype.toString.call(a),P=/\[object (.*)\]/i.exec(p);if(P=(P=P?P[1]:"unknown:["+p+"]").toLowerCase(),0<=(p=o.indexOf(a)))return this.dispatch("[CIRCULAR:"+p+"]");if(o.push(a),T!==void 0&&T.isBuffer&&T.isBuffer(a))return f("buffer:"),f(a);if(P==="object"||P==="function"||P==="asyncfunction")return p=Object.keys(a),c.unorderedObjects&&(p=p.sort()),c.respectType===!1||S(a)||p.splice(0,0,"prototype","__proto__","constructor"),c.excludeKeys&&(p=p.filter(function(U){return!c.excludeKeys(U)})),f("object:"+p.length+":"),y=this,p.forEach(function(U){y.dispatch(U),f(":"),c.excludeValues||y.dispatch(a[U]),f(",")});if(!this["_"+P]){if(c.ignoreUnknown)return f("["+P+"]");throw new Error('Unknown object type "'+P+'"')}this["_"+P](a)},_array:function(a,U){U=U!==void 0?U:c.unorderedArrays!==!1;var p=this;if(f("array:"+a.length+":"),!U||a.length<=1)return a.forEach(function(C){return p.dispatch(C)});var P=[],U=a.map(function(C){var R=new D,B=o.slice();return b(c,R,B).dispatch(C),P=P.concat(B.slice(o.length)),R.read().toString()});return o=o.concat(P),U.sort(),this._array(U,!1)},_date:function(a){return f("date:"+a.toJSON())},_symbol:function(a){return f("symbol:"+a.toString())},_error:function(a){return f("error:"+a.toString())},_boolean:function(a){return f("bool:"+a.toString())},_string:function(a){f("string:"+a.length+":"),f(a.toString())},_function:function(a){f("fn:"),S(a)?this.dispatch("[native]"):this.dispatch(a.toString()),c.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(a.name)),c.respectFunctionProperties&&this._object(a)},_number:function(a){return f("number:"+a.toString())},_xml:function(a){return f("xml:"+a.toString())},_null:function(){return f("Null")},_undefined:function(){return f("Undefined")},_regexp:function(a){return f("regex:"+a.toString())},_uint8array:function(a){return f("uint8array:"),this.dispatch(Array.prototype.slice.call(a))},_uint8clampedarray:function(a){return f("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(a))},_int8array:function(a){return f("int8array:"),this.dispatch(Array.prototype.slice.call(a))},_uint16array:function(a){return f("uint16array:"),this.dispatch(Array.prototype.slice.call(a))},_int16array:function(a){return f("int16array:"),this.dispatch(Array.prototype.slice.call(a))},_uint32array:function(a){return f("uint32array:"),this.dispatch(Array.prototype.slice.call(a))},_int32array:function(a){return f("int32array:"),this.dispatch(Array.prototype.slice.call(a))},_float32array:function(a){return f("float32array:"),this.dispatch(Array.prototype.slice.call(a))},_float64array:function(a){return f("float64array:"),this.dispatch(Array.prototype.slice.call(a))},_arraybuffer:function(a){return f("arraybuffer:"),this.dispatch(new Uint8Array(a))},_url:function(a){return f("url:"+a.toString())},_map:function(a){return f("map:"),a=Array.from(a),this._array(a,c.unorderedSets!==!1)},_set:function(a){return f("set:"),a=Array.from(a),this._array(a,c.unorderedSets!==!1)},_file:function(a){return f("file:"),this.dispatch([a.name,a.size,a.type,a.lastModfied])},_blob:function(){if(c.ignoreUnknown)return f("[blob]");throw Error(`Hashing Blob objects is currently not supported
|
|
2
2
|
(see https://github.com/puleos/object-hash/issues/26)
|
|
3
3
|
Use "options.replacer" or "options.ignoreUnknown"
|
|
4
4
|
`)},_domwindow:function(){return f("domwindow")},_bigint:function(a){return f("bigint:"+a.toString())},_process:function(){return f("process")},_timer:function(){return f("timer")},_pipe:function(){return f("pipe")},_tcp:function(){return f("tcp")},_udp:function(){return f("udp")},_tty:function(){return f("tty")},_statwatcher:function(){return f("statwatcher")},_securecontext:function(){return f("securecontext")},_connection:function(){return f("connection")},_zlib:function(){return f("zlib")},_context:function(){return f("context")},_nodescript:function(){return f("nodescript")},_httpparser:function(){return f("httpparser")},_dataview:function(){return f("dataview")},_signal:function(){return f("signal")},_fsevent:function(){return f("fsevent")},_tlswrap:function(){return f("tlswrap")}}}function D(){return{buf:"",write:function(c){this.buf+=c},end:function(c){this.buf+=c},read:function(){return this.buf}}}s.writeToStream=function(c,w,o){return o===void 0&&(o=w,w={}),b(w=v(c,w),o).dispatch(c)}}).call(this,r("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},r("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(r,n,s){(function(u,g,T,F,L,j,ee,k,Q){(function(M){var _=typeof Uint8Array<"u"?Uint8Array:Array,d=43,m=47,v=48,S=97,b=65,D=45,c=95;function w(o){return o=o.charCodeAt(0),o===d||o===D?62:o===m||o===c?63:o<v?-1:o<v+10?o-v+26+26:o<b+26?o-b:o<S+26?o-S+26:void 0}M.toByteArray=function(o){var f,a;if(0<o.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var y=o.length,y=o.charAt(y-2)==="="?2:o.charAt(y-1)==="="?1:0,p=new _(3*o.length/4-y),P=0<y?o.length-4:o.length,U=0;function C(R){p[U++]=R}for(f=0;f<P;f+=4,0)C((16711680&(a=w(o.charAt(f))<<18|w(o.charAt(f+1))<<12|w(o.charAt(f+2))<<6|w(o.charAt(f+3))))>>16),C((65280&a)>>8),C(255&a);return y==2?C(255&(a=w(o.charAt(f))<<2|w(o.charAt(f+1))>>4)):y==1&&(C((a=w(o.charAt(f))<<10|w(o.charAt(f+1))<<4|w(o.charAt(f+2))>>2)>>8&255),C(255&a)),p},M.fromByteArray=function(o){var f,a,y,p,P=o.length%3,U="";function C(R){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(R)}for(f=0,y=o.length-P;f<y;f+=3)a=(o[f]<<16)+(o[f+1]<<8)+o[f+2],U+=C((p=a)>>18&63)+C(p>>12&63)+C(p>>6&63)+C(63&p);switch(P){case 1:U=(U+=C((a=o[o.length-1])>>2))+C(a<<4&63)+"==";break;case 2:U=(U=(U+=C((a=(o[o.length-2]<<8)+o[o.length-1])>>10))+C(a>>4&63))+C(a<<2&63)+"="}return U}})(s===void 0?this.base64js={}:s)}).call(this,r("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},r("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(r,n,s){(function(u,g,d,F,L,j,ee,k,Q){var M=r("base64-js"),_=r("ieee754");function d(i,l,h){if(!(this instanceof d))return new d(i,l,h);var O,x,I,$,se=typeof i;if(l==="base64"&&se=="string")for(i=($=i).trim?$.trim():$.replace(/^\s+|\s+$/g,"");i.length%4!=0;)i+="=";if(se=="number")O=V(i);else if(se=="string")O=d.byteLength(i,l);else{if(se!="object")throw new Error("First argument needs to be a number, array or string.");O=V(i.length)}if(d._useTypedArrays?x=d._augment(new Uint8Array(O)):((x=this).length=O,x._isBuffer=!0),d._useTypedArrays&&typeof i.byteLength=="number")x._set(i);else if(K($=i)||d.isBuffer($)||$&&typeof $=="object"&&typeof $.length=="number")for(I=0;I<O;I++)d.isBuffer(i)?x[I]=i.readUInt8(I):x[I]=i[I];else if(se=="string")x.write(i,0,l);else if(se=="number"&&!d._useTypedArrays&&!h)for(I=0;I<O;I++)x[I]=0;return x}function m(i,l,h,O){return d._charsWritten=ye((function(x){for(var I=[],$=0;$<x.length;$++)I.push(255&x.charCodeAt($));return I})(l),i,h,O)}function v(i,l,h,O){return d._charsWritten=ye((function(x){for(var I,$,se=[],ue=0;ue<x.length;ue++)$=x.charCodeAt(ue),I=$>>8,$=$%256,se.push($),se.push(I);return se})(l),i,h,O)}function S(i,l,h){var O="";h=Math.min(i.length,h);for(var x=l;x<h;x++)O+=String.fromCharCode(i[x]);return O}function b(i,l,h,I){I||(E(typeof h=="boolean","missing or invalid endian"),E(l!=null,"missing offset"),E(l+1<i.length,"Trying to read beyond buffer length"));var x,I=i.length;if(!(I<=l))return h?(x=i[l],l+1<I&&(x|=i[l+1]<<8)):(x=i[l]<<8,l+1<I&&(x|=i[l+1])),x}function D(i,l,h,I){I||(E(typeof h=="boolean","missing or invalid endian"),E(l!=null,"missing offset"),E(l+3<i.length,"Trying to read beyond buffer length"));var x,I=i.length;if(!(I<=l))return h?(l+2<I&&(x=i[l+2]<<16),l+1<I&&(x|=i[l+1]<<8),x|=i[l],l+3<I&&(x+=i[l+3]<<24>>>0)):(l+1<I&&(x=i[l+1]<<16),l+2<I&&(x|=i[l+2]<<8),l+3<I&&(x|=i[l+3]),x+=i[l]<<24>>>0),x}function c(i,l,h,O){if(O||(E(typeof h=="boolean","missing or invalid endian"),E(l!=null,"missing offset"),E(l+1<i.length,"Trying to read beyond buffer length")),!(i.length<=l))return O=b(i,l,h,!0),32768&O?-1*(65535-O+1):O}function w(i,l,h,O){if(O||(E(typeof h=="boolean","missing or invalid endian"),E(l!=null,"missing offset"),E(l+3<i.length,"Trying to read beyond buffer length")),!(i.length<=l))return O=D(i,l,h,!0),2147483648&O?-1*(4294967295-O+1):O}function o(i,l,h,O){return O||(E(typeof h=="boolean","missing or invalid endian"),E(l+3<i.length,"Trying to read beyond buffer length")),_.read(i,l,h,23,4)}function f(i,l,h,O){return O||(E(typeof h=="boolean","missing or invalid endian"),E(l+7<i.length,"Trying to read beyond buffer length")),_.read(i,l,h,52,8)}function a(i,l,h,O,x){if(x||(E(l!=null,"missing value"),E(typeof O=="boolean","missing or invalid endian"),E(h!=null,"missing offset"),E(h+1<i.length,"trying to write beyond buffer length"),Lt(l,65535)),x=i.length,!(x<=h))for(var I=0,$=Math.min(x-h,2);I<$;I++)i[h+I]=(l&255<<8*(O?I:1-I))>>>8*(O?I:1-I)}function y(i,l,h,O,x){if(x||(E(l!=null,"missing value"),E(typeof O=="boolean","missing or invalid endian"),E(h!=null,"missing offset"),E(h+3<i.length,"trying to write beyond buffer length"),Lt(l,4294967295)),x=i.length,!(x<=h))for(var I=0,$=Math.min(x-h,4);I<$;I++)i[h+I]=l>>>8*(O?I:3-I)&255}function p(i,l,h,O,x){x||(E(l!=null,"missing value"),E(typeof O=="boolean","missing or invalid endian"),E(h!=null,"missing offset"),E(h+1<i.length,"Trying to write beyond buffer length"),Wt(l,32767,-32768)),i.length<=h||a(i,0<=l?l:65535+l+1,h,O,x)}function P(i,l,h,O,x){x||(E(l!=null,"missing value"),E(typeof O=="boolean","missing or invalid endian"),E(h!=null,"missing offset"),E(h+3<i.length,"Trying to write beyond buffer length"),Wt(l,2147483647,-2147483648)),i.length<=h||y(i,0<=l?l:4294967295+l+1,h,O,x)}function U(i,l,h,O,x){x||(E(l!=null,"missing value"),E(typeof O=="boolean","missing or invalid endian"),E(h!=null,"missing offset"),E(h+3<i.length,"Trying to write beyond buffer length"),Sr(l,34028234663852886e22,-34028234663852886e22)),i.length<=h||_.write(i,l,h,O,23,4)}function C(i,l,h,O,x){x||(E(l!=null,"missing value"),E(typeof O=="boolean","missing or invalid endian"),E(h!=null,"missing offset"),E(h+7<i.length,"Trying to write beyond buffer length"),Sr(l,17976931348623157e292,-17976931348623157e292)),i.length<=h||_.write(i,l,h,O,52,8)}s.Buffer=d,s.SlowBuffer=d,s.INSPECT_MAX_BYTES=50,d.poolSize=8192,d._useTypedArrays=(function(){try{var i=new ArrayBuffer(0),l=new Uint8Array(i);return l.foo=function(){return 42},l.foo()===42&&typeof l.subarray=="function"}catch{return!1}})(),d.isEncoding=function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.isBuffer=function(i){return!(i==null||!i._isBuffer)},d.byteLength=function(i,l){var h;switch(i+="",l||"utf8"){case"hex":h=i.length/2;break;case"utf8":case"utf-8":h=de(i).length;break;case"ascii":case"binary":case"raw":h=i.length;break;case"base64":h=Te(i).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":h=2*i.length;break;default:throw new Error("Unknown encoding")}return h},d.concat=function(i,l){if(E(K(i),`Usage: Buffer.concat(list, [totalLength])
|
|
@@ -17,4 +17,4 @@ N.version="2.30.1";Ln(te);N.fn=Y;N.min=Di;N.max=Mi;N.now=xi;N.utc=Ye;N.unix=eo;N
|
|
|
17
17
|
* Copyright(c) 2012-2017 Holiday Extras.
|
|
18
18
|
* Copyright(c) 2017 Roger C.
|
|
19
19
|
* MIT Licensed
|
|
20
|
-
*/var e=Pe,t=Pe,r=Uo,n=Pe,s=En(),u={};Bt=u;var g=["daily","test","m","h","custom"],T="YYYYMMDDHHmm",F=function(_,d){if(typeof d=="number"){switch(_){case"m":if(d<0||d>60)return!1;break;case"h":if(d<0||d>24)return!1;break}return{type:_,digit:d}}},L=function(_){switch(_){case"custom":case"daily":return{type:_,digit:void 0};case"test":return{type:_,digit:0}}return!1};u.getFrequency=function(_){var d=_.toLowerCase().match(/^(\d+)([mh])$/);if(d)return F(d[2],parseInt(d[1]));var m=L(_);return m||!1},u.parseFileSize=function(_){if(_&&typeof _=="string"){var d=_.toLowerCase().match(/^((?:0\.)?\d+)([kmg])$/);if(d)switch(d[2]){case"k":return d[1]*1024;case"m":return d[1]*1024*1024;case"g":return d[1]*1024*1024*1024}}return null},u.getDate=function(_,d,m){d=d||T;let v=m?r.utc():r().local();if(_&&g.indexOf(_.type)!==-1)switch(_.type){case"m":var S=Math.floor(v.minutes()/_.digit)*_.digit;return v.minutes(S).format(d);case"h":var b=Math.floor(v.hour()/_.digit)*_.digit;return v.hour(b).format(d);case"daily":case"custom":case"test":return v.format(d)}return v.format(d)},u.setAuditLog=function(_,d,m){var v=null;if(_){var S=_.toString().substr(-1),b=_.toString().match(/^(\d+)/);if(Number(b[1])>0){var D=t.dirname(m.replace(/%DATE%.+/,"_filename"));try{if(d){var c=t.resolve(d);v=JSON.parse(e.readFileSync(c,{encoding:"utf-8"}))}else{var c=t.resolve(D+"/.audit.json");v=JSON.parse(e.readFileSync(c,{encoding:"utf-8"}))}}catch(w){if(w.code!=="ENOENT")return null;v={keep:{days:!1,amount:Number(b[1])},auditLog:d||D+"/.audit.json",files:[]}}v.keep={days:S==="d",amount:Number(b[1])}}}return v},u.writeAuditLog=function(_,d){try{Q(_.auditLog),e.writeFileSync(_.auditLog,JSON.stringify(_,null,4))}catch(m){d&&console.error(new Date,"[FileStreamRotator] Failed to store log audit at:",_.auditLog,"Error:",m)}};function j(_,d){if(_.hash===n.createHash(_.hashType).update(_.name+"LOG_FILE"+_.date).digest("hex"))try{e.existsSync(_.name)&&e.unlinkSync(_.name)}catch{d&&console.error(new Date,"[FileStreamRotator] Could not remove old log file: ",_.name)}}function ee(_,d,m){let v=d||"current.log",S=t.dirname(_),b=t.basename(_),D=S+"/"+v;try{e.lstatSync(D).isSymbolicLink()&&(e.unlinkSync(D),e.symlinkSync(b,D))}catch(c){if(c&&c.code=="ENOENT")try{e.symlinkSync(b,D)}catch{m&&console.error(new Date,"[FileStreamRotator] Could not create symlink file: ",D," -> ",b)}}}function k(_,d,m){if(!_)return null;try{let v=e.lstatSync(_);return e.watch(_,function(S,b){if(S=="rename")try{let D=e.lstatSync(_)}catch(D){m(D,_)}})}catch{d&&console.log(new Date,"[FileStreamRotator] Could not add watcher for "+_)}}u.addLogToAudit=function(_,d,m,v){if(d&&d.files){var S=d.files.findIndex(function(o){return o.name===_});if(S!==-1)return d;var b=Date.now();if(d.files.push({date:b,name:_,hash:n.createHash(d.hashType).update(_+"LOG_FILE"+b).digest("hex")}),d.keep.days){var D=r().subtract(d.keep.amount,"days").valueOf(),c=d.files.filter(function(o){return o.date>D?!0:(o.hashType=d.hashType,j(o,v),m.emit("logRemoved",o),!1)});d.files=c}else{var w=d.files.splice(-d.keep.amount);d.files.length>0&&d.files.filter(function(o){return o.hashType=d.hashType,j(o,v),m.emit("logRemoved",o),!1}),d.files=w}u.writeAuditLog(d,v)}return d},u.getStream=function(_){var d=null,m=null,v=this;if(!_.filename)return console.error(new Date,"[FileStreamRotator] No filename supplied. Defaulting to STDOUT"),process.stdout;_.frequency&&(d=v.getFrequency(_.frequency));let S=v.setAuditLog(_.max_logs,_.audit_file,_.filename);S!=null&&(S.hashType=_.audit_hash_type!==void 0?_.audit_hash_type:"md5"),v.verbose=_.verbose!==void 0?_.verbose:!0;var b=null,D=0,c=0;_.size&&(b=u.parseFileSize(_.size));var w=_.date_format||T;d&&d.type=="daily"&&(_.date_format||(w="YYYY-MM-DD"),(r().format(w)!=r().endOf("day").format(w)||r().format(w)==r().add(1,"day").format(w))&&(v.verbose&&console.log(new Date,"[FileStreamRotator] Changing type to custom as date format changes more often than once a day or not every day"),d.type="custom")),d&&(m=_.frequency?v.getDate(d,w,_.utc):""),_.create_symlink=_.create_symlink||!1,_.extension=_.extension||"";var o=_.filename,f=null,a=o+(m?"."+m:"");if(o.match(/%DATE%/)&&(a=o.replace(/%DATE%/g,m||v.getDate(null,w,_.utc))),b){var y=null,p=a;if(S&&S.files&&S.files instanceof Array&&S.files.length>0){var P=S.files[S.files.length-1].name;if(P.match(p)){var U=P.match(p+"\\.(\\d+)");U&&(p=P,D=U[1])}}for(D==0&&p==a&&(p+=_.extension);e.existsSync(p);)y=p,D++,p=a+"."+D+_.extension;if(y){var C=e.statSync(y);C.size<b&&(p=y,D--,c=C.size)}a=p}else a+=_.extension;v.verbose&&console.log(new Date,"[FileStreamRotator] Logging to: ",a),Q(a);var R=_.file_options||{flags:"a"},B=e.createWriteStream(a,R);if(m&&d&&g.indexOf(d.type)>-1||b>0){v.verbose&&console.log(new Date,"[FileStreamRotator] Rotating file: ",d?d.type:"",b?"size: "+b:"");var V=new s;V.auditLog=S,V.end=function(){B.end.apply(B,arguments)},M(B,V),V.on("close",function(){K&&K.close()}),V.on("new",function(G){V.auditLog=v.addLogToAudit(G,V.auditLog,V,v.verbose),_.create_symlink&&ee(G,_.symlink_name,v.verbose),_.watch_log&&V.emit("addWatcher",G)});var K;return V.on("addWatcher",function(G){K&&K.close(),_.watch_log&&(K=k(G,v.verbose,function(de,Te){V.emit("createLog",Te)}))}),V.on("createLog",function(G){try{let de=e.lstatSync(G)}catch{B&&B.end=="function"&&B.end(),B=e.createWriteStream(G,R),V.emit("new",G),M(B,V)}}),V.write=(function(G,de){var Te=d?this.getDate(d,w,_.utc):m;if(Te!=m||b&&c>b){var ye=o+(m&&d?"."+Te:"");o.match(/%DATE%/)&&m&&(ye=o.replace(/%DATE%/g,Te)),b&&c>b?(D++,ye+="."+D+_.extension):(D=0,ye+=_.extension),c=0,v.verbose&&console.log(new Date,Fr().format("[FileStreamRotator] Changing logs from %s to %s",a,ye)),m=Te,f=a,a=ye,_.end_stream===!0?B.end():B.destroy(),Q(a),B=e.createWriteStream(ye,R),V.emit("new",ye),V.emit("rotate",f,ye),M(B,V)}B.write(G,de),c+=Buffer.byteLength(G,de)}).bind(this),process.nextTick(function(){V.emit("new",a)}),V.emit("new",a),V}else return v.verbose&&console.log(new Date,"[FileStreamRotator] File won't be rotated: ",_.frequency,_.size),process.nextTick(function(){B.emit("new",a)}),B};var Q=function(_){var d=t.dirname(_);d.split(t.sep).reduce(function(m,v){if(m+=v+t.sep,!e.existsSync(m))try{e.mkdirSync(m)}catch(S){if(S.code!=="EEXIST")throw S}return m},"")},M=function(d,m){d.on("close",function(){m.emit("close")}),d.on("finish",function(){m.emit("finish")}),d.on("error",function(v){m.emit("error",v)}),d.on("open",function(v){m.emit("open",v)})};return Bt}var Vt,Ir;function Co(){if(Ir)return Vt;Ir=1;const e=Pe,t=Pe,r=Pe,n=Fr(),s=Pe,u=Rn(),g=Nn().MESSAGE,T=Pe.PassThrough,F=In(),L={json:!1,colorize:!1,eol:t.EOL,logstash:null,prettyPrint:!1,label:null,stringify:!1,depth:null,showLevel:!0,timestamp:()=>new Date().toISOString()},j=function(k){k=k||{},F.call(this,k);function Q(m){Array.prototype.slice.call(arguments,1).forEach(v=>{if(k[v])throw new Error("Cannot set "+v+" and "+m+" together")})}function M(m){if(m&&typeof m=="string"){if(m.toLowerCase().match(/^((?:0\.)?\d+)([kmg])$/))return m}else if(m&&Number.isInteger(m)){const v=Math.round(m/1024);return v===0?"1k":v+"k"}return null}function _(m){return!/["<>|:*?\\/\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f]/g.test(m)}function d(m){return!/["<>|\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f]/g.test(m)}if(this.options=Object.assign({},L,k),k.stream)Q("stream","filename","maxsize"),this.logStream=new T,this.logStream.pipe(k.stream);else{if(this.filename=k.filename?r.basename(k.filename):"winston.log",this.dirname=k.dirname||r.dirname(k.filename),!_(this.filename)||!d(this.dirname))throw new Error("Your path or filename contain an invalid character.");this.logStream=Po().getStream({filename:r.join(this.dirname,this.filename),frequency:k.frequency?k.frequency:"custom",date_format:k.datePattern?k.datePattern:"YYYY-MM-DD",verbose:!1,size:M(k.maxSize),max_logs:k.maxFiles,end_stream:!0,audit_file:k.auditFile?k.auditFile:r.join(this.dirname,"."+u(k)+"-audit.json"),file_options:k.options?k.options:{flags:"a"},utc:k.utc?k.utc:!1,extension:k.extension?k.extension:"",create_symlink:k.createSymlink?k.createSymlink:!1,symlink_name:k.symlinkName?k.symlinkName:"current.log",watch_log:k.watchLog?k.watchLog:!1,audit_hash_type:k.auditHashType?k.auditHashType:"sha256"}),this.logStream.on("new",m=>{this.emit("new",m)}),this.logStream.on("rotate",(m,v)=>{this.emit("rotate",m,v)}),this.logStream.on("logRemoved",m=>{if(k.zippedArchive){const v=m.name+".gz";try{e.unlinkSync(v)}catch(S){if(S.code!=="ENOENT"){S.message=`Error occurred while removing ${v}: ${S.message}`,this.emit("error",S);return}}this.emit("logRemoved",v);return}this.emit("logRemoved",m.name)}),k.zippedArchive&&this.logStream.on("rotate",m=>{try{if(!e.existsSync(m))return}catch(D){D.message=`Error occurred while checking existence of ${m}: ${D.message}`,this.emit("error",D);return}try{if(e.existsSync(`${m}.gz`))return}catch(D){D.message=`Error occurred while checking existence of ${m}.gz: ${D.message}`,this.emit("error",D);return}const v=s.createGzip(),S=e.createReadStream(m);S.on("error",D=>{D.message=`Error occurred while reading ${m}: ${D.message}`,this.emit("error",D)});const b=e.createWriteStream(m+".gz");b.on("error",D=>{D.message=`Error occurred while writing ${m}.gz: ${D.message}`,this.emit("error",D)}),S.pipe(v).pipe(b).on("finish",()=>{try{e.unlinkSync(m)}catch(D){if(D.code!=="ENOENT"){D.message=`Error occurred while removing ${m}: ${D.message}`,this.emit("error",D);return}}this.emit("archive",m+".gz")})}),k.watchLog&&this.logStream.on("addWatcher",m=>{this.emit("addWatcher",m)})}};Vt=j,n.inherits(j,F),j.prototype.name="dailyRotateFile";const ee=function(){};return j.prototype.log=function(k,Q){Q=Q||ee,this.logStream.write(k[g]+this.options.eol),this.emit("logged",k),Q(null,!0)},j.prototype.close=function(){this.logStream&&this.logStream.end(()=>{this.emit("finish")})},j.prototype.query=function(k,Q){if(typeof k=="function"&&(Q=k,k={}),!this.options.json)throw new Error("query() may not be used without the json option being set to true");if(!this.filename)throw new Error("query() may not be used when initializing with a stream");let M=[];k=k||{},k.rows=k.rows||k.limit||10,k.start=k.start||0,k.until=k.until||new Date,typeof k.until!="object"&&(k.until=new Date(k.until)),k.from=k.from||k.until-1440*60*1e3,typeof k.from!="object"&&(k.from=new Date(k.from)),k.order=k.order||"desc";const _=(()=>{const m=new RegExp(this.filename.replace("%DATE%",".*"),"i");return e.readdirSync(this.dirname).filter(v=>r.basename(v).match(m))})();_.length===0&&Q&&Q(null,M);const d=m=>{if(!m)return;const v=r.join(this.dirname,m);let S="",b;if(m.endsWith(".gz")){b=new T;const c=e.createReadStream(v);c.on("error",w=>{w.message=`Error occurred while reading ${v}: ${w.message}`,b.emit("error",w)}),c.pipe(s.createGunzip()).pipe(b)}else b=e.createReadStream(v,{encoding:"utf8"});b.on("error",c=>{if(b.readable&&b.destroy(),!!Q)return c.code==="ENOENT"?Q(null,M):Q(c)}),b.on("data",c=>{c=(S+c).split(/\n+/);const w=c.length-1;for(let o=0;o<w;o++)D(c[o]);S=c[w]}),b.on("end",()=>{if(S&&D(S,!0),_.length)d(_.shift());else if(Q){M.sort((o,f)=>{const a=new Date(o.timestamp).getTime(),y=new Date(f.timestamp).getTime();return a>y?1:a<y?-1:0}),k.order==="desc"&&(M=M.reverse());const c=k.start||0,w=k.limit||M.length;M=M.slice(c,c+w),k.fields&&(M=M.map(o=>{const f={};return k.fields.forEach(a=>{f[a]=o[a]}),f})),Q(null,M)}});function D(c,w){try{const o=JSON.parse(c);if(!o||typeof o!="object")return;const f=new Date(o.timestamp);if(k.from&&f<k.from||k.until&&f>k.until||k.level&&k.level!==o.level)return;M.push(o)}catch(o){w||b.emit("error",o)}}};d(_.shift())},Vt}var Gt,Ar;function jo(){if(Ar)return Gt;Ar=1;const e=An(),t=Co();return e.transports.DailyRotateFile=t,Gt=t,Gt}var Yn=jo();const Ho=Tn(Yn),qo=Fn({__proto__:null,default:Ho},[Yn]);export{qo as i};
|
|
20
|
+
*/var e=Pe,t=Pe,r=Uo,n=Pe,s=En(),u={};Bt=u;var g=["daily","test","m","h","custom"],T="YYYYMMDDHHmm",F=function(_,d){if(typeof d=="number"){switch(_){case"m":if(d<0||d>60)return!1;break;case"h":if(d<0||d>24)return!1;break}return{type:_,digit:d}}},L=function(_){switch(_){case"custom":case"daily":return{type:_,digit:void 0};case"test":return{type:_,digit:0}}return!1};u.getFrequency=function(_){var d=_.toLowerCase().match(/^(\d+)([mh])$/);if(d)return F(d[2],parseInt(d[1]));var m=L(_);return m||!1},u.parseFileSize=function(_){if(_&&typeof _=="string"){var d=_.toLowerCase().match(/^((?:0\.)?\d+)([kmg])$/);if(d)switch(d[2]){case"k":return d[1]*1024;case"m":return d[1]*1024*1024;case"g":return d[1]*1024*1024*1024}}return null},u.getDate=function(_,d,m){d=d||T;let v=m?r.utc():r().local();if(_&&g.indexOf(_.type)!==-1)switch(_.type){case"m":var S=Math.floor(v.minutes()/_.digit)*_.digit;return v.minutes(S).format(d);case"h":var b=Math.floor(v.hour()/_.digit)*_.digit;return v.hour(b).format(d);case"daily":case"custom":case"test":return v.format(d)}return v.format(d)},u.setAuditLog=function(_,d,m){var v=null;if(_){var S=_.toString().substr(-1),b=_.toString().match(/^(\d+)/);if(Number(b[1])>0){var D=t.dirname(m.replace(/%DATE%.+/,"_filename"));try{if(d){var c=t.resolve(d);v=JSON.parse(e.readFileSync(c,{encoding:"utf-8"}))}else{var c=t.resolve(D+"/.audit.json");v=JSON.parse(e.readFileSync(c,{encoding:"utf-8"}))}}catch(w){if(w.code!=="ENOENT")return null;v={keep:{days:!1,amount:Number(b[1])},auditLog:d||D+"/.audit.json",files:[]}}v.keep={days:S==="d",amount:Number(b[1])}}}return v},u.writeAuditLog=function(_,d){try{Q(_.auditLog),e.writeFileSync(_.auditLog,JSON.stringify(_,null,4))}catch(m){d&&console.error(new Date,"[FileStreamRotator] Failed to store log audit at:",_.auditLog,"Error:",m)}};function j(_,d){if(_.hash===n.createHash(_.hashType).update(_.name+"LOG_FILE"+_.date).digest("hex"))try{e.existsSync(_.name)&&e.unlinkSync(_.name)}catch{d&&console.error(new Date,"[FileStreamRotator] Could not remove old log file: ",_.name)}}function ee(_,d,m){let v=d||"current.log",S=t.dirname(_),b=t.basename(_),D=S+"/"+v;try{e.lstatSync(D).isSymbolicLink()&&(e.unlinkSync(D),e.symlinkSync(b,D))}catch(c){if(c&&c.code=="ENOENT")try{e.symlinkSync(b,D)}catch{m&&console.error(new Date,"[FileStreamRotator] Could not create symlink file: ",D," -> ",b)}}}function k(_,d,m){if(!_)return null;try{let v=e.lstatSync(_);return e.watch(_,function(S,b){if(S=="rename")try{let D=e.lstatSync(_)}catch(D){m(D,_)}})}catch{d&&console.log(new Date,"[FileStreamRotator] Could not add watcher for "+_)}}u.addLogToAudit=function(_,d,m,v){if(d&&d.files){var S=d.files.findIndex(function(o){return o.name===_});if(S!==-1)return d;var b=Date.now();if(d.files.push({date:b,name:_,hash:n.createHash(d.hashType).update(_+"LOG_FILE"+b).digest("hex")}),d.keep.days){var D=r().subtract(d.keep.amount,"days").valueOf(),c=d.files.filter(function(o){return o.date>D?!0:(o.hashType=d.hashType,j(o,v),m.emit("logRemoved",o),!1)});d.files=c}else{var w=d.files.splice(-d.keep.amount);d.files.length>0&&d.files.filter(function(o){return o.hashType=d.hashType,j(o,v),m.emit("logRemoved",o),!1}),d.files=w}u.writeAuditLog(d,v)}return d},u.getStream=function(_){var d=null,m=null,v=this;if(!_.filename)return console.error(new Date,"[FileStreamRotator] No filename supplied. Defaulting to STDOUT"),process.stdout;_.frequency&&(d=v.getFrequency(_.frequency));let S=v.setAuditLog(_.max_logs,_.audit_file,_.filename);S!=null&&(S.hashType=_.audit_hash_type!==void 0?_.audit_hash_type:"md5"),v.verbose=_.verbose!==void 0?_.verbose:!0;var b=null,D=0,c=0;_.size&&(b=u.parseFileSize(_.size));var w=_.date_format||T;d&&d.type=="daily"&&(_.date_format||(w="YYYY-MM-DD"),(r().format(w)!=r().endOf("day").format(w)||r().format(w)==r().add(1,"day").format(w))&&(v.verbose&&console.log(new Date,"[FileStreamRotator] Changing type to custom as date format changes more often than once a day or not every day"),d.type="custom")),d&&(m=_.frequency?v.getDate(d,w,_.utc):""),_.create_symlink=_.create_symlink||!1,_.extension=_.extension||"";var o=_.filename,f=null,a=o+(m?"."+m:"");if(o.match(/%DATE%/)&&(a=o.replace(/%DATE%/g,m||v.getDate(null,w,_.utc))),b){var y=null,p=a;if(S&&S.files&&S.files instanceof Array&&S.files.length>0){var P=S.files[S.files.length-1].name;if(P.match(p)){var U=P.match(p+"\\.(\\d+)");U&&(p=P,D=U[1])}}for(D==0&&p==a&&(p+=_.extension);e.existsSync(p);)y=p,D++,p=a+"."+D+_.extension;if(y){var C=e.statSync(y);C.size<b&&(p=y,D--,c=C.size)}a=p}else a+=_.extension;v.verbose&&console.log(new Date,"[FileStreamRotator] Logging to: ",a),Q(a);var R=_.file_options||{flags:"a"},B=e.createWriteStream(a,R);if(m&&d&&g.indexOf(d.type)>-1||b>0){v.verbose&&console.log(new Date,"[FileStreamRotator] Rotating file: ",d?d.type:"",b?"size: "+b:"");var V=new s;V.auditLog=S,V.end=function(){B.end.apply(B,arguments)},M(B,V),V.on("close",function(){K&&K.close()}),V.on("new",function(G){V.auditLog=v.addLogToAudit(G,V.auditLog,V,v.verbose),_.create_symlink&&ee(G,_.symlink_name,v.verbose),_.watch_log&&V.emit("addWatcher",G)});var K;return V.on("addWatcher",function(G){K&&K.close(),_.watch_log&&(K=k(G,v.verbose,function(de,Te){V.emit("createLog",Te)}))}),V.on("createLog",function(G){try{let de=e.lstatSync(G)}catch{B&&B.end=="function"&&B.end(),B=e.createWriteStream(G,R),V.emit("new",G),M(B,V)}}),V.write=(function(G,de){var Te=d?this.getDate(d,w,_.utc):m;if(Te!=m||b&&c>b){var ye=o+(m&&d?"."+Te:"");o.match(/%DATE%/)&&m&&(ye=o.replace(/%DATE%/g,Te)),b&&c>b?(D++,ye+="."+D+_.extension):(D=0,ye+=_.extension),c=0,v.verbose&&console.log(new Date,Fr().format("[FileStreamRotator] Changing logs from %s to %s",a,ye)),m=Te,f=a,a=ye,_.end_stream===!0?B.end():B.destroy(),Q(a),B=e.createWriteStream(ye,R),V.emit("new",ye),V.emit("rotate",f,ye),M(B,V)}B.write(G,de),c+=Buffer.byteLength(G,de)}).bind(this),process.nextTick(function(){V.emit("new",a)}),V.emit("new",a),V}else return v.verbose&&console.log(new Date,"[FileStreamRotator] File won't be rotated: ",_.frequency,_.size),process.nextTick(function(){B.emit("new",a)}),B};var Q=function(_){var d=t.dirname(_);d.split(t.sep).reduce(function(m,v){if(m+=v+t.sep,!e.existsSync(m))try{e.mkdirSync(m)}catch(S){if(S.code!=="EEXIST")throw S}return m},"")},M=function(d,m){d.on("close",function(){m.emit("close")}),d.on("finish",function(){m.emit("finish")}),d.on("error",function(v){m.emit("error",v)}),d.on("open",function(v){m.emit("open",v)})};return Bt}var Vt,Ir;function Co(){if(Ir)return Vt;Ir=1;const e=Pe,t=Pe,r=Pe,n=Fr(),s=Pe,u=Rn(),g=Nn().MESSAGE,T=Pe.PassThrough,F=In(),L={json:!1,colorize:!1,eol:t.EOL,logstash:null,prettyPrint:!1,label:null,stringify:!1,depth:null,showLevel:!0,timestamp:()=>new Date().toISOString()},j=function(k){k=k||{},F.call(this,k);function Q(m){Array.prototype.slice.call(arguments,1).forEach(v=>{if(k[v])throw new Error("Cannot set "+v+" and "+m+" together")})}function M(m){if(m&&typeof m=="string"){if(m.toLowerCase().match(/^((?:0\.)?\d+)([kmg])$/))return m}else if(m&&Number.isInteger(m)){const v=Math.round(m/1024);return v===0?"1k":v+"k"}return null}function _(m){return!/["<>|:*?\\/\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f]/g.test(m)}function d(m){return!/["<>|\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f]/g.test(m)}if(this.options=Object.assign({},L,k),k.stream)Q("stream","filename","maxsize"),this.logStream=new T,this.logStream.pipe(k.stream);else{if(this.filename=k.filename?r.basename(k.filename):"winston.log",this.dirname=k.dirname||r.dirname(k.filename),!_(this.filename)||!d(this.dirname))throw new Error("Your path or filename contain an invalid character.");this.logStream=Po().getStream({filename:r.join(this.dirname,this.filename),frequency:k.frequency?k.frequency:"custom",date_format:k.datePattern?k.datePattern:"YYYY-MM-DD",verbose:!1,size:M(k.maxSize),max_logs:k.maxFiles,end_stream:!0,audit_file:k.auditFile?k.auditFile:r.join(this.dirname,"."+u(k)+"-audit.json"),file_options:k.options?k.options:{flags:"a"},utc:k.utc?k.utc:!1,extension:k.extension?k.extension:"",create_symlink:k.createSymlink?k.createSymlink:!1,symlink_name:k.symlinkName?k.symlinkName:"current.log",watch_log:k.watchLog?k.watchLog:!1,audit_hash_type:k.auditHashType?k.auditHashType:"sha256"}),this.logStream.on("new",m=>{this.emit("new",m)}),this.logStream.on("rotate",(m,v)=>{this.emit("rotate",m,v)}),this.logStream.on("logRemoved",m=>{if(k.zippedArchive){const v=m.name+".gz";try{e.unlinkSync(v)}catch(S){if(S.code!=="ENOENT"){S.message=`Error occurred while removing ${v}: ${S.message}`,this.emit("error",S);return}}this.emit("logRemoved",v);return}this.emit("logRemoved",m.name)}),k.zippedArchive&&this.logStream.on("rotate",m=>{try{if(!e.existsSync(m))return}catch(D){D.message=`Error occurred while checking existence of ${m}: ${D.message}`,this.emit("error",D);return}try{if(e.existsSync(`${m}.gz`))return}catch(D){D.message=`Error occurred while checking existence of ${m}.gz: ${D.message}`,this.emit("error",D);return}const v=s.createGzip(),S=e.createReadStream(m);S.on("error",D=>{D.message=`Error occurred while reading ${m}: ${D.message}`,this.emit("error",D)});const b=e.createWriteStream(m+".gz");b.on("error",D=>{D.message=`Error occurred while writing ${m}.gz: ${D.message}`,this.emit("error",D)}),S.pipe(v).pipe(b).on("finish",()=>{try{e.unlinkSync(m)}catch(D){if(D.code!=="ENOENT"){D.message=`Error occurred while removing ${m}: ${D.message}`,this.emit("error",D);return}}this.emit("archive",m+".gz")})}),k.watchLog&&this.logStream.on("addWatcher",m=>{this.emit("addWatcher",m)})}};Vt=j,n.inherits(j,F),j.prototype.name="dailyRotateFile";const ee=function(){};return j.prototype.log=function(k,Q){Q=Q||ee,this.logStream.write(k[g]+this.options.eol),this.emit("logged",k),Q(null,!0)},j.prototype.close=function(){this.logStream&&this.logStream.end(()=>{this.emit("finish")})},j.prototype.query=function(k,Q){if(typeof k=="function"&&(Q=k,k={}),!this.options.json)throw new Error("query() may not be used without the json option being set to true");if(!this.filename)throw new Error("query() may not be used when initializing with a stream");let M=[];k=k||{},k.rows=k.rows||k.limit||10,k.start=k.start||0,k.until=k.until||new Date,typeof k.until!="object"&&(k.until=new Date(k.until)),k.from=k.from||k.until-1440*60*1e3,typeof k.from!="object"&&(k.from=new Date(k.from)),k.order=k.order||"desc";const _=(()=>{const m=new RegExp(this.filename.replace("%DATE%",".*"),"i");return e.readdirSync(this.dirname).filter(v=>r.basename(v).match(m))})();_.length===0&&Q&&Q(null,M);const d=m=>{if(!m)return;const v=r.join(this.dirname,m);let S="",b;if(m.endsWith(".gz")){b=new T;const c=e.createReadStream(v);c.on("error",w=>{w.message=`Error occurred while reading ${v}: ${w.message}`,b.emit("error",w)}),c.pipe(s.createGunzip()).pipe(b)}else b=e.createReadStream(v,{encoding:"utf8"});b.on("error",c=>{if(b.readable&&b.destroy(),!!Q)return c.code==="ENOENT"?Q(null,M):Q(c)}),b.on("data",c=>{c=(S+c).split(/\n+/);const w=c.length-1;for(let o=0;o<w;o++)D(c[o]);S=c[w]}),b.on("end",()=>{if(S&&D(S,!0),_.length)d(_.shift());else if(Q){M.sort((o,f)=>{const a=new Date(o.timestamp).getTime(),y=new Date(f.timestamp).getTime();return a>y?1:a<y?-1:0}),k.order==="desc"&&(M=M.reverse());const c=k.start||0,w=k.limit||M.length;M=M.slice(c,c+w),k.fields&&(M=M.map(o=>{const f={};return k.fields.forEach(a=>{f[a]=o[a]}),f})),Q(null,M)}});function D(c,w){try{const o=JSON.parse(c);if(!o||typeof o!="object")return;const f=new Date(o.timestamp);if(k.from&&f<k.from||k.until&&f>k.until||k.level&&k.level!==o.level)return;M.push(o)}catch(o){w||b.emit("error",o)}}};d(_.shift())},Vt}var Gt,Ar;function jo(){if(Ar)return Gt;Ar=1;const e=An(),t=Co();return e.transports.DailyRotateFile=t,Gt=t,Gt}var Yn=jo();const Ho=Tn(Yn),$o=Fn({__proto__:null,default:Ho},[Yn]);export{$o as i};
|