From ca1c827fec650960126aae20b3a6258f408d3f57 Mon Sep 17 00:00:00 2001 From: Agusx1211 Date: Wed, 15 Nov 2023 20:36:00 +0000 Subject: [PATCH] Build: (6233328) Remove hardcoded region --- assets/{index-28df1cf2.js => index-f0bf66e2.js} | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename assets/{index-28df1cf2.js => index-f0bf66e2.js} (99%) diff --git a/assets/index-28df1cf2.js b/assets/index-f0bf66e2.js similarity index 99% rename from assets/index-28df1cf2.js rename to assets/index-f0bf66e2.js index 99c4415..a65fc0d 100644 --- a/assets/index-28df1cf2.js +++ b/assets/index-f0bf66e2.js @@ -168,4 +168,4 @@ ${vn(o)}`}getCanonicalPath({path:t}){if(this.uriEscapePath){const r=[];for(const * https://github.com/lancedikson/bowser * MIT License | (c) Dustin Diaz 2012-2015 * MIT License | (c) Denis Demchenko 2015-2019 - */class YA{static getParser(t,r=!1){if(typeof t!="string")throw new Error("UserAgent should be a string");return new G6(t,r)}static parse(t){return new G6(t).getResult()}static get BROWSER_MAP(){return KA}static get ENGINE_MAP(){return xo}static get OS_MAP(){return kr}static get PLATFORMS_MAP(){return Lt}}const bx=({serviceId:e,clientVersion:t})=>async()=>{var i,o,s,a,l;const r=typeof window<"u"&&((i=window==null?void 0:window.navigator)!=null&&i.userAgent)?YA.parse(window.navigator.userAgent):void 0,n=[["aws-sdk-js",t],["ua","2.0"],[`os/${((o=r==null?void 0:r.os)==null?void 0:o.name)||"other"}`,(s=r==null?void 0:r.os)==null?void 0:s.version],["lang/js"],["md/browser",`${((a=r==null?void 0:r.browser)==null?void 0:a.name)??"unknown"}_${((l=r==null?void 0:r.browser)==null?void 0:l.version)??"unknown"}`]];return e&&n.push([`api/${e}`,t]),n},wx=e=>()=>Promise.reject(e),Ex=e=>{if(typeof e=="string"){let t=e.length;for(let r=t-1;r>=0;r--){const n=e.charCodeAt(r);n>127&&n<=2047?t++:n>2047&&n<=65535&&(t+=2),n>=56320&&n<=57343&&r--}return t}else{if(typeof e.byteLength=="number")return e.byteLength;if(typeof e.size=="number")return e.size}throw new Error(`Body Length computation failed for ${e}`)},QA="required",pi="fn",mi="argv",Al="ref",W6=!0,K6="isSet",Tf="booleanEquals",Js="error",cc="endpoint",Li="tree",Cx="PartitionResult",Y6={[QA]:!1,type:"String"},Q6={[QA]:!0,default:!1,type:"Boolean"},J6={[Al]:"Endpoint"},JA={[pi]:Tf,[mi]:[{[Al]:"UseFIPS"},!0]},XA={[pi]:Tf,[mi]:[{[Al]:"UseDualStack"},!0]},si={},X6={[pi]:"getAttr",[mi]:[{[Al]:Cx},"supportsFIPS"]},Z6={[pi]:Tf,[mi]:[!0,{[pi]:"getAttr",[mi]:[{[Al]:Cx},"supportsDualStack"]}]},e4=[JA],t4=[XA],r4=[{[Al]:"Region"}],iK={version:"1.0",parameters:{Region:Y6,UseDualStack:Q6,UseFIPS:Q6,Endpoint:Y6},rules:[{conditions:[{[pi]:K6,[mi]:[J6]}],rules:[{conditions:e4,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:Js},{conditions:t4,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:Js},{endpoint:{url:J6,properties:si,headers:si},type:cc}],type:Li},{conditions:[{[pi]:K6,[mi]:r4}],rules:[{conditions:[{[pi]:"aws.partition",[mi]:r4,assign:Cx}],rules:[{conditions:[JA,XA],rules:[{conditions:[{[pi]:Tf,[mi]:[W6,X6]},Z6],rules:[{endpoint:{url:"https://cognito-identity-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:si,headers:si},type:cc}],type:Li},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:Js}],type:Li},{conditions:e4,rules:[{conditions:[{[pi]:Tf,[mi]:[X6,W6]}],rules:[{endpoint:{url:"https://cognito-identity-fips.{Region}.{PartitionResult#dnsSuffix}",properties:si,headers:si},type:cc}],type:Li},{error:"FIPS is enabled but this partition does not support FIPS",type:Js}],type:Li},{conditions:t4,rules:[{conditions:[Z6],rules:[{endpoint:{url:"https://cognito-identity.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:si,headers:si},type:cc}],type:Li},{error:"DualStack is enabled but this partition does not support DualStack",type:Js}],type:Li},{endpoint:{url:"https://cognito-identity.{Region}.{PartitionResult#dnsSuffix}",properties:si,headers:si},type:cc}],type:Li}],type:Li},{error:"Invalid Configuration: Missing Region",type:Js}]},oK=iK,sK=(e,t={})=>ex(oK,{endpointParams:e,logger:t.logger}),aK=e=>({apiVersion:"2014-06-30",base64Decoder:(e==null?void 0:e.base64Decoder)??Kf,base64Encoder:(e==null?void 0:e.base64Encoder)??Q0,disableHostPrefix:(e==null?void 0:e.disableHostPrefix)??!1,endpointProvider:(e==null?void 0:e.endpointProvider)??sK,extensions:(e==null?void 0:e.extensions)??[],logger:(e==null?void 0:e.logger)??new fx,serviceId:(e==null?void 0:e.serviceId)??"Cognito Identity",urlParser:(e==null?void 0:e.urlParser)??tl,utf8Decoder:(e==null?void 0:e.utf8Decoder)??bl,utf8Encoder:(e==null?void 0:e.utf8Encoder)??Wf}),lK=["in-region","cross-region","mobile","standard","legacy"],Sx=({defaultsMode:e}={})=>vA(async()=>{const t=typeof e=="function"?await e():e;switch(t==null?void 0:t.toLowerCase()){case"auto":return Promise.resolve(cK()?"mobile":"standard");case"mobile":case"in-region":case"cross-region":case"standard":case"legacy":return Promise.resolve(t==null?void 0:t.toLocaleLowerCase());case void 0:return Promise.resolve("legacy");default:throw new Error(`Invalid parameter for "defaultsMode", expect ${lK.join(", ")}, got ${t}`)}}),cK=()=>{var r,n;const e=typeof window<"u"&&((r=window==null?void 0:window.navigator)!=null&&r.userAgent)?YA.parse(window.navigator.userAgent):void 0,t=(n=e==null?void 0:e.platform)==null?void 0:n.type;return t==="tablet"||t==="mobile"},fK=e=>{const t=Sx(e),r=()=>t().then(px),n=aK(e);return{...n,...e,runtime:"browser",defaultsMode:t,bodyLengthChecker:(e==null?void 0:e.bodyLengthChecker)??Ex,credentialDefaultProvider:(e==null?void 0:e.credentialDefaultProvider)??(i=>()=>Promise.reject(new Error("Credential is missing"))),defaultUserAgentProvider:(e==null?void 0:e.defaultUserAgentProvider)??bx({serviceId:n.serviceId,clientVersion:OW.version}),maxAttempts:(e==null?void 0:e.maxAttempts)??nl,region:(e==null?void 0:e.region)??wx("Region is missing"),requestHandler:(e==null?void 0:e.requestHandler)??new dx(r),retryMode:(e==null?void 0:e.retryMode)??(async()=>(await r()).retryMode||ax),sha256:(e==null?void 0:e.sha256)??J0.Sha256,streamCollector:(e==null?void 0:e.streamCollector)??hx,useDualstackEndpoint:(e==null?void 0:e.useDualstackEndpoint)??(()=>Promise.resolve(rx)),useFipsEndpoint:(e==null?void 0:e.useFipsEndpoint)??(()=>Promise.resolve(nx))}},Ax=e=>{let t=async()=>{if(e.region===void 0)throw new Error("Region is missing from runtimeConfig");const r=e.region;return typeof r=="string"?r:r()};return{setRegion(r){t=r},region(){return t}}},kx=e=>({region:e.region()}),K1=e=>e,uK=(e,t)=>{const r={...K1(Ax(e)),...K1(mx(e)),...K1(qm(e))};return t.forEach(n=>n.configure(r)),{...e,...kx(r),...xx(r),...Hm(r)}};class dK extends ux{constructor(...[t]){const r=fK(t||{}),n=mW(r),i=ix(n),o=sx(i),s=lx(o),a=s,l=Qm(a),c=Jm(l),f=uK(c,(t==null?void 0:t.extensions)||[]);super(f),this.config=f,this.middlewareStack.use(cx(this.config)),this.middlewareStack.use(ox(this.config)),this.middlewareStack.use(Gm(this.config)),this.middlewareStack.use(Wm(this.config)),this.middlewareStack.use(Km(this.config)),this.middlewareStack.use(tx(this.config))}destroy(){super.destroy()}}class kn extends Yf{constructor(t){super(t),Object.setPrototypeOf(this,kn.prototype)}}let hK=class ZA extends kn{constructor(t){super({name:"InternalErrorException",$fault:"server",...t}),this.name="InternalErrorException",this.$fault="server",Object.setPrototypeOf(this,ZA.prototype)}},vK=class e9 extends kn{constructor(t){super({name:"InvalidParameterException",$fault:"client",...t}),this.name="InvalidParameterException",this.$fault="client",Object.setPrototypeOf(this,e9.prototype)}};class Rx extends kn{constructor(t){super({name:"LimitExceededException",$fault:"client",...t}),this.name="LimitExceededException",this.$fault="client",Object.setPrototypeOf(this,Rx.prototype)}}let yK=class t9 extends kn{constructor(t){super({name:"NotAuthorizedException",$fault:"client",...t}),this.name="NotAuthorizedException",this.$fault="client",Object.setPrototypeOf(this,t9.prototype)}};class Px extends kn{constructor(t){super({name:"ResourceConflictException",$fault:"client",...t}),this.name="ResourceConflictException",this.$fault="client",Object.setPrototypeOf(this,Px.prototype)}}let pK=class r9 extends kn{constructor(t){super({name:"TooManyRequestsException",$fault:"client",...t}),this.name="TooManyRequestsException",this.$fault="client",Object.setPrototypeOf(this,r9.prototype)}},mK=class n9 extends kn{constructor(t){super({name:"ResourceNotFoundException",$fault:"client",...t}),this.name="ResourceNotFoundException",this.$fault="client",Object.setPrototypeOf(this,n9.prototype)}};class Tx extends kn{constructor(t){super({name:"ExternalServiceException",$fault:"client",...t}),this.name="ExternalServiceException",this.$fault="client",Object.setPrototypeOf(this,Tx.prototype)}}class _x extends kn{constructor(t){super({name:"InvalidIdentityPoolConfigurationException",$fault:"client",...t}),this.name="InvalidIdentityPoolConfigurationException",this.$fault="client",Object.setPrototypeOf(this,_x.prototype)}}const xK=async(e,t)=>{const r=h9("GetCredentialsForIdentity");let n;return n=JSON.stringify(we(e)),d9(t,r,"/",void 0,n)},gK=async(e,t)=>{const r=h9("GetId");let n;return n=JSON.stringify(we(e)),d9(t,r,"/",void 0,n)},bK=async(e,t)=>{if(e.statusCode>=300)return wK(e,t);const r=await Mx(e.body,t);let n={};return n=RK(r),{$metadata:Zn(e),...n}},wK=async(e,t)=>{const r={...e,body:await v9(e.body,t)},n=y9(e,r.body);switch(n){case"ExternalServiceException":case"com.amazonaws.cognitoidentity#ExternalServiceException":throw await i9(r);case"InternalErrorException":case"com.amazonaws.cognitoidentity#InternalErrorException":throw await o9(r);case"InvalidIdentityPoolConfigurationException":case"com.amazonaws.cognitoidentity#InvalidIdentityPoolConfigurationException":throw await SK(r);case"InvalidParameterException":case"com.amazonaws.cognitoidentity#InvalidParameterException":throw await s9(r);case"NotAuthorizedException":case"com.amazonaws.cognitoidentity#NotAuthorizedException":throw await a9(r);case"ResourceConflictException":case"com.amazonaws.cognitoidentity#ResourceConflictException":throw await l9(r);case"ResourceNotFoundException":case"com.amazonaws.cognitoidentity#ResourceNotFoundException":throw await c9(r);case"TooManyRequestsException":case"com.amazonaws.cognitoidentity#TooManyRequestsException":throw await f9(r);default:const i=r.body;return u9({output:e,parsedBody:i,errorCode:n})}},EK=async(e,t)=>{if(e.statusCode>=300)return CK(e,t);const r=await Mx(e.body,t);let n={};return n=we(r),{$metadata:Zn(e),...n}},CK=async(e,t)=>{const r={...e,body:await v9(e.body,t)},n=y9(e,r.body);switch(n){case"ExternalServiceException":case"com.amazonaws.cognitoidentity#ExternalServiceException":throw await i9(r);case"InternalErrorException":case"com.amazonaws.cognitoidentity#InternalErrorException":throw await o9(r);case"InvalidParameterException":case"com.amazonaws.cognitoidentity#InvalidParameterException":throw await s9(r);case"LimitExceededException":case"com.amazonaws.cognitoidentity#LimitExceededException":throw await AK(r);case"NotAuthorizedException":case"com.amazonaws.cognitoidentity#NotAuthorizedException":throw await a9(r);case"ResourceConflictException":case"com.amazonaws.cognitoidentity#ResourceConflictException":throw await l9(r);case"ResourceNotFoundException":case"com.amazonaws.cognitoidentity#ResourceNotFoundException":throw await c9(r);case"TooManyRequestsException":case"com.amazonaws.cognitoidentity#TooManyRequestsException":throw await f9(r);default:const i=r.body;return u9({output:e,parsedBody:i,errorCode:n})}},i9=async(e,t)=>{const r=e.body,n=we(r),i=new Tx({$metadata:Zn(e),...n});return Te(i,r)},o9=async(e,t)=>{const r=e.body,n=we(r),i=new hK({$metadata:Zn(e),...n});return Te(i,r)},SK=async(e,t)=>{const r=e.body,n=we(r),i=new _x({$metadata:Zn(e),...n});return Te(i,r)},s9=async(e,t)=>{const r=e.body,n=we(r),i=new vK({$metadata:Zn(e),...n});return Te(i,r)},AK=async(e,t)=>{const r=e.body,n=we(r),i=new Rx({$metadata:Zn(e),...n});return Te(i,r)},a9=async(e,t)=>{const r=e.body,n=we(r),i=new yK({$metadata:Zn(e),...n});return Te(i,r)},l9=async(e,t)=>{const r=e.body,n=we(r),i=new Px({$metadata:Zn(e),...n});return Te(i,r)},c9=async(e,t)=>{const r=e.body,n=we(r),i=new mK({$metadata:Zn(e),...n});return Te(i,r)},f9=async(e,t)=>{const r=e.body,n=we(r),i=new pK({$metadata:Zn(e),...n});return Te(i,r)},kK=(e,t)=>Qf(e,{AccessKeyId:Wc,Expiration:r=>nW(aW(qy(r))),SecretKey:Wc,SessionToken:Wc}),RK=(e,t)=>Qf(e,{Credentials:r=>kK(r),IdentityId:Wc}),Zn=e=>({httpStatusCode:e.statusCode,requestId:e.headers["x-amzn-requestid"]??e.headers["x-amzn-request-id"]??e.headers["x-amz-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}),PK=(e,t)=>vx(e,t).then(r=>t.utf8Encoder(r)),u9=yx(kn),d9=async(e,t,r,n,i)=>{const{hostname:o,protocol:s="https",port:a,path:l}=await e.endpoint(),c={protocol:s,hostname:o,port:a,method:"POST",path:l.endsWith("/")?l.slice(0,-1)+r:l+r,headers:t};return n!==void 0&&(c.hostname=n),i!==void 0&&(c.body=i),new Cn(c)};function h9(e){return{"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityService.${e}`}}const Mx=(e,t)=>PK(e,t).then(r=>r.length?JSON.parse(r):{}),v9=async(e,t)=>{const r=await Mx(e,t);return r.message=r.message??r.Message,r},y9=(e,t)=>{const r=(o,s)=>Object.keys(o).find(a=>a.toLowerCase()===s.toLowerCase()),n=o=>{let s=o;return typeof s=="number"&&(s=s.toString()),s.indexOf(",")>=0&&(s=s.split(",")[0]),s.indexOf(":")>=0&&(s=s.split(":")[0]),s.indexOf("#")>=0&&(s=s.split("#")[1]),s},i=r(e.headers,"x-amzn-errortype");if(i!==void 0)return n(e.headers[i]);if(t.code!==void 0)return n(t.code);if(t.__type!==void 0)return n(t.__type)};class Ix extends Sl{static getEndpointParameterInstructions(){return{UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}}}constructor(t){super(),this.input=t}resolveMiddleware(t,r,n){this.middlewareStack.use(wl(r,this.serialize,this.deserialize)),this.middlewareStack.use(El(r,Ix.getEndpointParameterInstructions()));const i=t.concat(this.middlewareStack),{logger:o}=r,l={logger:o,clientName:"CognitoIdentityClient",commandName:"GetCredentialsForIdentityCommand",inputFilterSensitiveLog:f=>f,outputFilterSensitiveLog:f=>f,[xl]:{service:"AWSCognitoIdentityService",operation:"GetCredentialsForIdentity"}},{requestHandler:c}=r;return i.resolve(f=>c.handle(f.request,n||{}),l)}serialize(t,r){return xK(t,r)}deserialize(t,r){return bK(t,r)}}class Nx extends Sl{static getEndpointParameterInstructions(){return{UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}}}constructor(t){super(),this.input=t}resolveMiddleware(t,r,n){this.middlewareStack.use(wl(r,this.serialize,this.deserialize)),this.middlewareStack.use(El(r,Nx.getEndpointParameterInstructions()));const i=t.concat(this.middlewareStack),{logger:o}=r,l={logger:o,clientName:"CognitoIdentityClient",commandName:"GetIdCommand",inputFilterSensitiveLog:f=>f,outputFilterSensitiveLog:f=>f,[xl]:{service:"AWSCognitoIdentityService",operation:"GetId"}},{requestHandler:c}=r;return i.resolve(f=>c.handle(f.request,n||{}),l)}serialize(t,r){return gK(t,r)}deserialize(t,r){return EK(t,r)}}function p9(e){return Promise.all(Object.keys(e).reduce((t,r)=>{const n=e[r];return typeof n=="string"?t.push([r,n]):t.push(n().then(i=>[r,i])),t},[])).then(t=>t.reduce((r,[n,i])=>(r[n]=i,r),{}))}function TK(e){return async()=>{const{Credentials:{AccessKeyId:t=_K(),Expiration:r,SecretKey:n=IK(),SessionToken:i}=MK()}=await e.client.send(new Ix({CustomRoleArn:e.customRoleArn,IdentityId:e.identityId,Logins:e.logins?await p9(e.logins):void 0}));return{identityId:e.identityId,accessKeyId:t,secretAccessKey:n,sessionToken:i,expiration:r}}}function _K(){throw new gl("Response from Amazon Cognito contained no access key ID")}function MK(){throw new gl("Response from Amazon Cognito contained no credentials")}function IK(){throw new gl("Response from Amazon Cognito contained no secret key")}const Y1="IdentityIds";class NK{constructor(t="aws:cognito-identity-ids"){this.dbName=t}getItem(t){return this.withObjectStore("readonly",r=>{const n=r.get(t);return new Promise(i=>{n.onerror=()=>i(null),n.onsuccess=()=>i(n.result?n.result.value:null)})}).catch(()=>null)}removeItem(t){return this.withObjectStore("readwrite",r=>{const n=r.delete(t);return new Promise((i,o)=>{n.onerror=()=>o(n.error),n.onsuccess=()=>i()})})}setItem(t,r){return this.withObjectStore("readwrite",n=>{const i=n.put({id:t,value:r});return new Promise((o,s)=>{i.onerror=()=>s(i.error),i.onsuccess=()=>o()})})}getDb(){const t=self.indexedDB.open(this.dbName,1);return new Promise((r,n)=>{t.onsuccess=()=>{r(t.result)},t.onerror=()=>{n(t.error)},t.onblocked=()=>{n(new Error("Unable to access DB"))},t.onupgradeneeded=()=>{const i=t.result;i.onerror=()=>{n(new Error("Failed to create object store"))},i.createObjectStore(Y1,{keyPath:"id"})}})}withObjectStore(t,r){return this.getDb().then(n=>{const i=n.transaction(Y1,t);return i.oncomplete=()=>n.close(),new Promise((o,s)=>{i.onerror=()=>s(i.error),o(r(i.objectStore(Y1)))}).catch(o=>{throw n.close(),o})})}}class $K{constructor(t={}){this.store=t}getItem(t){return t in this.store?this.store[t]:null}removeItem(t){delete this.store[t]}setItem(t,r){this.store[t]=r}}const DK=new $K;function OK(){return typeof self=="object"&&self.indexedDB?new NK:typeof window=="object"&&window.localStorage?window.localStorage:DK}function LK({accountId:e,cache:t=OK(),client:r,customRoleArn:n,identityPoolId:i,logins:o,userIdentifier:s=!o||Object.keys(o).length===0?"ANONYMOUS":void 0}){const a=s?`aws:cognito-identity-credentials:${i}:${s}`:void 0;let l=async()=>{let c=a&&await t.getItem(a);if(!c){const{IdentityId:f=BK()}=await r.send(new Nx({AccountId:e,IdentityPoolId:i,Logins:o?await p9(o):void 0}));c=f,a&&Promise.resolve(t.setItem(a,c)).catch(()=>{})}return l=TK({client:r,customRoleArn:n,logins:o,identityId:c}),l()};return()=>l().catch(async c=>{throw a&&Promise.resolve(t.removeItem(a)).catch(()=>{}),c})}function BK(){throw new gl("Response from Amazon Cognito contained no identity ID")}const FK=e=>LK({...e,client:new dK(e.clientConfig??{})});class Cc extends Error{}Cc.prototype.name="InvalidTokenError";function jK(e){return decodeURIComponent(atob(e).replace(/(.)/g,(t,r)=>{let n=r.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}))}function zK(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return jK(t)}catch{return atob(t)}}function UK(e,t){if(typeof e!="string")throw new Cc("Invalid token specified: must be a string");t||(t={});const r=t.header===!0?0:1,n=e.split(".")[r];if(typeof n!="string")throw new Cc(`Invalid token specified: missing part #${r+1}`);let i;try{i=zK(n)}catch(o){throw new Cc(`Invalid token specified: invalid base64 for part #${r+1} (${o.message})`)}try{return JSON.parse(i)}catch(o){throw new Cc(`Invalid token specified: invalid json for part #${r+1} (${o.message})`)}}const VK=e=>({...e,useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:"kms"}),qK="@aws-sdk/client-kms",HK="AWS SDK for JavaScript Kms Client for Node.js, Browser and React Native",GK="3.445.0",WK={build:"concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'","build:cjs":"tsc -p tsconfig.cjs.json","build:docs":"typedoc","build:es":"tsc -p tsconfig.es.json","build:include:deps":"lerna run --scope $npm_package_name --include-dependencies build","build:types":"tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4",clean:"rimraf ./dist-* && rimraf *.tsbuildinfo","extract:docs":"api-extractor run --local","generate:client":"node ../../scripts/generate-clients/single-service --solo kms"},KK="./dist-cjs/index.js",YK="./dist-types/index.d.ts",QK="./dist-es/index.js",JK=!1,XK={"@aws-crypto/sha256-browser":"3.0.0","@aws-crypto/sha256-js":"3.0.0","@aws-sdk/client-sts":"3.445.0","@aws-sdk/core":"3.445.0","@aws-sdk/credential-provider-node":"3.445.0","@aws-sdk/middleware-host-header":"3.433.0","@aws-sdk/middleware-logger":"3.433.0","@aws-sdk/middleware-recursion-detection":"3.433.0","@aws-sdk/middleware-signing":"3.433.0","@aws-sdk/middleware-user-agent":"3.438.0","@aws-sdk/region-config-resolver":"3.433.0","@aws-sdk/types":"3.433.0","@aws-sdk/util-endpoints":"3.438.0","@aws-sdk/util-user-agent-browser":"3.433.0","@aws-sdk/util-user-agent-node":"3.437.0","@smithy/config-resolver":"^2.0.16","@smithy/fetch-http-handler":"^2.2.4","@smithy/hash-node":"^2.0.12","@smithy/invalid-dependency":"^2.0.12","@smithy/middleware-content-length":"^2.0.14","@smithy/middleware-endpoint":"^2.1.3","@smithy/middleware-retry":"^2.0.18","@smithy/middleware-serde":"^2.0.12","@smithy/middleware-stack":"^2.0.6","@smithy/node-config-provider":"^2.1.3","@smithy/node-http-handler":"^2.1.8","@smithy/protocol-http":"^3.0.8","@smithy/smithy-client":"^2.1.12","@smithy/types":"^2.4.0","@smithy/url-parser":"^2.0.12","@smithy/util-base64":"^2.0.0","@smithy/util-body-length-browser":"^2.0.0","@smithy/util-body-length-node":"^2.1.0","@smithy/util-defaults-mode-browser":"^2.0.16","@smithy/util-defaults-mode-node":"^2.0.21","@smithy/util-endpoints":"^1.0.2","@smithy/util-retry":"^2.0.5","@smithy/util-utf8":"^2.0.0",tslib:"^2.5.0"},ZK={"@smithy/service-client-documentation-generator":"^2.0.0","@tsconfig/node14":"1.0.3","@types/node":"^14.14.31",concurrently:"7.0.0","downlevel-dts":"0.10.1",rimraf:"3.0.2",typedoc:"0.23.23",typescript:"~4.9.5"},eY={node:">=14.0.0"},tY={"<4.0":{"dist-types/*":["dist-types/ts3.4/*"]}},rY=["dist-*/**"],nY={name:"AWS SDK for JavaScript Team",url:"https://aws.amazon.com/javascript/"},iY="Apache-2.0",oY={"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.browser"},sY="https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-kms",aY={type:"git",url:"https://github.com/aws/aws-sdk-js-v3.git",directory:"clients/client-kms"},lY={name:qK,description:HK,version:GK,scripts:WK,main:KK,types:YK,module:QK,sideEffects:JK,dependencies:XK,devDependencies:ZK,engines:eY,typesVersions:tY,files:rY,author:nY,license:iY,browser:oY,"react-native":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.native"},homepage:sY,repository:aY},m9="required",xi="fn",gi="argv",kl="ref",n4=!0,i4="isSet",_f="booleanEquals",Xs="error",fc="endpoint",Bi="tree",$x="PartitionResult",o4={[m9]:!1,type:"String"},s4={[m9]:!0,default:!1,type:"Boolean"},a4={[kl]:"Endpoint"},x9={[xi]:_f,[gi]:[{[kl]:"UseFIPS"},!0]},g9={[xi]:_f,[gi]:[{[kl]:"UseDualStack"},!0]},ai={},l4={[xi]:"getAttr",[gi]:[{[kl]:$x},"supportsFIPS"]},c4={[xi]:_f,[gi]:[!0,{[xi]:"getAttr",[gi]:[{[kl]:$x},"supportsDualStack"]}]},f4=[x9],u4=[g9],d4=[{[kl]:"Region"}],cY={version:"1.0",parameters:{Region:o4,UseDualStack:s4,UseFIPS:s4,Endpoint:o4},rules:[{conditions:[{[xi]:i4,[gi]:[a4]}],rules:[{conditions:f4,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:Xs},{conditions:u4,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:Xs},{endpoint:{url:a4,properties:ai,headers:ai},type:fc}],type:Bi},{conditions:[{[xi]:i4,[gi]:d4}],rules:[{conditions:[{[xi]:"aws.partition",[gi]:d4,assign:$x}],rules:[{conditions:[x9,g9],rules:[{conditions:[{[xi]:_f,[gi]:[n4,l4]},c4],rules:[{endpoint:{url:"https://kms-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:ai,headers:ai},type:fc}],type:Bi},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:Xs}],type:Bi},{conditions:f4,rules:[{conditions:[{[xi]:_f,[gi]:[l4,n4]}],rules:[{endpoint:{url:"https://kms-fips.{Region}.{PartitionResult#dnsSuffix}",properties:ai,headers:ai},type:fc}],type:Bi},{error:"FIPS is enabled but this partition does not support FIPS",type:Xs}],type:Bi},{conditions:u4,rules:[{conditions:[c4],rules:[{endpoint:{url:"https://kms.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:ai,headers:ai},type:fc}],type:Bi},{error:"DualStack is enabled but this partition does not support DualStack",type:Xs}],type:Bi},{endpoint:{url:"https://kms.{Region}.{PartitionResult#dnsSuffix}",properties:ai,headers:ai},type:fc}],type:Bi}],type:Bi},{error:"Invalid Configuration: Missing Region",type:Xs}]},fY=cY,uY=(e,t={})=>ex(fY,{endpointParams:e,logger:t.logger}),dY=e=>({apiVersion:"2014-11-01",base64Decoder:(e==null?void 0:e.base64Decoder)??Kf,base64Encoder:(e==null?void 0:e.base64Encoder)??Q0,disableHostPrefix:(e==null?void 0:e.disableHostPrefix)??!1,endpointProvider:(e==null?void 0:e.endpointProvider)??uY,extensions:(e==null?void 0:e.extensions)??[],logger:(e==null?void 0:e.logger)??new fx,serviceId:(e==null?void 0:e.serviceId)??"KMS",urlParser:(e==null?void 0:e.urlParser)??tl,utf8Decoder:(e==null?void 0:e.utf8Decoder)??bl,utf8Encoder:(e==null?void 0:e.utf8Encoder)??Wf}),hY=e=>{const t=Sx(e),r=()=>t().then(px),n=dY(e);return{...n,...e,runtime:"browser",defaultsMode:t,bodyLengthChecker:(e==null?void 0:e.bodyLengthChecker)??Ex,credentialDefaultProvider:(e==null?void 0:e.credentialDefaultProvider)??(i=>()=>Promise.reject(new Error("Credential is missing"))),defaultUserAgentProvider:(e==null?void 0:e.defaultUserAgentProvider)??bx({serviceId:n.serviceId,clientVersion:lY.version}),maxAttempts:(e==null?void 0:e.maxAttempts)??nl,region:(e==null?void 0:e.region)??wx("Region is missing"),requestHandler:(e==null?void 0:e.requestHandler)??new dx(r),retryMode:(e==null?void 0:e.retryMode)??(async()=>(await r()).retryMode||ax),sha256:(e==null?void 0:e.sha256)??J0.Sha256,streamCollector:(e==null?void 0:e.streamCollector)??hx,useDualstackEndpoint:(e==null?void 0:e.useDualstackEndpoint)??(()=>Promise.resolve(rx)),useFipsEndpoint:(e==null?void 0:e.useFipsEndpoint)??(()=>Promise.resolve(nx))}},Q1=e=>e,vY=(e,t)=>{const r={...Q1(Ax(e)),...Q1(mx(e)),...Q1(qm(e))};return t.forEach(n=>n.configure(r)),{...e,...kx(r),...xx(r),...Hm(r)}};class yY extends ux{constructor(...[t]){const r=hY(t||{}),n=VK(r),i=ix(n),o=sx(i),s=lx(o),a=s,l=Qm(a),c=Jm(l),f=vY(c,(t==null?void 0:t.extensions)||[]);super(f),this.config=f,this.middlewareStack.use(cx(this.config)),this.middlewareStack.use(ox(this.config)),this.middlewareStack.use(Gm(this.config)),this.middlewareStack.use(Wm(this.config)),this.middlewareStack.use(Km(this.config)),this.middlewareStack.use(RH(this.config)),this.middlewareStack.use(tx(this.config))}destroy(){super.destroy()}}class Rn extends Yf{constructor(t){super(t),Object.setPrototypeOf(this,Rn.prototype)}}class Dx extends Rn{constructor(t){super({name:"DependencyTimeoutException",$fault:"server",...t}),this.name="DependencyTimeoutException",this.$fault="server",Object.setPrototypeOf(this,Dx.prototype)}}class Ox extends Rn{constructor(t){super({name:"KMSInternalException",$fault:"server",...t}),this.name="KMSInternalException",this.$fault="server",Object.setPrototypeOf(this,Ox.prototype)}}class Lx extends Rn{constructor(t){super({name:"KMSInvalidStateException",$fault:"client",...t}),this.name="KMSInvalidStateException",this.$fault="client",Object.setPrototypeOf(this,Lx.prototype)}}class Bx extends Rn{constructor(t){super({name:"NotFoundException",$fault:"client",...t}),this.name="NotFoundException",this.$fault="client",Object.setPrototypeOf(this,Bx.prototype)}}class Fx extends Rn{constructor(t){super({name:"DisabledException",$fault:"client",...t}),this.name="DisabledException",this.$fault="client",Object.setPrototypeOf(this,Fx.prototype)}}class jx extends Rn{constructor(t){super({name:"DryRunOperationException",$fault:"client",...t}),this.name="DryRunOperationException",this.$fault="client",Object.setPrototypeOf(this,jx.prototype)}}class zx extends Rn{constructor(t){super({name:"InvalidGrantTokenException",$fault:"client",...t}),this.name="InvalidGrantTokenException",this.$fault="client",Object.setPrototypeOf(this,zx.prototype)}}class Ux extends Rn{constructor(t){super({name:"InvalidKeyUsageException",$fault:"client",...t}),this.name="InvalidKeyUsageException",this.$fault="client",Object.setPrototypeOf(this,Ux.prototype)}}class Vx extends Rn{constructor(t){super({name:"KeyUnavailableException",$fault:"server",...t}),this.name="KeyUnavailableException",this.$fault="server",Object.setPrototypeOf(this,Vx.prototype)}}const pY=e=>({...e,...e.Plaintext&&{Plaintext:Yt}}),mY=async(e,t)=>{const r=DY("GenerateDataKey");let n;return n=JSON.stringify(TY(e,t)),$Y(t,r,"/",void 0,n)},xY=async(e,t)=>{if(e.statusCode>=300)return gY(e,t);const r=await b9(e.body,t);let n={};return n=MY(r,t),{$metadata:Di(e),...n}},gY=async(e,t)=>{const r={...e,body:await OY(e.body,t)},n=LY(e,r.body);switch(n){case"DependencyTimeoutException":case"com.amazonaws.kms#DependencyTimeoutException":throw await bY(r);case"DisabledException":case"com.amazonaws.kms#DisabledException":throw await wY(r);case"DryRunOperationException":case"com.amazonaws.kms#DryRunOperationException":throw await EY(r);case"InvalidGrantTokenException":case"com.amazonaws.kms#InvalidGrantTokenException":throw await CY(r);case"InvalidKeyUsageException":case"com.amazonaws.kms#InvalidKeyUsageException":throw await SY(r);case"KMSInternalException":case"com.amazonaws.kms#KMSInternalException":throw await kY(r);case"KMSInvalidStateException":case"com.amazonaws.kms#KMSInvalidStateException":throw await RY(r);case"KeyUnavailableException":case"com.amazonaws.kms#KeyUnavailableException":throw await AY(r);case"NotFoundException":case"com.amazonaws.kms#NotFoundException":throw await PY(r);default:const i=r.body;return NY({output:e,parsedBody:i,errorCode:n})}},bY=async(e,t)=>{const r=e.body,n=we(r),i=new Dx({$metadata:Di(e),...n});return Te(i,r)},wY=async(e,t)=>{const r=e.body,n=we(r),i=new Fx({$metadata:Di(e),...n});return Te(i,r)},EY=async(e,t)=>{const r=e.body,n=we(r),i=new jx({$metadata:Di(e),...n});return Te(i,r)},CY=async(e,t)=>{const r=e.body,n=we(r),i=new zx({$metadata:Di(e),...n});return Te(i,r)},SY=async(e,t)=>{const r=e.body,n=we(r),i=new Ux({$metadata:Di(e),...n});return Te(i,r)},AY=async(e,t)=>{const r=e.body,n=we(r),i=new Vx({$metadata:Di(e),...n});return Te(i,r)},kY=async(e,t)=>{const r=e.body,n=we(r),i=new Ox({$metadata:Di(e),...n});return Te(i,r)},RY=async(e,t)=>{const r=e.body,n=we(r),i=new Lx({$metadata:Di(e),...n});return Te(i,r)},PY=async(e,t)=>{const r=e.body,n=we(r),i=new Bx({$metadata:Di(e),...n});return Te(i,r)},TY=(e,t)=>Qf(e,{DryRun:[],EncryptionContext:we,GrantTokens:we,KeyId:[],KeySpec:[],NumberOfBytes:[],Recipient:r=>_Y(r,t)}),_Y=(e,t)=>Qf(e,{AttestationDocument:t.base64Encoder,KeyEncryptionAlgorithm:[]}),MY=(e,t)=>Qf(e,{CiphertextBlob:t.base64Decoder,CiphertextForRecipient:t.base64Decoder,KeyId:Wc,Plaintext:t.base64Decoder}),Di=e=>({httpStatusCode:e.statusCode,requestId:e.headers["x-amzn-requestid"]??e.headers["x-amzn-request-id"]??e.headers["x-amz-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}),IY=(e,t)=>vx(e,t).then(r=>t.utf8Encoder(r)),NY=yx(Rn),$Y=async(e,t,r,n,i)=>{const{hostname:o,protocol:s="https",port:a,path:l}=await e.endpoint(),c={protocol:s,hostname:o,port:a,method:"POST",path:l.endsWith("/")?l.slice(0,-1)+r:l+r,headers:t};return n!==void 0&&(c.hostname=n),i!==void 0&&(c.body=i),new Cn(c)};function DY(e){return{"content-type":"application/x-amz-json-1.1","x-amz-target":`TrentService.${e}`}}const b9=(e,t)=>IY(e,t).then(r=>r.length?JSON.parse(r):{}),OY=async(e,t)=>{const r=await b9(e,t);return r.message=r.message??r.Message,r},LY=(e,t)=>{const r=(o,s)=>Object.keys(o).find(a=>a.toLowerCase()===s.toLowerCase()),n=o=>{let s=o;return typeof s=="number"&&(s=s.toString()),s.indexOf(",")>=0&&(s=s.split(",")[0]),s.indexOf(":")>=0&&(s=s.split(":")[0]),s.indexOf("#")>=0&&(s=s.split("#")[1]),s},i=r(e.headers,"x-amzn-errortype");if(i!==void 0)return n(e.headers[i]);if(t.code!==void 0)return n(t.code);if(t.__type!==void 0)return n(t.__type)};class qx extends Sl{static getEndpointParameterInstructions(){return{UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}}}constructor(t){super(),this.input=t}resolveMiddleware(t,r,n){this.middlewareStack.use(wl(r,this.serialize,this.deserialize)),this.middlewareStack.use(El(r,qx.getEndpointParameterInstructions()));const i=t.concat(this.middlewareStack),{logger:o}=r,l={logger:o,clientName:"KMSClient",commandName:"GenerateDataKeyCommand",inputFilterSensitiveLog:f=>f,outputFilterSensitiveLog:pY,[xl]:{service:"TrentService",operation:"GenerateDataKey"}},{requestHandler:c}=r;return i.resolve(f=>c.handle(f.request,n||{}),l)}serialize(t,r){return mY(t,r)}deserialize(t,r){return xY(t,r)}}const BY=e=>({...e,useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:"cognito-idp"}),FY="@aws-sdk/client-cognito-identity-provider",jY="AWS SDK for JavaScript Cognito Identity Provider Client for Node.js, Browser and React Native",zY="3.445.0",UY={build:"concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'","build:cjs":"tsc -p tsconfig.cjs.json","build:docs":"typedoc","build:es":"tsc -p tsconfig.es.json","build:include:deps":"lerna run --scope $npm_package_name --include-dependencies build","build:types":"tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4",clean:"rimraf ./dist-* && rimraf *.tsbuildinfo","extract:docs":"api-extractor run --local","generate:client":"node ../../scripts/generate-clients/single-service --solo cognito-identity-provider"},VY="./dist-cjs/index.js",qY="./dist-types/index.d.ts",HY="./dist-es/index.js",GY=!1,WY={"@aws-crypto/sha256-browser":"3.0.0","@aws-crypto/sha256-js":"3.0.0","@aws-sdk/client-sts":"3.445.0","@aws-sdk/core":"3.445.0","@aws-sdk/credential-provider-node":"3.445.0","@aws-sdk/middleware-host-header":"3.433.0","@aws-sdk/middleware-logger":"3.433.0","@aws-sdk/middleware-recursion-detection":"3.433.0","@aws-sdk/middleware-signing":"3.433.0","@aws-sdk/middleware-user-agent":"3.438.0","@aws-sdk/region-config-resolver":"3.433.0","@aws-sdk/types":"3.433.0","@aws-sdk/util-endpoints":"3.438.0","@aws-sdk/util-user-agent-browser":"3.433.0","@aws-sdk/util-user-agent-node":"3.437.0","@smithy/config-resolver":"^2.0.16","@smithy/fetch-http-handler":"^2.2.4","@smithy/hash-node":"^2.0.12","@smithy/invalid-dependency":"^2.0.12","@smithy/middleware-content-length":"^2.0.14","@smithy/middleware-endpoint":"^2.1.3","@smithy/middleware-retry":"^2.0.18","@smithy/middleware-serde":"^2.0.12","@smithy/middleware-stack":"^2.0.6","@smithy/node-config-provider":"^2.1.3","@smithy/node-http-handler":"^2.1.8","@smithy/protocol-http":"^3.0.8","@smithy/smithy-client":"^2.1.12","@smithy/types":"^2.4.0","@smithy/url-parser":"^2.0.12","@smithy/util-base64":"^2.0.0","@smithy/util-body-length-browser":"^2.0.0","@smithy/util-body-length-node":"^2.1.0","@smithy/util-defaults-mode-browser":"^2.0.16","@smithy/util-defaults-mode-node":"^2.0.21","@smithy/util-endpoints":"^1.0.2","@smithy/util-retry":"^2.0.5","@smithy/util-utf8":"^2.0.0",tslib:"^2.5.0"},KY={"@smithy/service-client-documentation-generator":"^2.0.0","@tsconfig/node14":"1.0.3","@types/node":"^14.14.31",concurrently:"7.0.0","downlevel-dts":"0.10.1",rimraf:"3.0.2",typedoc:"0.23.23",typescript:"~4.9.5"},YY={node:">=14.0.0"},QY={"<4.0":{"dist-types/*":["dist-types/ts3.4/*"]}},JY=["dist-*/**"],XY={name:"AWS SDK for JavaScript Team",url:"https://aws.amazon.com/javascript/"},ZY="Apache-2.0",eQ={"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.browser"},tQ="https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-cognito-identity-provider",rQ={type:"git",url:"https://github.com/aws/aws-sdk-js-v3.git",directory:"clients/client-cognito-identity-provider"},nQ={name:FY,description:jY,version:zY,scripts:UY,main:VY,types:qY,module:HY,sideEffects:GY,dependencies:WY,devDependencies:KY,engines:YY,typesVersions:QY,files:JY,author:XY,license:ZY,browser:eQ,"react-native":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.native"},homepage:tQ,repository:rQ},w9="required",bi="fn",wi="argv",Rl="ref",h4=!0,v4="isSet",Mf="booleanEquals",Zs="error",uc="endpoint",Fi="tree",Hx="PartitionResult",y4={[w9]:!1,type:"String"},p4={[w9]:!0,default:!1,type:"Boolean"},m4={[Rl]:"Endpoint"},E9={[bi]:Mf,[wi]:[{[Rl]:"UseFIPS"},!0]},C9={[bi]:Mf,[wi]:[{[Rl]:"UseDualStack"},!0]},li={},x4={[bi]:"getAttr",[wi]:[{[Rl]:Hx},"supportsFIPS"]},g4={[bi]:Mf,[wi]:[!0,{[bi]:"getAttr",[wi]:[{[Rl]:Hx},"supportsDualStack"]}]},b4=[E9],w4=[C9],E4=[{[Rl]:"Region"}],iQ={version:"1.0",parameters:{Region:y4,UseDualStack:p4,UseFIPS:p4,Endpoint:y4},rules:[{conditions:[{[bi]:v4,[wi]:[m4]}],rules:[{conditions:b4,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:Zs},{conditions:w4,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:Zs},{endpoint:{url:m4,properties:li,headers:li},type:uc}],type:Fi},{conditions:[{[bi]:v4,[wi]:E4}],rules:[{conditions:[{[bi]:"aws.partition",[wi]:E4,assign:Hx}],rules:[{conditions:[E9,C9],rules:[{conditions:[{[bi]:Mf,[wi]:[h4,x4]},g4],rules:[{endpoint:{url:"https://cognito-idp-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:li,headers:li},type:uc}],type:Fi},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:Zs}],type:Fi},{conditions:b4,rules:[{conditions:[{[bi]:Mf,[wi]:[x4,h4]}],rules:[{endpoint:{url:"https://cognito-idp-fips.{Region}.{PartitionResult#dnsSuffix}",properties:li,headers:li},type:uc}],type:Fi},{error:"FIPS is enabled but this partition does not support FIPS",type:Zs}],type:Fi},{conditions:w4,rules:[{conditions:[g4],rules:[{endpoint:{url:"https://cognito-idp.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:li,headers:li},type:uc}],type:Fi},{error:"DualStack is enabled but this partition does not support DualStack",type:Zs}],type:Fi},{endpoint:{url:"https://cognito-idp.{Region}.{PartitionResult#dnsSuffix}",properties:li,headers:li},type:uc}],type:Fi}],type:Fi},{error:"Invalid Configuration: Missing Region",type:Zs}]},oQ=iQ,sQ=(e,t={})=>ex(oQ,{endpointParams:e,logger:t.logger}),aQ=e=>({apiVersion:"2016-04-18",base64Decoder:(e==null?void 0:e.base64Decoder)??Kf,base64Encoder:(e==null?void 0:e.base64Encoder)??Q0,disableHostPrefix:(e==null?void 0:e.disableHostPrefix)??!1,endpointProvider:(e==null?void 0:e.endpointProvider)??sQ,extensions:(e==null?void 0:e.extensions)??[],logger:(e==null?void 0:e.logger)??new fx,serviceId:(e==null?void 0:e.serviceId)??"Cognito Identity Provider",urlParser:(e==null?void 0:e.urlParser)??tl,utf8Decoder:(e==null?void 0:e.utf8Decoder)??bl,utf8Encoder:(e==null?void 0:e.utf8Encoder)??Wf}),lQ=e=>{const t=Sx(e),r=()=>t().then(px),n=aQ(e);return{...n,...e,runtime:"browser",defaultsMode:t,bodyLengthChecker:(e==null?void 0:e.bodyLengthChecker)??Ex,credentialDefaultProvider:(e==null?void 0:e.credentialDefaultProvider)??(i=>()=>Promise.reject(new Error("Credential is missing"))),defaultUserAgentProvider:(e==null?void 0:e.defaultUserAgentProvider)??bx({serviceId:n.serviceId,clientVersion:nQ.version}),maxAttempts:(e==null?void 0:e.maxAttempts)??nl,region:(e==null?void 0:e.region)??wx("Region is missing"),requestHandler:(e==null?void 0:e.requestHandler)??new dx(r),retryMode:(e==null?void 0:e.retryMode)??(async()=>(await r()).retryMode||ax),sha256:(e==null?void 0:e.sha256)??J0.Sha256,streamCollector:(e==null?void 0:e.streamCollector)??hx,useDualstackEndpoint:(e==null?void 0:e.useDualstackEndpoint)??(()=>Promise.resolve(rx)),useFipsEndpoint:(e==null?void 0:e.useFipsEndpoint)??(()=>Promise.resolve(nx))}},J1=e=>e,cQ=(e,t)=>{const r={...J1(Ax(e)),...J1(mx(e)),...J1(qm(e))};return t.forEach(n=>n.configure(r)),{...e,...kx(r),...xx(r),...Hm(r)}};class fQ extends ux{constructor(...[t]){const r=lQ(t||{}),n=BY(r),i=ix(n),o=sx(i),s=lx(o),a=s,l=Qm(a),c=Jm(l),f=cQ(c,(t==null?void 0:t.extensions)||[]);super(f),this.config=f,this.middlewareStack.use(cx(this.config)),this.middlewareStack.use(ox(this.config)),this.middlewareStack.use(Gm(this.config)),this.middlewareStack.use(Wm(this.config)),this.middlewareStack.use(Km(this.config)),this.middlewareStack.use(tx(this.config))}destroy(){super.destroy()}}class vt extends Yf{constructor(t){super(t),Object.setPrototypeOf(this,vt.prototype)}}class Gx extends vt{constructor(t){super({name:"InternalErrorException",$fault:"server",...t}),this.name="InternalErrorException",this.$fault="server",Object.setPrototypeOf(this,Gx.prototype)}}class Wx extends vt{constructor(t){super({name:"InvalidParameterException",$fault:"client",...t}),this.name="InvalidParameterException",this.$fault="client",Object.setPrototypeOf(this,Wx.prototype)}}class Kx extends vt{constructor(t){super({name:"NotAuthorizedException",$fault:"client",...t}),this.name="NotAuthorizedException",this.$fault="client",Object.setPrototypeOf(this,Kx.prototype)}}class Yx extends vt{constructor(t){super({name:"ResourceNotFoundException",$fault:"client",...t}),this.name="ResourceNotFoundException",this.$fault="client",Object.setPrototypeOf(this,Yx.prototype)}}class Qx extends vt{constructor(t){super({name:"TooManyRequestsException",$fault:"client",...t}),this.name="TooManyRequestsException",this.$fault="client",Object.setPrototypeOf(this,Qx.prototype)}}class Jx extends vt{constructor(t){super({name:"UserNotFoundException",$fault:"client",...t}),this.name="UserNotFoundException",this.$fault="client",Object.setPrototypeOf(this,Jx.prototype)}}class Xx extends vt{constructor(t){super({name:"InvalidLambdaResponseException",$fault:"client",...t}),this.name="InvalidLambdaResponseException",this.$fault="client",Object.setPrototypeOf(this,Xx.prototype)}}class Zx extends vt{constructor(t){super({name:"UnexpectedLambdaException",$fault:"client",...t}),this.name="UnexpectedLambdaException",this.$fault="client",Object.setPrototypeOf(this,Zx.prototype)}}class X0 extends vt{constructor(t){super({name:"UserLambdaValidationException",$fault:"client",...t}),this.name="UserLambdaValidationException",this.$fault="client",Object.setPrototypeOf(this,X0.prototype)}}class eg extends vt{constructor(t){super({name:"CodeDeliveryFailureException",$fault:"client",...t}),this.name="CodeDeliveryFailureException",this.$fault="client",Object.setPrototypeOf(this,eg.prototype)}}class tg extends vt{constructor(t){super({name:"InvalidPasswordException",$fault:"client",...t}),this.name="InvalidPasswordException",this.$fault="client",Object.setPrototypeOf(this,tg.prototype)}}class rg extends vt{constructor(t){super({name:"InvalidSmsRoleAccessPolicyException",$fault:"client",...t}),this.name="InvalidSmsRoleAccessPolicyException",this.$fault="client",Object.setPrototypeOf(this,rg.prototype)}}class ng extends vt{constructor(t){super({name:"InvalidSmsRoleTrustRelationshipException",$fault:"client",...t}),this.name="InvalidSmsRoleTrustRelationshipException",this.$fault="client",Object.setPrototypeOf(this,ng.prototype)}}class ig extends vt{constructor(t){super({name:"UsernameExistsException",$fault:"client",...t}),this.name="UsernameExistsException",this.$fault="client",Object.setPrototypeOf(this,ig.prototype)}}class og extends vt{constructor(t){super({name:"AliasExistsException",$fault:"client",...t}),this.name="AliasExistsException",this.$fault="client",Object.setPrototypeOf(this,og.prototype)}}class sg extends vt{constructor(t){super({name:"InvalidUserPoolConfigurationException",$fault:"client",...t}),this.name="InvalidUserPoolConfigurationException",this.$fault="client",Object.setPrototypeOf(this,sg.prototype)}}class ag extends vt{constructor(t){super({name:"MFAMethodNotFoundException",$fault:"client",...t}),this.name="MFAMethodNotFoundException",this.$fault="client",Object.setPrototypeOf(this,ag.prototype)}}class lg extends vt{constructor(t){super({name:"PasswordResetRequiredException",$fault:"client",...t}),this.name="PasswordResetRequiredException",this.$fault="client",Object.setPrototypeOf(this,lg.prototype)}}class cg extends vt{constructor(t){super({name:"UserNotConfirmedException",$fault:"client",...t}),this.name="UserNotConfirmedException",this.$fault="client",Object.setPrototypeOf(this,cg.prototype)}}class fg extends vt{constructor(t){super({name:"InvalidEmailRoleAccessPolicyException",$fault:"client",...t}),this.name="InvalidEmailRoleAccessPolicyException",this.$fault="client",Object.setPrototypeOf(this,fg.prototype)}}class ug extends vt{constructor(t){super({name:"CodeMismatchException",$fault:"client",...t}),this.name="CodeMismatchException",this.$fault="client",Object.setPrototypeOf(this,ug.prototype)}}class dg extends vt{constructor(t){super({name:"ExpiredCodeException",$fault:"client",...t}),this.name="ExpiredCodeException",this.$fault="client",Object.setPrototypeOf(this,dg.prototype)}}class hg extends vt{constructor(t){super({name:"SoftwareTokenMFANotFoundException",$fault:"client",...t}),this.name="SoftwareTokenMFANotFoundException",this.$fault="client",Object.setPrototypeOf(this,hg.prototype)}}class vg extends vt{constructor(t){super({name:"ForbiddenException",$fault:"client",...t}),this.name="ForbiddenException",this.$fault="client",Object.setPrototypeOf(this,vg.prototype)}}const C4=e=>({...e,...e.Value&&{Value:Yt}}),S9=e=>({...e,...e.AccessToken&&{AccessToken:Yt},...e.RefreshToken&&{RefreshToken:Yt},...e.IdToken&&{IdToken:Yt}}),uQ=e=>({...e,...e.AuthParameters&&{AuthParameters:Yt},...e.ClientId&&{ClientId:Yt},...e.UserContextData&&{UserContextData:Yt}}),dQ=e=>({...e,...e.Session&&{Session:Yt},...e.AuthenticationResult&&{AuthenticationResult:S9(e.AuthenticationResult)}}),hQ=e=>({...e,...e.ClientId&&{ClientId:Yt},...e.Session&&{Session:Yt},...e.ChallengeResponses&&{ChallengeResponses:Yt},...e.UserContextData&&{UserContextData:Yt}}),vQ=e=>({...e,...e.Session&&{Session:Yt},...e.AuthenticationResult&&{AuthenticationResult:S9(e.AuthenticationResult)}}),yQ=e=>({...e,...e.ClientId&&{ClientId:Yt},...e.SecretHash&&{SecretHash:Yt},...e.Username&&{Username:Yt},...e.Password&&{Password:Yt},...e.UserAttributes&&{UserAttributes:e.UserAttributes.map(t=>C4(t))},...e.ValidationData&&{ValidationData:e.ValidationData.map(t=>C4(t))},...e.UserContextData&&{UserContextData:Yt}}),pQ=async(e,t)=>{const r=Pg("InitiateAuth");let n;return n=JSON.stringify(we(e)),Rg(t,r,"/",void 0,n)},mQ=async(e,t)=>{const r=Pg("RespondToAuthChallenge");let n;return n=JSON.stringify(we(e)),Rg(t,r,"/",void 0,n)},xQ=async(e,t)=>{const r=Pg("SignUp");let n;return n=JSON.stringify(we(e)),Rg(t,r,"/",void 0,n)},gQ=async(e,t)=>{if(e.statusCode>=300)return bQ(e,t);const r=await Z0(e.body,t);let n={};return n=we(r),{$metadata:yt(e),...n}},bQ=async(e,t)=>{const r={...e,body:await Tg(e.body,t)},n=_g(e,r.body);switch(n){case"ForbiddenException":case"com.amazonaws.cognitoidentityprovider#ForbiddenException":throw await yg(r);case"InternalErrorException":case"com.amazonaws.cognitoidentityprovider#InternalErrorException":throw await pg(r);case"InvalidLambdaResponseException":case"com.amazonaws.cognitoidentityprovider#InvalidLambdaResponseException":throw await mg(r);case"InvalidParameterException":case"com.amazonaws.cognitoidentityprovider#InvalidParameterException":throw await xg(r);case"InvalidSmsRoleAccessPolicyException":case"com.amazonaws.cognitoidentityprovider#InvalidSmsRoleAccessPolicyException":throw await gg(r);case"InvalidSmsRoleTrustRelationshipException":case"com.amazonaws.cognitoidentityprovider#InvalidSmsRoleTrustRelationshipException":throw await bg(r);case"InvalidUserPoolConfigurationException":case"com.amazonaws.cognitoidentityprovider#InvalidUserPoolConfigurationException":throw await k9(r);case"NotAuthorizedException":case"com.amazonaws.cognitoidentityprovider#NotAuthorizedException":throw await wg(r);case"PasswordResetRequiredException":case"com.amazonaws.cognitoidentityprovider#PasswordResetRequiredException":throw await R9(r);case"ResourceNotFoundException":case"com.amazonaws.cognitoidentityprovider#ResourceNotFoundException":throw await Eg(r);case"TooManyRequestsException":case"com.amazonaws.cognitoidentityprovider#TooManyRequestsException":throw await Cg(r);case"UnexpectedLambdaException":case"com.amazonaws.cognitoidentityprovider#UnexpectedLambdaException":throw await Sg(r);case"UserLambdaValidationException":case"com.amazonaws.cognitoidentityprovider#UserLambdaValidationException":throw await Ag(r);case"UserNotConfirmedException":case"com.amazonaws.cognitoidentityprovider#UserNotConfirmedException":throw await P9(r);case"UserNotFoundException":case"com.amazonaws.cognitoidentityprovider#UserNotFoundException":throw await T9(r);default:const i=r.body;return kg({output:e,parsedBody:i,errorCode:n})}},wQ=async(e,t)=>{if(e.statusCode>=300)return EQ(e,t);const r=await Z0(e.body,t);let n={};return n=we(r),{$metadata:yt(e),...n}},EQ=async(e,t)=>{const r={...e,body:await Tg(e.body,t)},n=_g(e,r.body);switch(n){case"AliasExistsException":case"com.amazonaws.cognitoidentityprovider#AliasExistsException":throw await AQ(r);case"CodeMismatchException":case"com.amazonaws.cognitoidentityprovider#CodeMismatchException":throw await RQ(r);case"ExpiredCodeException":case"com.amazonaws.cognitoidentityprovider#ExpiredCodeException":throw await PQ(r);case"ForbiddenException":case"com.amazonaws.cognitoidentityprovider#ForbiddenException":throw await yg(r);case"InternalErrorException":case"com.amazonaws.cognitoidentityprovider#InternalErrorException":throw await pg(r);case"InvalidLambdaResponseException":case"com.amazonaws.cognitoidentityprovider#InvalidLambdaResponseException":throw await mg(r);case"InvalidParameterException":case"com.amazonaws.cognitoidentityprovider#InvalidParameterException":throw await xg(r);case"InvalidPasswordException":case"com.amazonaws.cognitoidentityprovider#InvalidPasswordException":throw await A9(r);case"InvalidSmsRoleAccessPolicyException":case"com.amazonaws.cognitoidentityprovider#InvalidSmsRoleAccessPolicyException":throw await gg(r);case"InvalidSmsRoleTrustRelationshipException":case"com.amazonaws.cognitoidentityprovider#InvalidSmsRoleTrustRelationshipException":throw await bg(r);case"InvalidUserPoolConfigurationException":case"com.amazonaws.cognitoidentityprovider#InvalidUserPoolConfigurationException":throw await k9(r);case"MFAMethodNotFoundException":case"com.amazonaws.cognitoidentityprovider#MFAMethodNotFoundException":throw await _Q(r);case"NotAuthorizedException":case"com.amazonaws.cognitoidentityprovider#NotAuthorizedException":throw await wg(r);case"PasswordResetRequiredException":case"com.amazonaws.cognitoidentityprovider#PasswordResetRequiredException":throw await R9(r);case"ResourceNotFoundException":case"com.amazonaws.cognitoidentityprovider#ResourceNotFoundException":throw await Eg(r);case"SoftwareTokenMFANotFoundException":case"com.amazonaws.cognitoidentityprovider#SoftwareTokenMFANotFoundException":throw await MQ(r);case"TooManyRequestsException":case"com.amazonaws.cognitoidentityprovider#TooManyRequestsException":throw await Cg(r);case"UnexpectedLambdaException":case"com.amazonaws.cognitoidentityprovider#UnexpectedLambdaException":throw await Sg(r);case"UserLambdaValidationException":case"com.amazonaws.cognitoidentityprovider#UserLambdaValidationException":throw await Ag(r);case"UserNotConfirmedException":case"com.amazonaws.cognitoidentityprovider#UserNotConfirmedException":throw await P9(r);case"UserNotFoundException":case"com.amazonaws.cognitoidentityprovider#UserNotFoundException":throw await T9(r);default:const i=r.body;return kg({output:e,parsedBody:i,errorCode:n})}},CQ=async(e,t)=>{if(e.statusCode>=300)return SQ(e,t);const r=await Z0(e.body,t);let n={};return n=we(r),{$metadata:yt(e),...n}},SQ=async(e,t)=>{const r={...e,body:await Tg(e.body,t)},n=_g(e,r.body);switch(n){case"CodeDeliveryFailureException":case"com.amazonaws.cognitoidentityprovider#CodeDeliveryFailureException":throw await kQ(r);case"ForbiddenException":case"com.amazonaws.cognitoidentityprovider#ForbiddenException":throw await yg(r);case"InternalErrorException":case"com.amazonaws.cognitoidentityprovider#InternalErrorException":throw await pg(r);case"InvalidEmailRoleAccessPolicyException":case"com.amazonaws.cognitoidentityprovider#InvalidEmailRoleAccessPolicyException":throw await TQ(r);case"InvalidLambdaResponseException":case"com.amazonaws.cognitoidentityprovider#InvalidLambdaResponseException":throw await mg(r);case"InvalidParameterException":case"com.amazonaws.cognitoidentityprovider#InvalidParameterException":throw await xg(r);case"InvalidPasswordException":case"com.amazonaws.cognitoidentityprovider#InvalidPasswordException":throw await A9(r);case"InvalidSmsRoleAccessPolicyException":case"com.amazonaws.cognitoidentityprovider#InvalidSmsRoleAccessPolicyException":throw await gg(r);case"InvalidSmsRoleTrustRelationshipException":case"com.amazonaws.cognitoidentityprovider#InvalidSmsRoleTrustRelationshipException":throw await bg(r);case"NotAuthorizedException":case"com.amazonaws.cognitoidentityprovider#NotAuthorizedException":throw await wg(r);case"ResourceNotFoundException":case"com.amazonaws.cognitoidentityprovider#ResourceNotFoundException":throw await Eg(r);case"TooManyRequestsException":case"com.amazonaws.cognitoidentityprovider#TooManyRequestsException":throw await Cg(r);case"UnexpectedLambdaException":case"com.amazonaws.cognitoidentityprovider#UnexpectedLambdaException":throw await Sg(r);case"UserLambdaValidationException":case"com.amazonaws.cognitoidentityprovider#UserLambdaValidationException":throw await Ag(r);case"UsernameExistsException":case"com.amazonaws.cognitoidentityprovider#UsernameExistsException":throw await IQ(r);default:const i=r.body;return kg({output:e,parsedBody:i,errorCode:n})}},AQ=async(e,t)=>{const r=e.body,n=we(r),i=new og({$metadata:yt(e),...n});return Te(i,r)},kQ=async(e,t)=>{const r=e.body,n=we(r),i=new eg({$metadata:yt(e),...n});return Te(i,r)},RQ=async(e,t)=>{const r=e.body,n=we(r),i=new ug({$metadata:yt(e),...n});return Te(i,r)},PQ=async(e,t)=>{const r=e.body,n=we(r),i=new dg({$metadata:yt(e),...n});return Te(i,r)},yg=async(e,t)=>{const r=e.body,n=we(r),i=new vg({$metadata:yt(e),...n});return Te(i,r)},pg=async(e,t)=>{const r=e.body,n=we(r),i=new Gx({$metadata:yt(e),...n});return Te(i,r)},TQ=async(e,t)=>{const r=e.body,n=we(r),i=new fg({$metadata:yt(e),...n});return Te(i,r)},mg=async(e,t)=>{const r=e.body,n=we(r),i=new Xx({$metadata:yt(e),...n});return Te(i,r)},xg=async(e,t)=>{const r=e.body,n=we(r),i=new Wx({$metadata:yt(e),...n});return Te(i,r)},A9=async(e,t)=>{const r=e.body,n=we(r),i=new tg({$metadata:yt(e),...n});return Te(i,r)},gg=async(e,t)=>{const r=e.body,n=we(r),i=new rg({$metadata:yt(e),...n});return Te(i,r)},bg=async(e,t)=>{const r=e.body,n=we(r),i=new ng({$metadata:yt(e),...n});return Te(i,r)},k9=async(e,t)=>{const r=e.body,n=we(r),i=new sg({$metadata:yt(e),...n});return Te(i,r)},_Q=async(e,t)=>{const r=e.body,n=we(r),i=new ag({$metadata:yt(e),...n});return Te(i,r)},wg=async(e,t)=>{const r=e.body,n=we(r),i=new Kx({$metadata:yt(e),...n});return Te(i,r)},R9=async(e,t)=>{const r=e.body,n=we(r),i=new lg({$metadata:yt(e),...n});return Te(i,r)},Eg=async(e,t)=>{const r=e.body,n=we(r),i=new Yx({$metadata:yt(e),...n});return Te(i,r)},MQ=async(e,t)=>{const r=e.body,n=we(r),i=new hg({$metadata:yt(e),...n});return Te(i,r)},Cg=async(e,t)=>{const r=e.body,n=we(r),i=new Qx({$metadata:yt(e),...n});return Te(i,r)},Sg=async(e,t)=>{const r=e.body,n=we(r),i=new Zx({$metadata:yt(e),...n});return Te(i,r)},Ag=async(e,t)=>{const r=e.body,n=we(r),i=new X0({$metadata:yt(e),...n});return Te(i,r)},IQ=async(e,t)=>{const r=e.body,n=we(r),i=new ig({$metadata:yt(e),...n});return Te(i,r)},P9=async(e,t)=>{const r=e.body,n=we(r),i=new cg({$metadata:yt(e),...n});return Te(i,r)},T9=async(e,t)=>{const r=e.body,n=we(r),i=new Jx({$metadata:yt(e),...n});return Te(i,r)},yt=e=>({httpStatusCode:e.statusCode,requestId:e.headers["x-amzn-requestid"]??e.headers["x-amzn-request-id"]??e.headers["x-amz-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}),NQ=(e,t)=>vx(e,t).then(r=>t.utf8Encoder(r)),kg=yx(vt),Rg=async(e,t,r,n,i)=>{const{hostname:o,protocol:s="https",port:a,path:l}=await e.endpoint(),c={protocol:s,hostname:o,port:a,method:"POST",path:l.endsWith("/")?l.slice(0,-1)+r:l+r,headers:t};return n!==void 0&&(c.hostname=n),i!==void 0&&(c.body=i),new Cn(c)};function Pg(e){return{"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityProviderService.${e}`}}const Z0=(e,t)=>NQ(e,t).then(r=>r.length?JSON.parse(r):{}),Tg=async(e,t)=>{const r=await Z0(e,t);return r.message=r.message??r.Message,r},_g=(e,t)=>{const r=(o,s)=>Object.keys(o).find(a=>a.toLowerCase()===s.toLowerCase()),n=o=>{let s=o;return typeof s=="number"&&(s=s.toString()),s.indexOf(",")>=0&&(s=s.split(",")[0]),s.indexOf(":")>=0&&(s=s.split(":")[0]),s.indexOf("#")>=0&&(s=s.split("#")[1]),s},i=r(e.headers,"x-amzn-errortype");if(i!==void 0)return n(e.headers[i]);if(t.code!==void 0)return n(t.code);if(t.__type!==void 0)return n(t.__type)};class Mg extends Sl{static getEndpointParameterInstructions(){return{UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}}}constructor(t){super(),this.input=t}resolveMiddleware(t,r,n){this.middlewareStack.use(wl(r,this.serialize,this.deserialize)),this.middlewareStack.use(El(r,Mg.getEndpointParameterInstructions()));const i=t.concat(this.middlewareStack),{logger:o}=r,l={logger:o,clientName:"CognitoIdentityProviderClient",commandName:"InitiateAuthCommand",inputFilterSensitiveLog:uQ,outputFilterSensitiveLog:dQ,[xl]:{service:"AWSCognitoIdentityProviderService",operation:"InitiateAuth"}},{requestHandler:c}=r;return i.resolve(f=>c.handle(f.request,n||{}),l)}serialize(t,r){return pQ(t,r)}deserialize(t,r){return gQ(t,r)}}class Ig extends Sl{static getEndpointParameterInstructions(){return{UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}}}constructor(t){super(),this.input=t}resolveMiddleware(t,r,n){this.middlewareStack.use(wl(r,this.serialize,this.deserialize)),this.middlewareStack.use(El(r,Ig.getEndpointParameterInstructions()));const i=t.concat(this.middlewareStack),{logger:o}=r,l={logger:o,clientName:"CognitoIdentityProviderClient",commandName:"RespondToAuthChallengeCommand",inputFilterSensitiveLog:hQ,outputFilterSensitiveLog:vQ,[xl]:{service:"AWSCognitoIdentityProviderService",operation:"RespondToAuthChallenge"}},{requestHandler:c}=r;return i.resolve(f=>c.handle(f.request,n||{}),l)}serialize(t,r){return mQ(t,r)}deserialize(t,r){return wQ(t,r)}}class Ng extends Sl{static getEndpointParameterInstructions(){return{UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}}}constructor(t){super(),this.input=t}resolveMiddleware(t,r,n){this.middlewareStack.use(wl(r,this.serialize,this.deserialize)),this.middlewareStack.use(El(r,Ng.getEndpointParameterInstructions()));const i=t.concat(this.middlewareStack),{logger:o}=r,l={logger:o,clientName:"CognitoIdentityProviderClient",commandName:"SignUpCommand",inputFilterSensitiveLog:yQ,outputFilterSensitiveLog:f=>f,[xl]:{service:"AWSCognitoIdentityProviderService",operation:"SignUp"}},{requestHandler:c}=r;return i.resolve(f=>c.handle(f.request,n||{}),l)}serialize(t,r){return xQ(t,r)}deserialize(t,r){return CQ(t,r)}}function jt(){return jt=Object.assign?Object.assign.bind():function(e){for(var t=1;t{if(!o.to||o.to===i7)throw new Error("Contract creation not supported");return{type:"transaction",to:o.to,value:fe.from(o.value||0).toHexString(),data:he(o.data||[])}})})}function FQ({wallet:e,token:t,to:r,value:n,chainId:i,lifespan:o,identifier:s}){return jt({},ei(o),{identifier:s,code:"sendTransaction",wallet:e,network:i.toString(),transactions:[{type:"erc20send",token:t,to:r,value:fe.from(n).toString()}]})}function jQ({wallet:e,token:t,to:r,id:n,chainId:i,lifespan:o,identifier:s,safe:a,data:l}){return jt({},ei(o),{identifier:s,code:"sendTransaction",wallet:e,network:i.toString(),transactions:[{type:"erc721send",token:t,to:r,id:n,safe:a,data:l}]})}function zQ({wallet:e,token:t,to:r,values:n,chainId:i,lifespan:o,identifier:s,data:a}){return jt({},ei(o),{identifier:s,code:"sendTransaction",wallet:e,network:i.toString(),transactions:[{type:"erc1155send",token:t,to:r,vals:n.map(l=>({id:l.id,amount:fe.from(l.amount).toString()})),data:a}]})}function UQ({wallet:e,to:t,value:r,abi:n,func:i,args:o,chainId:s,lifespan:a,identifier:l}){return jt({},ei(a),{identifier:l,code:"sendTransaction",wallet:e,network:s.toString(),transactions:[{type:"delayedEncode",to:t,value:fe.from(r).toString(),data:{abi:n,func:i,args:o}}]})}function VQ(e){if(e.length===0)throw new Error("No packets provided");const t=e[0].network,r=e[0].wallet,n=e[0].expires-e[0].issued,i=e[0].identifier;if(!e.every(o=>o.network===t))throw new Error("All packets must have the same chainId");if(!e.every(o=>o.wallet===r))throw new Error("All packets must have the same wallet");return jt({},ei(n),{identifier:i,code:"sendTransaction",network:t,wallet:r,transactions:e.reduce((o,s)=>o.concat(s.transactions),[])})}function $g(e){return typeof e=="object"&&typeof e.code=="string"&&e.code==="transactionReceipt"&&typeof e.data=="object"&&typeof e.data.txHash=="string"&&typeof e.data.receipt=="object"&&typeof e.data.request=="object"}function qQ(e){return typeof e=="object"&&typeof e.code=="string"&&e.code==="transactionFailed"&&typeof e.data=="object"&&typeof e.data.request=="object"&&Array.isArray(e.data.simulations)&&typeof e.data.error=="string"}function dc(e){return $g(e)||qQ(e)}function HQ(e){return typeof e=="object"&&typeof e.code=="string"&&e.code==="signedMessage"&&typeof e.data=="object"&&typeof e.data.message=="string"&&typeof e.data.signature=="string"}function GQ(e){return typeof e=="object"&&typeof e.code=="string"&&e.code==="validationRequired"&&typeof e.data=="object"&&typeof e.data.sessionId=="string"}function WQ(e){return typeof e=="object"&&typeof e.code=="string"&&e.code==="getSessionResponse"&&typeof e.data=="object"&&typeof e.data.session=="string"&&typeof e.data.wallet=="string"}function KQ(e){"version"in e&&(e=e.packet);const t=Xt(ZV(e));return se(Ct(t))}function YQ(e,t){const r=KQ(t);return e.signMessage(r)}class QQ{constructor(t,r){this.path="/rpc/Guard/",this.ping=n=>this.fetch(this.url("Ping"),Sr({},n)).then(i=>Ar(i).then(o=>({status:o.status}))),this.version=n=>this.fetch(this.url("Version"),Sr({},n)).then(i=>Ar(i).then(o=>({version:o.version}))),this.runtimeStatus=n=>this.fetch(this.url("RuntimeStatus"),Sr({},n)).then(i=>Ar(i).then(o=>({status:o.status}))),this.signTransactions=(n,i)=>this.fetch(this.url("SignTransactions"),Sr(n,i)).then(o=>Ar(o).then(s=>({sig:s.sig}))),this.signMessage=(n,i)=>this.fetch(this.url("SignMessage"),Sr(n,i)).then(o=>Ar(o).then(s=>({sig:s.sig}))),this.getGuardSignerAddress=(n,i)=>this.fetch(this.url("GetGuardSignerAddress"),Sr(n,i)).then(o=>Ar(o).then(s=>({address:s.address}))),this.getWalletTransactionPolicyList=(n,i)=>this.fetch(this.url("GetWalletTransactionPolicyList"),Sr(n,i)).then(o=>Ar(o).then(s=>({policyList:s.policyList}))),this.setWalletTransactionPolicyList=(n,i)=>this.fetch(this.url("SetWalletTransactionPolicyList"),Sr(n,i)).then(o=>Ar(o).then(s=>({}))),this.getSessionUserMapRules=(n,i)=>this.fetch(this.url("GetSessionUserMapRules"),Sr(n,i)).then(o=>Ar(o).then(s=>({rules:s.rules}))),this.setSessionUserMapRules=(n,i)=>this.fetch(this.url("SetSessionUserMapRules"),Sr(n,i)).then(o=>Ar(o).then(s=>({}))),this.getSession=(n,i)=>this.fetch(this.url("GetSession"),Sr(n,i)).then(o=>Ar(o).then(s=>({validated:s.validated}))),this.registerSession=(n,i)=>this.fetch(this.url("RegisterSession"),Sr(n,i)).then(o=>Ar(o).then(s=>({sessionId:s.sessionId}))),this.startSessionValidation=(n,i)=>this.fetch(this.url("StartSessionValidation"),Sr(n,i)).then(o=>Ar(o).then(s=>({salt:s.salt}))),this.validateSession=(n,i)=>this.fetch(this.url("ValidateSession"),Sr(n,i)).then(o=>Ar(o).then(s=>({status:s.status}))),this.invalidateSession=(n,i)=>this.fetch(this.url("InvalidateSession"),Sr(n,i)).then(o=>Ar(o).then(s=>({status:s.status}))),this.hostname=t,this.fetch=(n,i)=>r(n,i)}url(t){return this.hostname+this.path+t}}const Sr=(e={},t={})=>({method:"POST",headers:jt({},t,{"Content-Type":"application/json"}),body:JSON.stringify(e||{})}),Ar=e=>e.text().then(t=>{let r;try{r=JSON.parse(t)}catch{throw{code:"unknown",msg:`expecting JSON, got: ${t}`,status:e.status}}if(!e.ok)throw r;return r});function JQ({wallet:e,chainId:t,message:r,lifespan:n}){return jt({},ei(n),{code:"signMessage",wallet:e,network:t.toString(),message:r.startsWith("0x")?r:he(Xt(r))})}const Gy={mainnet:1,goerli:5,polygon:137,"polygon-zkevm":1101,mumbai:80001,bsc:56,"bsc-testnet":97,arbitrum:42161,"arbitrum-nova":42170,"arbitrum-goerli":421613,optimism:10,gnosis:100,avalanche:43114,"avalanche-testnet":43113,"base-goerli":84531},XQ=Object.entries(Gy).reduce((e,[t,r])=>(e[r]=t,e),{});function S4(e){if(typeof e=="number"){if(e in XQ)return e;throw new Error(`Unknown network id ${e}`)}const t=e.toLowerCase();if(t in Gy)return Gy[t];throw new Error(`Unknown network name ${e}`)}const M9="https://guard2.sequence.app",I9={rpcServer:"http://localhost:9123",kmsRegion:"us-east-2",idpRegion:"us-east-2",emailRegion:"us-east-2",keyId:"arn:aws:kms:us-east-1:000000000000:key/aeb99e0f-9e89-44de-a084-e1817af47778",endpoint:"http://localstack:4566"},ZQ={rpcServer:"https://d14tu8valot5m0.cloudfront.net",kmsRegion:"us-east-2",idpRegion:"us-east-2",emailRegion:"us-east-2",keyId:"arn:aws:kms:us-east-2:170768627592:key/0fd8f803-9cb5-4de5-86e4-41963fb6043d",endpoint:void 0};var eJ=Object.freeze({__proto__:null,DEFAULT_GUARD:M9,TEMPLATE_LOCAL:I9,TEMPLATE_NEXT:ZQ});const tJ="@0xsequence.waas.wallet",rJ="@0xsequence.waas.signer",nJ="@0xsequence.waas.status",ea=5*60;class iJ{constructor(t={network:1},r=new _9,n=M9){this.VERSION="0.0.0-dev1",this.config=t,this.store=r,this.guardUrl=n,this.status=new Kc(this.store,nJ,"signed-out"),this.signer=new Kc(this.store,rJ,void 0),this.wallet=new Kc(this.store,tJ,void 0)}async getAddress(){return this.getWalletAddress()}async getWalletAddress(){if(!await this.isSignedIn())throw new Error("Not signed in");const t=await this.wallet.get();if(!t)throw new Error("No wallet");return t}async commonArgs(t){var r;return jt({},t,{identifier:t==null?void 0:t.identifier,wallet:await this.getWalletAddress(),lifespan:(r=t==null?void 0:t.lifespan)!=null?r:ea,chainId:S4(t.network||this.config.network)})}async buildPayload(t){if(!await this.isSignedIn())throw new Error("Not signed in");const r=await this.signer.get();if(!r)throw new Error("No signer");const n=new qn(r),i=await YQ(n,t);return{version:this.VERSION,packet:t,signatures:[{session:n.address,signature:i}]}}async signUsingSessionKey(t){const r=await this.signer.get();if(!r)throw new Error("No signer");return new qn(r).signMessage(t)}async getSignerAddress(){const t=await this.signer.get();if(!t)throw new Error("No signer");return new qn(t).address}async getSessionID(){return this.getSignerAddress()}async getSessionShortID(){return(await this.getSessionID()).substring(2,8)}async signIn(t){await this.status.get()!=="signed-out"&&await this.completeSignOut();const n=await $Q({proof:t,lifespan:ea});return await Promise.all([this.status.set("pending"),this.signer.set(n.signer.privateKey)]),{version:this.VERSION,packet:n.packet,signatures:[]}}async signOut({lifespan:t,sessionId:r}={}){const n=await DQ({lifespan:t||ea,wallet:await this.getWalletAddress(),session:r||await this.getSignerAddress()});return this.buildPayload(n)}async completeSignOut(){await Promise.all([this.status.set("signed-out"),this.signer.set(void 0),this.wallet.set(void 0)])}async completeSignIn(t){if(t.result)return this.completeSignIn(t.result);const r=await this.status.get(),n=await this.signer.get();if(t.code!=="sessionOpened")throw new Error("Invalid receipt");if(r!=="pending"||!n)throw new Error("No pending sign in");if(new qn(n).address.toLowerCase()!==t.data.sessionId.toLowerCase())throw new Error("Invalid signer");return await Promise.all([this.status.set("signed-in"),this.wallet.set(t.data.wallet)]),t.data.wallet}async isSignedIn(){return await this.status.get()==="signed-in"}async signMessage(t){var r;const n=JQ(jt({chainId:S4(t.network||this.config.network),lifespan:(r=t.lifespan)!=null?r:ea,wallet:await this.getWalletAddress()},t));return this.buildPayload(n)}async sendTransaction(t){const r=BQ(await this.commonArgs(t));return this.buildPayload(r)}async sendERC20(t){if(t.token.toLowerCase()===t.to.toLowerCase())throw new Error("Cannot burn tokens using sendERC20");const r=FQ(await this.commonArgs(t));return this.buildPayload(r)}async sendERC721(t){if(t.token.toLowerCase()===t.to.toLowerCase())throw new Error("Cannot burn tokens using sendERC721");const r=jQ(await this.commonArgs(t));return this.buildPayload(r)}async sendERC1155(t){if(t.token.toLowerCase()===t.to.toLowerCase())throw new Error("Cannot burn tokens using sendERC1155");const r=zQ(await this.commonArgs(t));return this.buildPayload(r)}async callContract(t){const r=UQ(await this.commonArgs(t));return this.buildPayload(r)}async validateSession({deviceMetadata:t,redirectURL:r}){const n=await OQ({lifespan:ea,session:await this.getSignerAddress(),deviceMetadata:t,redirectURL:r,wallet:await this.getWalletAddress()});return this.buildPayload(n)}async getSession(){const t=await LQ({session:await this.getSignerAddress(),wallet:await this.getWalletAddress(),lifespan:ea});return this.buildPayload(t)}async isSessionValid(){const t=await this.getSignerAddress(),r=new QQ(this.guardUrl,fetch);try{if((await r.getSession({sessionAddress:t})).validated)return!0}catch{}return!1}async waitForSessionValid(t=6e5,r=2e3){const n=Date.now();for(;Date.now()-nsetTimeout(i,r))}return!1}async batch(t){const r=VQ(t.map(n=>n.packet));return this.buildPayload(r)}}class oJ{constructor(t,r){this.path="/rpc/WaasAuthenticator/",this.registerSession=(n,i,o)=>this.fetch(this.url("RegisterSession"),hc(n,i,o)).then(s=>vc(s).then(a=>({session:a.session,data:a.data})),s=>{throw So.new({cause:`fetch(): ${s.message||""}`})}),this.listSessions=(n,i,o)=>this.fetch(this.url("ListSessions"),hc(n,i,o)).then(s=>vc(s).then(a=>({sessions:a.sessions})),s=>{throw So.new({cause:`fetch(): ${s.message||""}`})}),this.dropSession=(n,i,o)=>this.fetch(this.url("DropSession"),hc(n,i,o)).then(s=>vc(s).then(a=>({ok:a.ok})),s=>{throw So.new({cause:`fetch(): ${s.message||""}`})}),this.getAddress=(n,i,o)=>this.fetch(this.url("GetAddress"),hc(n,i,o)).then(s=>vc(s).then(a=>({address:a.address})),s=>{throw So.new({cause:`fetch(): ${s.message||""}`})}),this.sendIntent=(n,i,o)=>this.fetch(this.url("SendIntent"),hc(n,i,o)).then(s=>vc(s).then(a=>({code:a.code,data:a.data})),s=>{throw So.new({cause:`fetch(): ${s.message||""}`})}),this.hostname=t,this.fetch=(n,i)=>r(n,i)}url(t){return this.hostname+this.path+t}}const hc=(e={},t={},r=null)=>({method:"POST",headers:jt({},t,{"Content-Type":"application/json"}),body:JSON.stringify(e||{}),signal:r}),vc=e=>e.text().then(t=>{let r;try{r=JSON.parse(t)}catch(n){let i="";throw n instanceof Error&&(i=n.message),eh.new({status:e.status,cause:`JSON.parse(): ${i}: response text: ${t}`})}if(!e.ok){const n=typeof r.code=="number"?r.code:0;throw(sJ[n]||ti).new(r)}return r});class ti extends Error{constructor(t,r,n,i,o){super(n),this.name=t||"WebrpcError",this.code=typeof r=="number"?r:0,this.message=n||`endpoint error ${this.code}`,this.msg=this.message,this.status=typeof i=="number"?i:0,this.cause=o,Object.setPrototypeOf(this,ti.prototype)}static new(t){return new this(t.error,t.code,t.message||t.msg,t.status,t.cause)}}class Dg extends ti{constructor(t="WebrpcEndpoint",r=0,n="endpoint error",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,Dg.prototype)}}class So extends ti{constructor(t="WebrpcRequestFailed",r=-1,n="request failed",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,So.prototype)}}class Og extends ti{constructor(t="WebrpcBadRoute",r=-2,n="bad route",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,Og.prototype)}}class Lg extends ti{constructor(t="WebrpcBadMethod",r=-3,n="bad method",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,Lg.prototype)}}class Bg extends ti{constructor(t="WebrpcBadRequest",r=-4,n="bad request",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,Bg.prototype)}}class eh extends ti{constructor(t="WebrpcBadResponse",r=-5,n="bad response",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,eh.prototype)}}class Fg extends ti{constructor(t="WebrpcServerPanic",r=-6,n="server panic",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,Fg.prototype)}}class jg extends ti{constructor(t="WebrpcInternalError",r=-7,n="internal error",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,jg.prototype)}}const sJ={0:Dg,[-1]:So,[-2]:Og,[-3]:Lg,[-4]:Bg,[-5]:eh,[-6]:Fg,[-7]:jg};function aJ(e){const t=new Uint8Array(e);return window.crypto.getRandomValues(t),Array.from(t).map(r=>r.toString(16).padStart(2,"0")).join("")}class lJ{constructor(t,r){this.region=t,this.clientId=r}cognito(){return this.cognitoMemo||(this.cognitoMemo=new fQ({region:this.region})),this.cognitoMemo}signUp(t){return this.cognito().send(new Ng({ClientId:this.clientId,Username:t,Password:"aB1%"+aJ(14),UserAttributes:[{Name:"email",Value:t}]}))}signIn(t){return this.cognito().send(new Mg({AuthFlow:"CUSTOM_AUTH",ClientId:this.clientId,AuthParameters:{USERNAME:t}}))}async initiateAuth({email:t}){let r;try{r=await this.signIn(t)}catch(n){if(n instanceof X0&&n.message.includes("user not found"))await this.signUp(t),r=await this.signIn(t);else throw n}if(!r.Session)throw new Error("response session is empty");return{instance:r.Session,email:t}}async finalizeAuth({instance:t,email:r,answer:n}){const i=await this.cognito().send(new Ig({ClientId:this.clientId,Session:t,ChallengeName:"CUSTOM_CHALLENGE",ChallengeResponses:{USERNAME:r,ANSWER:n}}));if(!i.AuthenticationResult||!i.AuthenticationResult.IdToken)throw new Error("AuthenticationResult.IdToken is empty");return{idToken:i.AuthenticationResult.IdToken}}}function X1(e){return"0x"+Array.from(typeof e=="string"?new TextEncoder().encode(e):e,t=>t.toString(16).padStart(2,"0")).join("")}function cJ(e){return new Uint8Array(e.substring(2).match(/.{1,2}/g).map(t=>parseInt(t,16)))}function fJ(e){return JSON.parse(atob(e))}function uJ(e,t){const r=e.key,n=r?fJ(r):{},i=jt({},t,e,n);if(i.network===void 0&&(i.network=1),i.tenant===void 0)throw new Error("Missing tenant");if(i.secret===void 0)throw new Error("Missing secret");if(i.identityPoolId===void 0)throw new Error("Missing identityPoolId");return i}class dJ{constructor(t,r=I9,n=new _9){this.validationRequiredCallback=[],this.store=n,this.config=uJ(t,r),this.waas=new iJ(jt({network:1},t),this.store),this.client=new oJ(this.config.rpcServer,window.fetch),this.kmsKey=new Kc(this.store,"@0xsequence.waas.auth.key",void 0),this.deviceName=new Kc(this.store,"@0xsequence.waas.auth.deviceName",void 0)}get email(){if(this.emailClient)return this.emailClient;if(!this.config.emailRegion)throw new Error("Missing emailRegion");if(!this.config.emailClientId)throw new Error("Missing emailClientId");return this.emailClient=new lJ(this.config.emailRegion,this.config.emailClientId),this.emailClient}async onValidationRequired(t){return this.validationRequiredCallback.push(t),()=>{this.validationRequiredCallback=this.validationRequiredCallback.filter(r=>r!==t)}}async handleValidationRequired({onValidationRequired:t,redirectURL:r}={}){var n;if(!(t?t():!0))return!1;for(const s of this.validationRequiredCallback)s();const o=await this.waas.validateSession({redirectURL:r,deviceMetadata:(n=await this.deviceName.get())!=null?n:"Unknown device"});return await this.sendIntent(o),this.waitForSessionValid()}async useStoredCypherKey(){const t=await this.kmsKey.get();if(!t)throw new Error("No stored key");const r=JSON.parse(t);if(r.encryptedPayloadKey&&r.plainHex)return r;throw new Error("Invalid stored key")}async saveCypherKey(t){const r=await t.send(new qx({KeyId:this.config.keyId,KeySpec:"AES_256"}));if(!r.CiphertextBlob||!r.Plaintext)throw new Error("invalid response from KMS");return this.kmsKey.set(JSON.stringify({encryptedPayloadKey:X1(r.CiphertextBlob),plainHex:X1(r.Plaintext)}))}async sendIntent(t){const r={sessionId:await this.waas.getSessionID(),intentJson:JSON.stringify(t,null,0)},{args:n,headers:i}=await this.preparePayload(r);return this.client.sendIntent(n,i)}async preparePayload(t){const{encryptedPayloadKey:r,plainHex:n}=await this.useStoredCypherKey(),i={name:"AES-CBC",iv:window.crypto.getRandomValues(new Uint8Array(16))},o=await window.crypto.subtle.importKey("raw",cJ(n),i,!1,["encrypt"]),s=new TextEncoder().encode(JSON.stringify(t)),a=await window.crypto.subtle.encrypt(i,o,s),l=X1(new Uint8Array([...i.iv,...new Uint8Array(a)])),c=await this.waas.signUsingSessionKey(s);return{headers:{"X-Sequence-Tenant":this.config.tenant},args:{encryptedPayloadKey:r,payloadCiphertext:l,payloadSig:c}}}async isSignedIn(){return this.waas.isSignedIn()}async signIn(t,r){const n=await this.waas.signIn({idToken:t.idToken}),i=UK(t.idToken);if(!i.iss)throw new Error("Invalid idToken");const o=new yY({region:this.config.kmsRegion,endpoint:this.config.endpoint,credentials:FK({identityPoolId:this.config.identityPoolId,logins:{[i.iss.replace("https://","").replace("http://","")]:t.idToken},clientConfig:{region:this.config.idpRegion}})});await this.saveCypherKey(o);const s={projectId:this.config.tenant,idToken:t.idToken,sessionAddress:n.packet.session,friendlyName:r,intentJSON:JSON.stringify(n,null,0)},{args:a,headers:l}=await this.preparePayload(s),c=await this.client.registerSession(a,l);return await this.waas.completeSignIn({code:"sessionOpened",data:{sessionId:c.session.id,wallet:c.data.wallet}}),this.deviceName.set(r),c.session.address}async refreshSession(){throw new Error("Not implemented")}async getSessionID(){return this.waas.getSessionID()}async dropSession({sessionId:t,strict:r}={}){const n=await this.waas.getSessionID(),i=t||n;try{const o={dropSessionId:i,sessionId:n},{args:s,headers:a}=await this.preparePayload(o);await this.client.dropSession(s,a)}catch(o){if(r)throw o;console.error(o)}i.toLowerCase()===n.toLowerCase()&&(await this.waas.completeSignOut(),this.kmsKey.set(void 0),this.deviceName.set(void 0))}async listSessions(){const t={sessionId:await this.waas.getSessionID()},r=await this.waas.getSessionID().then(s=>s.toLowerCase()),{args:n,headers:i}=await this.preparePayload(t);return(await this.client.listSessions(n,i)).sessions.map(s=>jt({},s,{isThis:s.address.toLowerCase()===r}))}async getAddress(){return this.waas.getAddress()}async validateSession(t){return await this.waas.isSessionValid()?!0:this.handleValidationRequired(t)}async isSessionValid(){const t=await this.waas.getSession(),r=await this.sendIntent(t);if(!WQ(r))throw new Error(`Invalid response: ${JSON.stringify(r)}`);return r.data.validated}async waitForSessionValid(t=6e5,r=2e3){const n=Date.now();for(;Date.now()-nsetTimeout(i,r))}return!1}async useIdentifier(t){if(t.identifier)return t;const r=`ts-sdk-${Date.now()}-${await this.waas.getSignerAddress()}`;return jt({},t,{identifier:r})}async trySendIntent(t,r,n){const i=await this.sendIntent(r);if(n(i))return i;if(GQ(i)&&await this.handleValidationRequired(t.validation)){const s=await this.sendIntent(r);if(n(s))return s}throw new Error(JSON.stringify(i))}async signMessage(t){const r=await this.waas.signMessage(await this.useIdentifier(t));return this.trySendIntent(t,r,HQ)}async sendTransaction(t){const r=await this.waas.sendTransaction(await this.useIdentifier(t));return this.trySendIntent(t,r,dc)}async sendERC20(t){const r=await this.waas.sendERC20(await this.useIdentifier(t));return this.trySendIntent(t,r,dc)}async sendERC721(t){const r=await this.waas.sendERC721(await this.useIdentifier(t));return this.trySendIntent(t,r,dc)}async sendERC1155(t){const r=await this.waas.sendERC1155(await this.useIdentifier(t));return this.trySendIntent(t,r,dc)}async callContract(t){const r=await this.waas.callContract(await this.useIdentifier(t));return this.trySendIntent(t,r,dc)}}function hJ(){const[e,t]=x.useState(),[r,n]=x.useState(""),[i,o]=x.useState(""),[s,a]=x.useState(),[l,c]=x.useState(!1),[f,u]=x.useState();x.useEffect(()=>{d()},[]);const d=async()=>{const m=Qt.getAddress();t(await bJ.getBalance(m))},v=async(m,y)=>{try{u(void 0),c(!0);const w=await Qt.sendTransaction({transactions:[{to:m,value:UV(y)}]});$g(w)?a(w.data.txHash):u(w.data.error),c(!1)}catch(w){console.error(w),c(!1)}};return Y.jsxs(le,{children:[Y.jsx(le,{marginBottom:"5",children:Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Send native token transaction"})}),Y.jsxs(We,{variant:"normal",fontWeight:"bold",children:["Native token balance: ",zV(e||0)," MATIC"]}),Y.jsx(Uo,{marginLeft:"2",size:"xs",label:"Fetch",onClick:d}),Y.jsx(le,{marginTop:"5",children:Y.jsx(Ei,{name:"sendNativeTokenTo",type:"text",onChange:m=>{n(m.target.value)},value:r,placeholder:"To address 0x...",required:!0,"data-id":"nativeTokenSendAddress"})}),Y.jsx(le,{marginTop:"5",children:Y.jsx(Ei,{name:"sendNativeTokenAmount",type:"text",onChange:m=>{o(m.target.value)},value:i,placeholder:"Amount",required:!0,"data-id":"nativeTokenSendAmount"})}),f&&Y.jsxs(le,{marginTop:"3",children:["Transaction failed: ",f]}),l?Y.jsx(le,{gap:"2",marginY:"4",alignItems:"center",justifyContent:"center",children:Y.jsx(Qa,{})}):Y.jsx(Uo,{marginTop:"5",label:"Send native token",disabled:r===""&&i==="",onClick:()=>v(r,i)}),s&&Y.jsxs(le,{marginTop:"3",children:[Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Send native token transaction hash:"}),Y.jsx("br",{}),Y.jsx("a",{href:`https://polygonscan.com/tx/${s}`,target:"_blank",rel:"noopener noreferrer",children:s})]})]})}function vJ(){const[e,t]=x.useState(),[r,n]=x.useState(),[i,o]=x.useState(!0),[s,a]=x.useState(),l=async c=>{o(!0),t(void 0);try{await Qt.dropSession({sessionId:c}),t(await Qt.listSessions())}catch(f){a(f.message),t(await Qt.listSessions())}o(!1)};return x.useEffect(()=>{Promise.all([Qt.listSessions(),Qt.getSessionID()]).then(([c,f])=>{t(c),n(f),o(!1)}).catch(c=>{a(c.message),o(!1)})},[]),Y.jsxs(le,{children:[Y.jsxs(le,{marginBottom:"5",children:[Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Your open sessions"}),e&&Y.jsx(Y.Fragment,{children:e.map(c=>Y.jsxs(le,{children:[c.friendlyName,!c.isThis&&Y.jsx("a",{style:{marginLeft:"7px",textDecoration:"underline",cursor:"pointer"},onClick:()=>l(c.id),children:"x"}),c.isThis&&Y.jsx(Y.Fragment,{children:" (current)"})]},c.id))}),i&&Y.jsx(Qa,{})]}),s&&Y.jsxs(We,{variant:"normal",color:"text100",fontWeight:"bold",children:["Error loading sessions: ",s]})]})}function yJ(){const[e,t]=x.useState(""),[r,n]=x.useState(),i=async()=>{const o=await Qt.signMessage({message:e});n(o.data.signature)};return Y.jsxs(le,{children:[Y.jsx(le,{marginBottom:"5",children:Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Sign message"})}),Y.jsx(Ei,{name:"signMessageText",type:"text",onChange:o=>{t(o.target.value),r!=""&&n("")},value:e,placeholder:"Enter a message to sign",required:!0,"data-id":"signMessageInput"}),Y.jsx(Uo,{marginTop:"5",label:"Sign message",disabled:e==="",onClick:()=>i()}),r&&r!==""&&Y.jsxs(le,{flexDirection:"column",marginTop:"5",children:[Y.jsxs(We,{variant:"normal",color:"text100",fontWeight:"bold",children:["Signature for ",e,":"]}),Y.jsx(le,{children:Y.jsx(We,{as:"p",wordBreak:"break-word",children:r})})]})]})}function pJ(){const[e,t]=x.useState(""),[r,n]=x.useState(""),[i,o]=x.useState(""),[s,a]=x.useState(""),[l,c]=x.useState(),[f,u]=x.useState(!1),[d,v]=x.useState(),m=async()=>{try{v(void 0),u(!0);const y=await Qt.callContract({to:e,abi:r,func:i,args:JSON.parse(s),value:0});$g(y)?c(y.data.txHash):v(y.data.error),u(!1)}catch(y){console.error(y),u(!1)}};return Y.jsxs(le,{children:[Y.jsx(le,{marginBottom:"5",children:Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Call any contract"})}),Y.jsx(le,{marginTop:"5",children:Y.jsx(Ei,{name:"callContractAddress",type:"text",onChange:y=>{t(y.target.value)},value:e,placeholder:"Contract address 0x...",required:!0,"data-id":"nativeTokenSendAddress"})}),Y.jsx(le,{marginTop:"5",children:Y.jsx(Ei,{name:"callContractAbi",type:"text",onChange:y=>{n(y.target.value)},value:r,placeholder:"Contract ABI or function ABI, e.g. [{...}] or [{...}, {...}] or transfer(address,uint256)",required:!0,"data-id":"nativeTokenSendAmount"})}),Y.jsx(le,{marginTop:"5",children:Y.jsx(Ei,{name:"callContractMethod",type:"text",onChange:y=>{o(y.target.value)},value:i,placeholder:"Method name, e.g. transfer",required:!0,"data-id":"nativeTokenSendAmount"})}),Y.jsx(le,{marginTop:"5",children:Y.jsx(Ei,{name:"callContractArgs",type:"text",onChange:y=>{a(y.target.value)},value:s,placeholder:'Method args, e.g. [0x..., 1000] or named { "to": "0x...", "amount": "1000" }',required:!0,"data-id":"nativeTokenSendAmount"})}),d&&Y.jsxs(le,{marginTop:"3",children:["Transaction failed: ",d]}),f?Y.jsx(le,{gap:"2",marginY:"4",alignItems:"center",justifyContent:"center",children:Y.jsx(Qa,{})}):Y.jsx(Uo,{marginTop:"5",label:"Call contract",disabled:e===""&&r===""&&i===""&&s==="",onClick:()=>m()}),l&&Y.jsxs(le,{marginTop:"3",children:[Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Send native token transaction hash:"}),Y.jsx("br",{}),Y.jsx("a",{href:`https://polygonscan.com/tx/${l}`,target:"_blank",rel:"noopener noreferrer",children:l})]})]})}function mJ(){const[e,t]=x.useState(),[r,n]=x.useState(),[i,o]=x.useState();return x.useEffect(()=>{Qt.getAddress().then(s=>{t(s)}).catch(s=>{n(s.message)})},[]),x.useEffect(()=>{Qt.isSignedIn().then(s=>{s||Oa.navigate("/login")})},[]),Qt.onValidationRequired(()=>{o("Check your email to validate your session"),Qt.waitForSessionValid(600*1e3,4e3).then(()=>{o(void 0)})}),Y.jsxs(Y.Fragment,{children:[Y.jsx(gI,{children:i&&Y.jsx(rO,{children:Y.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"Helvetica, Arial, sans-serif",fontSize:"1.2em",height:"50vh"},children:i})})}),Y.jsxs(le,{marginY:"0",marginX:"auto",paddingX:"6",style:{maxWidth:"720px",marginTop:"80px",marginBottom:"80px"},children:[Y.jsx(le,{marginBottom:"10",children:Y.jsx(GS,{})}),Y.jsxs(le,{marginBottom:"5",flexDirection:"row",children:[Y.jsxs(We,{marginTop:"1",variant:"normal",color:"text100",children:["Logged in with email:"," "]}),Y.jsx(Uo,{marginLeft:"auto",label:"Log out",size:"xs",onClick:async()=>{try{await Qt.dropSession({strict:!1})}catch(s){console.warn(`Could not drop session: ${s.message}`)}xF(),Oa.navigate("/login")}})]}),Y.jsx(Fl,{background:"buttonGlass"}),Y.jsx(le,{marginBottom:"5",children:Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Your wallet address:"})}),Y.jsx(le,{marginBottom:"4",children:e?Y.jsx(le,{children:Y.jsx(We,{children:e})}):Y.jsx(Qa,{})}),Y.jsx(le,{children:r&&Y.jsxs(We,{children:["Error fetching wallet address: ",r]})}),Y.jsx(Fl,{background:"buttonGlass"}),Y.jsx(vJ,{}),Y.jsx(Fl,{background:"buttonGlass"}),Y.jsx(hJ,{}),Y.jsx(Fl,{background:"buttonGlass"}),Y.jsx(yJ,{}),Y.jsx(Fl,{background:"buttonGlass"}),Y.jsx(pJ,{})]})]})}const xJ="970987756660-35a6tc48hvi8cev9cnknp0iugv9poa23.apps.googleusercontent.com",gJ={}.VITE_SEQUENCE_API_KEY,bJ=new OV("https://nodes.sequence.app/polygon"),Qt=new dJ({network:"polygon",key:gJ,idpRegion:"us-west-2"},eJ.TEMPLATE_NEXT),Oa=aF([{path:"/login",element:Y.jsx(XV,{})},{path:"/",element:Y.jsx(mJ,{})}]);Z1.createRoot(document.getElementById("root")).render(Y.jsx(er.StrictMode,{children:Y.jsx(YL,{children:Y.jsx(hF,{clientId:xJ,children:Y.jsx(nF,{router:Oa})})})})); + */class YA{static getParser(t,r=!1){if(typeof t!="string")throw new Error("UserAgent should be a string");return new G6(t,r)}static parse(t){return new G6(t).getResult()}static get BROWSER_MAP(){return KA}static get ENGINE_MAP(){return xo}static get OS_MAP(){return kr}static get PLATFORMS_MAP(){return Lt}}const bx=({serviceId:e,clientVersion:t})=>async()=>{var i,o,s,a,l;const r=typeof window<"u"&&((i=window==null?void 0:window.navigator)!=null&&i.userAgent)?YA.parse(window.navigator.userAgent):void 0,n=[["aws-sdk-js",t],["ua","2.0"],[`os/${((o=r==null?void 0:r.os)==null?void 0:o.name)||"other"}`,(s=r==null?void 0:r.os)==null?void 0:s.version],["lang/js"],["md/browser",`${((a=r==null?void 0:r.browser)==null?void 0:a.name)??"unknown"}_${((l=r==null?void 0:r.browser)==null?void 0:l.version)??"unknown"}`]];return e&&n.push([`api/${e}`,t]),n},wx=e=>()=>Promise.reject(e),Ex=e=>{if(typeof e=="string"){let t=e.length;for(let r=t-1;r>=0;r--){const n=e.charCodeAt(r);n>127&&n<=2047?t++:n>2047&&n<=65535&&(t+=2),n>=56320&&n<=57343&&r--}return t}else{if(typeof e.byteLength=="number")return e.byteLength;if(typeof e.size=="number")return e.size}throw new Error(`Body Length computation failed for ${e}`)},QA="required",pi="fn",mi="argv",Al="ref",W6=!0,K6="isSet",Tf="booleanEquals",Js="error",cc="endpoint",Li="tree",Cx="PartitionResult",Y6={[QA]:!1,type:"String"},Q6={[QA]:!0,default:!1,type:"Boolean"},J6={[Al]:"Endpoint"},JA={[pi]:Tf,[mi]:[{[Al]:"UseFIPS"},!0]},XA={[pi]:Tf,[mi]:[{[Al]:"UseDualStack"},!0]},si={},X6={[pi]:"getAttr",[mi]:[{[Al]:Cx},"supportsFIPS"]},Z6={[pi]:Tf,[mi]:[!0,{[pi]:"getAttr",[mi]:[{[Al]:Cx},"supportsDualStack"]}]},e4=[JA],t4=[XA],r4=[{[Al]:"Region"}],iK={version:"1.0",parameters:{Region:Y6,UseDualStack:Q6,UseFIPS:Q6,Endpoint:Y6},rules:[{conditions:[{[pi]:K6,[mi]:[J6]}],rules:[{conditions:e4,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:Js},{conditions:t4,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:Js},{endpoint:{url:J6,properties:si,headers:si},type:cc}],type:Li},{conditions:[{[pi]:K6,[mi]:r4}],rules:[{conditions:[{[pi]:"aws.partition",[mi]:r4,assign:Cx}],rules:[{conditions:[JA,XA],rules:[{conditions:[{[pi]:Tf,[mi]:[W6,X6]},Z6],rules:[{endpoint:{url:"https://cognito-identity-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:si,headers:si},type:cc}],type:Li},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:Js}],type:Li},{conditions:e4,rules:[{conditions:[{[pi]:Tf,[mi]:[X6,W6]}],rules:[{endpoint:{url:"https://cognito-identity-fips.{Region}.{PartitionResult#dnsSuffix}",properties:si,headers:si},type:cc}],type:Li},{error:"FIPS is enabled but this partition does not support FIPS",type:Js}],type:Li},{conditions:t4,rules:[{conditions:[Z6],rules:[{endpoint:{url:"https://cognito-identity.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:si,headers:si},type:cc}],type:Li},{error:"DualStack is enabled but this partition does not support DualStack",type:Js}],type:Li},{endpoint:{url:"https://cognito-identity.{Region}.{PartitionResult#dnsSuffix}",properties:si,headers:si},type:cc}],type:Li}],type:Li},{error:"Invalid Configuration: Missing Region",type:Js}]},oK=iK,sK=(e,t={})=>ex(oK,{endpointParams:e,logger:t.logger}),aK=e=>({apiVersion:"2014-06-30",base64Decoder:(e==null?void 0:e.base64Decoder)??Kf,base64Encoder:(e==null?void 0:e.base64Encoder)??Q0,disableHostPrefix:(e==null?void 0:e.disableHostPrefix)??!1,endpointProvider:(e==null?void 0:e.endpointProvider)??sK,extensions:(e==null?void 0:e.extensions)??[],logger:(e==null?void 0:e.logger)??new fx,serviceId:(e==null?void 0:e.serviceId)??"Cognito Identity",urlParser:(e==null?void 0:e.urlParser)??tl,utf8Decoder:(e==null?void 0:e.utf8Decoder)??bl,utf8Encoder:(e==null?void 0:e.utf8Encoder)??Wf}),lK=["in-region","cross-region","mobile","standard","legacy"],Sx=({defaultsMode:e}={})=>vA(async()=>{const t=typeof e=="function"?await e():e;switch(t==null?void 0:t.toLowerCase()){case"auto":return Promise.resolve(cK()?"mobile":"standard");case"mobile":case"in-region":case"cross-region":case"standard":case"legacy":return Promise.resolve(t==null?void 0:t.toLocaleLowerCase());case void 0:return Promise.resolve("legacy");default:throw new Error(`Invalid parameter for "defaultsMode", expect ${lK.join(", ")}, got ${t}`)}}),cK=()=>{var r,n;const e=typeof window<"u"&&((r=window==null?void 0:window.navigator)!=null&&r.userAgent)?YA.parse(window.navigator.userAgent):void 0,t=(n=e==null?void 0:e.platform)==null?void 0:n.type;return t==="tablet"||t==="mobile"},fK=e=>{const t=Sx(e),r=()=>t().then(px),n=aK(e);return{...n,...e,runtime:"browser",defaultsMode:t,bodyLengthChecker:(e==null?void 0:e.bodyLengthChecker)??Ex,credentialDefaultProvider:(e==null?void 0:e.credentialDefaultProvider)??(i=>()=>Promise.reject(new Error("Credential is missing"))),defaultUserAgentProvider:(e==null?void 0:e.defaultUserAgentProvider)??bx({serviceId:n.serviceId,clientVersion:OW.version}),maxAttempts:(e==null?void 0:e.maxAttempts)??nl,region:(e==null?void 0:e.region)??wx("Region is missing"),requestHandler:(e==null?void 0:e.requestHandler)??new dx(r),retryMode:(e==null?void 0:e.retryMode)??(async()=>(await r()).retryMode||ax),sha256:(e==null?void 0:e.sha256)??J0.Sha256,streamCollector:(e==null?void 0:e.streamCollector)??hx,useDualstackEndpoint:(e==null?void 0:e.useDualstackEndpoint)??(()=>Promise.resolve(rx)),useFipsEndpoint:(e==null?void 0:e.useFipsEndpoint)??(()=>Promise.resolve(nx))}},Ax=e=>{let t=async()=>{if(e.region===void 0)throw new Error("Region is missing from runtimeConfig");const r=e.region;return typeof r=="string"?r:r()};return{setRegion(r){t=r},region(){return t}}},kx=e=>({region:e.region()}),K1=e=>e,uK=(e,t)=>{const r={...K1(Ax(e)),...K1(mx(e)),...K1(qm(e))};return t.forEach(n=>n.configure(r)),{...e,...kx(r),...xx(r),...Hm(r)}};class dK extends ux{constructor(...[t]){const r=fK(t||{}),n=mW(r),i=ix(n),o=sx(i),s=lx(o),a=s,l=Qm(a),c=Jm(l),f=uK(c,(t==null?void 0:t.extensions)||[]);super(f),this.config=f,this.middlewareStack.use(cx(this.config)),this.middlewareStack.use(ox(this.config)),this.middlewareStack.use(Gm(this.config)),this.middlewareStack.use(Wm(this.config)),this.middlewareStack.use(Km(this.config)),this.middlewareStack.use(tx(this.config))}destroy(){super.destroy()}}class kn extends Yf{constructor(t){super(t),Object.setPrototypeOf(this,kn.prototype)}}let hK=class ZA extends kn{constructor(t){super({name:"InternalErrorException",$fault:"server",...t}),this.name="InternalErrorException",this.$fault="server",Object.setPrototypeOf(this,ZA.prototype)}},vK=class e9 extends kn{constructor(t){super({name:"InvalidParameterException",$fault:"client",...t}),this.name="InvalidParameterException",this.$fault="client",Object.setPrototypeOf(this,e9.prototype)}};class Rx extends kn{constructor(t){super({name:"LimitExceededException",$fault:"client",...t}),this.name="LimitExceededException",this.$fault="client",Object.setPrototypeOf(this,Rx.prototype)}}let yK=class t9 extends kn{constructor(t){super({name:"NotAuthorizedException",$fault:"client",...t}),this.name="NotAuthorizedException",this.$fault="client",Object.setPrototypeOf(this,t9.prototype)}};class Px extends kn{constructor(t){super({name:"ResourceConflictException",$fault:"client",...t}),this.name="ResourceConflictException",this.$fault="client",Object.setPrototypeOf(this,Px.prototype)}}let pK=class r9 extends kn{constructor(t){super({name:"TooManyRequestsException",$fault:"client",...t}),this.name="TooManyRequestsException",this.$fault="client",Object.setPrototypeOf(this,r9.prototype)}},mK=class n9 extends kn{constructor(t){super({name:"ResourceNotFoundException",$fault:"client",...t}),this.name="ResourceNotFoundException",this.$fault="client",Object.setPrototypeOf(this,n9.prototype)}};class Tx extends kn{constructor(t){super({name:"ExternalServiceException",$fault:"client",...t}),this.name="ExternalServiceException",this.$fault="client",Object.setPrototypeOf(this,Tx.prototype)}}class _x extends kn{constructor(t){super({name:"InvalidIdentityPoolConfigurationException",$fault:"client",...t}),this.name="InvalidIdentityPoolConfigurationException",this.$fault="client",Object.setPrototypeOf(this,_x.prototype)}}const xK=async(e,t)=>{const r=h9("GetCredentialsForIdentity");let n;return n=JSON.stringify(we(e)),d9(t,r,"/",void 0,n)},gK=async(e,t)=>{const r=h9("GetId");let n;return n=JSON.stringify(we(e)),d9(t,r,"/",void 0,n)},bK=async(e,t)=>{if(e.statusCode>=300)return wK(e,t);const r=await Mx(e.body,t);let n={};return n=RK(r),{$metadata:Zn(e),...n}},wK=async(e,t)=>{const r={...e,body:await v9(e.body,t)},n=y9(e,r.body);switch(n){case"ExternalServiceException":case"com.amazonaws.cognitoidentity#ExternalServiceException":throw await i9(r);case"InternalErrorException":case"com.amazonaws.cognitoidentity#InternalErrorException":throw await o9(r);case"InvalidIdentityPoolConfigurationException":case"com.amazonaws.cognitoidentity#InvalidIdentityPoolConfigurationException":throw await SK(r);case"InvalidParameterException":case"com.amazonaws.cognitoidentity#InvalidParameterException":throw await s9(r);case"NotAuthorizedException":case"com.amazonaws.cognitoidentity#NotAuthorizedException":throw await a9(r);case"ResourceConflictException":case"com.amazonaws.cognitoidentity#ResourceConflictException":throw await l9(r);case"ResourceNotFoundException":case"com.amazonaws.cognitoidentity#ResourceNotFoundException":throw await c9(r);case"TooManyRequestsException":case"com.amazonaws.cognitoidentity#TooManyRequestsException":throw await f9(r);default:const i=r.body;return u9({output:e,parsedBody:i,errorCode:n})}},EK=async(e,t)=>{if(e.statusCode>=300)return CK(e,t);const r=await Mx(e.body,t);let n={};return n=we(r),{$metadata:Zn(e),...n}},CK=async(e,t)=>{const r={...e,body:await v9(e.body,t)},n=y9(e,r.body);switch(n){case"ExternalServiceException":case"com.amazonaws.cognitoidentity#ExternalServiceException":throw await i9(r);case"InternalErrorException":case"com.amazonaws.cognitoidentity#InternalErrorException":throw await o9(r);case"InvalidParameterException":case"com.amazonaws.cognitoidentity#InvalidParameterException":throw await s9(r);case"LimitExceededException":case"com.amazonaws.cognitoidentity#LimitExceededException":throw await AK(r);case"NotAuthorizedException":case"com.amazonaws.cognitoidentity#NotAuthorizedException":throw await a9(r);case"ResourceConflictException":case"com.amazonaws.cognitoidentity#ResourceConflictException":throw await l9(r);case"ResourceNotFoundException":case"com.amazonaws.cognitoidentity#ResourceNotFoundException":throw await c9(r);case"TooManyRequestsException":case"com.amazonaws.cognitoidentity#TooManyRequestsException":throw await f9(r);default:const i=r.body;return u9({output:e,parsedBody:i,errorCode:n})}},i9=async(e,t)=>{const r=e.body,n=we(r),i=new Tx({$metadata:Zn(e),...n});return Te(i,r)},o9=async(e,t)=>{const r=e.body,n=we(r),i=new hK({$metadata:Zn(e),...n});return Te(i,r)},SK=async(e,t)=>{const r=e.body,n=we(r),i=new _x({$metadata:Zn(e),...n});return Te(i,r)},s9=async(e,t)=>{const r=e.body,n=we(r),i=new vK({$metadata:Zn(e),...n});return Te(i,r)},AK=async(e,t)=>{const r=e.body,n=we(r),i=new Rx({$metadata:Zn(e),...n});return Te(i,r)},a9=async(e,t)=>{const r=e.body,n=we(r),i=new yK({$metadata:Zn(e),...n});return Te(i,r)},l9=async(e,t)=>{const r=e.body,n=we(r),i=new Px({$metadata:Zn(e),...n});return Te(i,r)},c9=async(e,t)=>{const r=e.body,n=we(r),i=new mK({$metadata:Zn(e),...n});return Te(i,r)},f9=async(e,t)=>{const r=e.body,n=we(r),i=new pK({$metadata:Zn(e),...n});return Te(i,r)},kK=(e,t)=>Qf(e,{AccessKeyId:Wc,Expiration:r=>nW(aW(qy(r))),SecretKey:Wc,SessionToken:Wc}),RK=(e,t)=>Qf(e,{Credentials:r=>kK(r),IdentityId:Wc}),Zn=e=>({httpStatusCode:e.statusCode,requestId:e.headers["x-amzn-requestid"]??e.headers["x-amzn-request-id"]??e.headers["x-amz-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}),PK=(e,t)=>vx(e,t).then(r=>t.utf8Encoder(r)),u9=yx(kn),d9=async(e,t,r,n,i)=>{const{hostname:o,protocol:s="https",port:a,path:l}=await e.endpoint(),c={protocol:s,hostname:o,port:a,method:"POST",path:l.endsWith("/")?l.slice(0,-1)+r:l+r,headers:t};return n!==void 0&&(c.hostname=n),i!==void 0&&(c.body=i),new Cn(c)};function h9(e){return{"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityService.${e}`}}const Mx=(e,t)=>PK(e,t).then(r=>r.length?JSON.parse(r):{}),v9=async(e,t)=>{const r=await Mx(e,t);return r.message=r.message??r.Message,r},y9=(e,t)=>{const r=(o,s)=>Object.keys(o).find(a=>a.toLowerCase()===s.toLowerCase()),n=o=>{let s=o;return typeof s=="number"&&(s=s.toString()),s.indexOf(",")>=0&&(s=s.split(",")[0]),s.indexOf(":")>=0&&(s=s.split(":")[0]),s.indexOf("#")>=0&&(s=s.split("#")[1]),s},i=r(e.headers,"x-amzn-errortype");if(i!==void 0)return n(e.headers[i]);if(t.code!==void 0)return n(t.code);if(t.__type!==void 0)return n(t.__type)};class Ix extends Sl{static getEndpointParameterInstructions(){return{UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}}}constructor(t){super(),this.input=t}resolveMiddleware(t,r,n){this.middlewareStack.use(wl(r,this.serialize,this.deserialize)),this.middlewareStack.use(El(r,Ix.getEndpointParameterInstructions()));const i=t.concat(this.middlewareStack),{logger:o}=r,l={logger:o,clientName:"CognitoIdentityClient",commandName:"GetCredentialsForIdentityCommand",inputFilterSensitiveLog:f=>f,outputFilterSensitiveLog:f=>f,[xl]:{service:"AWSCognitoIdentityService",operation:"GetCredentialsForIdentity"}},{requestHandler:c}=r;return i.resolve(f=>c.handle(f.request,n||{}),l)}serialize(t,r){return xK(t,r)}deserialize(t,r){return bK(t,r)}}class Nx extends Sl{static getEndpointParameterInstructions(){return{UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}}}constructor(t){super(),this.input=t}resolveMiddleware(t,r,n){this.middlewareStack.use(wl(r,this.serialize,this.deserialize)),this.middlewareStack.use(El(r,Nx.getEndpointParameterInstructions()));const i=t.concat(this.middlewareStack),{logger:o}=r,l={logger:o,clientName:"CognitoIdentityClient",commandName:"GetIdCommand",inputFilterSensitiveLog:f=>f,outputFilterSensitiveLog:f=>f,[xl]:{service:"AWSCognitoIdentityService",operation:"GetId"}},{requestHandler:c}=r;return i.resolve(f=>c.handle(f.request,n||{}),l)}serialize(t,r){return gK(t,r)}deserialize(t,r){return EK(t,r)}}function p9(e){return Promise.all(Object.keys(e).reduce((t,r)=>{const n=e[r];return typeof n=="string"?t.push([r,n]):t.push(n().then(i=>[r,i])),t},[])).then(t=>t.reduce((r,[n,i])=>(r[n]=i,r),{}))}function TK(e){return async()=>{const{Credentials:{AccessKeyId:t=_K(),Expiration:r,SecretKey:n=IK(),SessionToken:i}=MK()}=await e.client.send(new Ix({CustomRoleArn:e.customRoleArn,IdentityId:e.identityId,Logins:e.logins?await p9(e.logins):void 0}));return{identityId:e.identityId,accessKeyId:t,secretAccessKey:n,sessionToken:i,expiration:r}}}function _K(){throw new gl("Response from Amazon Cognito contained no access key ID")}function MK(){throw new gl("Response from Amazon Cognito contained no credentials")}function IK(){throw new gl("Response from Amazon Cognito contained no secret key")}const Y1="IdentityIds";class NK{constructor(t="aws:cognito-identity-ids"){this.dbName=t}getItem(t){return this.withObjectStore("readonly",r=>{const n=r.get(t);return new Promise(i=>{n.onerror=()=>i(null),n.onsuccess=()=>i(n.result?n.result.value:null)})}).catch(()=>null)}removeItem(t){return this.withObjectStore("readwrite",r=>{const n=r.delete(t);return new Promise((i,o)=>{n.onerror=()=>o(n.error),n.onsuccess=()=>i()})})}setItem(t,r){return this.withObjectStore("readwrite",n=>{const i=n.put({id:t,value:r});return new Promise((o,s)=>{i.onerror=()=>s(i.error),i.onsuccess=()=>o()})})}getDb(){const t=self.indexedDB.open(this.dbName,1);return new Promise((r,n)=>{t.onsuccess=()=>{r(t.result)},t.onerror=()=>{n(t.error)},t.onblocked=()=>{n(new Error("Unable to access DB"))},t.onupgradeneeded=()=>{const i=t.result;i.onerror=()=>{n(new Error("Failed to create object store"))},i.createObjectStore(Y1,{keyPath:"id"})}})}withObjectStore(t,r){return this.getDb().then(n=>{const i=n.transaction(Y1,t);return i.oncomplete=()=>n.close(),new Promise((o,s)=>{i.onerror=()=>s(i.error),o(r(i.objectStore(Y1)))}).catch(o=>{throw n.close(),o})})}}class $K{constructor(t={}){this.store=t}getItem(t){return t in this.store?this.store[t]:null}removeItem(t){delete this.store[t]}setItem(t,r){this.store[t]=r}}const DK=new $K;function OK(){return typeof self=="object"&&self.indexedDB?new NK:typeof window=="object"&&window.localStorage?window.localStorage:DK}function LK({accountId:e,cache:t=OK(),client:r,customRoleArn:n,identityPoolId:i,logins:o,userIdentifier:s=!o||Object.keys(o).length===0?"ANONYMOUS":void 0}){const a=s?`aws:cognito-identity-credentials:${i}:${s}`:void 0;let l=async()=>{let c=a&&await t.getItem(a);if(!c){const{IdentityId:f=BK()}=await r.send(new Nx({AccountId:e,IdentityPoolId:i,Logins:o?await p9(o):void 0}));c=f,a&&Promise.resolve(t.setItem(a,c)).catch(()=>{})}return l=TK({client:r,customRoleArn:n,logins:o,identityId:c}),l()};return()=>l().catch(async c=>{throw a&&Promise.resolve(t.removeItem(a)).catch(()=>{}),c})}function BK(){throw new gl("Response from Amazon Cognito contained no identity ID")}const FK=e=>LK({...e,client:new dK(e.clientConfig??{})});class Cc extends Error{}Cc.prototype.name="InvalidTokenError";function jK(e){return decodeURIComponent(atob(e).replace(/(.)/g,(t,r)=>{let n=r.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}))}function zK(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return jK(t)}catch{return atob(t)}}function UK(e,t){if(typeof e!="string")throw new Cc("Invalid token specified: must be a string");t||(t={});const r=t.header===!0?0:1,n=e.split(".")[r];if(typeof n!="string")throw new Cc(`Invalid token specified: missing part #${r+1}`);let i;try{i=zK(n)}catch(o){throw new Cc(`Invalid token specified: invalid base64 for part #${r+1} (${o.message})`)}try{return JSON.parse(i)}catch(o){throw new Cc(`Invalid token specified: invalid json for part #${r+1} (${o.message})`)}}const VK=e=>({...e,useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:"kms"}),qK="@aws-sdk/client-kms",HK="AWS SDK for JavaScript Kms Client for Node.js, Browser and React Native",GK="3.445.0",WK={build:"concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'","build:cjs":"tsc -p tsconfig.cjs.json","build:docs":"typedoc","build:es":"tsc -p tsconfig.es.json","build:include:deps":"lerna run --scope $npm_package_name --include-dependencies build","build:types":"tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4",clean:"rimraf ./dist-* && rimraf *.tsbuildinfo","extract:docs":"api-extractor run --local","generate:client":"node ../../scripts/generate-clients/single-service --solo kms"},KK="./dist-cjs/index.js",YK="./dist-types/index.d.ts",QK="./dist-es/index.js",JK=!1,XK={"@aws-crypto/sha256-browser":"3.0.0","@aws-crypto/sha256-js":"3.0.0","@aws-sdk/client-sts":"3.445.0","@aws-sdk/core":"3.445.0","@aws-sdk/credential-provider-node":"3.445.0","@aws-sdk/middleware-host-header":"3.433.0","@aws-sdk/middleware-logger":"3.433.0","@aws-sdk/middleware-recursion-detection":"3.433.0","@aws-sdk/middleware-signing":"3.433.0","@aws-sdk/middleware-user-agent":"3.438.0","@aws-sdk/region-config-resolver":"3.433.0","@aws-sdk/types":"3.433.0","@aws-sdk/util-endpoints":"3.438.0","@aws-sdk/util-user-agent-browser":"3.433.0","@aws-sdk/util-user-agent-node":"3.437.0","@smithy/config-resolver":"^2.0.16","@smithy/fetch-http-handler":"^2.2.4","@smithy/hash-node":"^2.0.12","@smithy/invalid-dependency":"^2.0.12","@smithy/middleware-content-length":"^2.0.14","@smithy/middleware-endpoint":"^2.1.3","@smithy/middleware-retry":"^2.0.18","@smithy/middleware-serde":"^2.0.12","@smithy/middleware-stack":"^2.0.6","@smithy/node-config-provider":"^2.1.3","@smithy/node-http-handler":"^2.1.8","@smithy/protocol-http":"^3.0.8","@smithy/smithy-client":"^2.1.12","@smithy/types":"^2.4.0","@smithy/url-parser":"^2.0.12","@smithy/util-base64":"^2.0.0","@smithy/util-body-length-browser":"^2.0.0","@smithy/util-body-length-node":"^2.1.0","@smithy/util-defaults-mode-browser":"^2.0.16","@smithy/util-defaults-mode-node":"^2.0.21","@smithy/util-endpoints":"^1.0.2","@smithy/util-retry":"^2.0.5","@smithy/util-utf8":"^2.0.0",tslib:"^2.5.0"},ZK={"@smithy/service-client-documentation-generator":"^2.0.0","@tsconfig/node14":"1.0.3","@types/node":"^14.14.31",concurrently:"7.0.0","downlevel-dts":"0.10.1",rimraf:"3.0.2",typedoc:"0.23.23",typescript:"~4.9.5"},eY={node:">=14.0.0"},tY={"<4.0":{"dist-types/*":["dist-types/ts3.4/*"]}},rY=["dist-*/**"],nY={name:"AWS SDK for JavaScript Team",url:"https://aws.amazon.com/javascript/"},iY="Apache-2.0",oY={"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.browser"},sY="https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-kms",aY={type:"git",url:"https://github.com/aws/aws-sdk-js-v3.git",directory:"clients/client-kms"},lY={name:qK,description:HK,version:GK,scripts:WK,main:KK,types:YK,module:QK,sideEffects:JK,dependencies:XK,devDependencies:ZK,engines:eY,typesVersions:tY,files:rY,author:nY,license:iY,browser:oY,"react-native":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.native"},homepage:sY,repository:aY},m9="required",xi="fn",gi="argv",kl="ref",n4=!0,i4="isSet",_f="booleanEquals",Xs="error",fc="endpoint",Bi="tree",$x="PartitionResult",o4={[m9]:!1,type:"String"},s4={[m9]:!0,default:!1,type:"Boolean"},a4={[kl]:"Endpoint"},x9={[xi]:_f,[gi]:[{[kl]:"UseFIPS"},!0]},g9={[xi]:_f,[gi]:[{[kl]:"UseDualStack"},!0]},ai={},l4={[xi]:"getAttr",[gi]:[{[kl]:$x},"supportsFIPS"]},c4={[xi]:_f,[gi]:[!0,{[xi]:"getAttr",[gi]:[{[kl]:$x},"supportsDualStack"]}]},f4=[x9],u4=[g9],d4=[{[kl]:"Region"}],cY={version:"1.0",parameters:{Region:o4,UseDualStack:s4,UseFIPS:s4,Endpoint:o4},rules:[{conditions:[{[xi]:i4,[gi]:[a4]}],rules:[{conditions:f4,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:Xs},{conditions:u4,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:Xs},{endpoint:{url:a4,properties:ai,headers:ai},type:fc}],type:Bi},{conditions:[{[xi]:i4,[gi]:d4}],rules:[{conditions:[{[xi]:"aws.partition",[gi]:d4,assign:$x}],rules:[{conditions:[x9,g9],rules:[{conditions:[{[xi]:_f,[gi]:[n4,l4]},c4],rules:[{endpoint:{url:"https://kms-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:ai,headers:ai},type:fc}],type:Bi},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:Xs}],type:Bi},{conditions:f4,rules:[{conditions:[{[xi]:_f,[gi]:[l4,n4]}],rules:[{endpoint:{url:"https://kms-fips.{Region}.{PartitionResult#dnsSuffix}",properties:ai,headers:ai},type:fc}],type:Bi},{error:"FIPS is enabled but this partition does not support FIPS",type:Xs}],type:Bi},{conditions:u4,rules:[{conditions:[c4],rules:[{endpoint:{url:"https://kms.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:ai,headers:ai},type:fc}],type:Bi},{error:"DualStack is enabled but this partition does not support DualStack",type:Xs}],type:Bi},{endpoint:{url:"https://kms.{Region}.{PartitionResult#dnsSuffix}",properties:ai,headers:ai},type:fc}],type:Bi}],type:Bi},{error:"Invalid Configuration: Missing Region",type:Xs}]},fY=cY,uY=(e,t={})=>ex(fY,{endpointParams:e,logger:t.logger}),dY=e=>({apiVersion:"2014-11-01",base64Decoder:(e==null?void 0:e.base64Decoder)??Kf,base64Encoder:(e==null?void 0:e.base64Encoder)??Q0,disableHostPrefix:(e==null?void 0:e.disableHostPrefix)??!1,endpointProvider:(e==null?void 0:e.endpointProvider)??uY,extensions:(e==null?void 0:e.extensions)??[],logger:(e==null?void 0:e.logger)??new fx,serviceId:(e==null?void 0:e.serviceId)??"KMS",urlParser:(e==null?void 0:e.urlParser)??tl,utf8Decoder:(e==null?void 0:e.utf8Decoder)??bl,utf8Encoder:(e==null?void 0:e.utf8Encoder)??Wf}),hY=e=>{const t=Sx(e),r=()=>t().then(px),n=dY(e);return{...n,...e,runtime:"browser",defaultsMode:t,bodyLengthChecker:(e==null?void 0:e.bodyLengthChecker)??Ex,credentialDefaultProvider:(e==null?void 0:e.credentialDefaultProvider)??(i=>()=>Promise.reject(new Error("Credential is missing"))),defaultUserAgentProvider:(e==null?void 0:e.defaultUserAgentProvider)??bx({serviceId:n.serviceId,clientVersion:lY.version}),maxAttempts:(e==null?void 0:e.maxAttempts)??nl,region:(e==null?void 0:e.region)??wx("Region is missing"),requestHandler:(e==null?void 0:e.requestHandler)??new dx(r),retryMode:(e==null?void 0:e.retryMode)??(async()=>(await r()).retryMode||ax),sha256:(e==null?void 0:e.sha256)??J0.Sha256,streamCollector:(e==null?void 0:e.streamCollector)??hx,useDualstackEndpoint:(e==null?void 0:e.useDualstackEndpoint)??(()=>Promise.resolve(rx)),useFipsEndpoint:(e==null?void 0:e.useFipsEndpoint)??(()=>Promise.resolve(nx))}},Q1=e=>e,vY=(e,t)=>{const r={...Q1(Ax(e)),...Q1(mx(e)),...Q1(qm(e))};return t.forEach(n=>n.configure(r)),{...e,...kx(r),...xx(r),...Hm(r)}};class yY extends ux{constructor(...[t]){const r=hY(t||{}),n=VK(r),i=ix(n),o=sx(i),s=lx(o),a=s,l=Qm(a),c=Jm(l),f=vY(c,(t==null?void 0:t.extensions)||[]);super(f),this.config=f,this.middlewareStack.use(cx(this.config)),this.middlewareStack.use(ox(this.config)),this.middlewareStack.use(Gm(this.config)),this.middlewareStack.use(Wm(this.config)),this.middlewareStack.use(Km(this.config)),this.middlewareStack.use(RH(this.config)),this.middlewareStack.use(tx(this.config))}destroy(){super.destroy()}}class Rn extends Yf{constructor(t){super(t),Object.setPrototypeOf(this,Rn.prototype)}}class Dx extends Rn{constructor(t){super({name:"DependencyTimeoutException",$fault:"server",...t}),this.name="DependencyTimeoutException",this.$fault="server",Object.setPrototypeOf(this,Dx.prototype)}}class Ox extends Rn{constructor(t){super({name:"KMSInternalException",$fault:"server",...t}),this.name="KMSInternalException",this.$fault="server",Object.setPrototypeOf(this,Ox.prototype)}}class Lx extends Rn{constructor(t){super({name:"KMSInvalidStateException",$fault:"client",...t}),this.name="KMSInvalidStateException",this.$fault="client",Object.setPrototypeOf(this,Lx.prototype)}}class Bx extends Rn{constructor(t){super({name:"NotFoundException",$fault:"client",...t}),this.name="NotFoundException",this.$fault="client",Object.setPrototypeOf(this,Bx.prototype)}}class Fx extends Rn{constructor(t){super({name:"DisabledException",$fault:"client",...t}),this.name="DisabledException",this.$fault="client",Object.setPrototypeOf(this,Fx.prototype)}}class jx extends Rn{constructor(t){super({name:"DryRunOperationException",$fault:"client",...t}),this.name="DryRunOperationException",this.$fault="client",Object.setPrototypeOf(this,jx.prototype)}}class zx extends Rn{constructor(t){super({name:"InvalidGrantTokenException",$fault:"client",...t}),this.name="InvalidGrantTokenException",this.$fault="client",Object.setPrototypeOf(this,zx.prototype)}}class Ux extends Rn{constructor(t){super({name:"InvalidKeyUsageException",$fault:"client",...t}),this.name="InvalidKeyUsageException",this.$fault="client",Object.setPrototypeOf(this,Ux.prototype)}}class Vx extends Rn{constructor(t){super({name:"KeyUnavailableException",$fault:"server",...t}),this.name="KeyUnavailableException",this.$fault="server",Object.setPrototypeOf(this,Vx.prototype)}}const pY=e=>({...e,...e.Plaintext&&{Plaintext:Yt}}),mY=async(e,t)=>{const r=DY("GenerateDataKey");let n;return n=JSON.stringify(TY(e,t)),$Y(t,r,"/",void 0,n)},xY=async(e,t)=>{if(e.statusCode>=300)return gY(e,t);const r=await b9(e.body,t);let n={};return n=MY(r,t),{$metadata:Di(e),...n}},gY=async(e,t)=>{const r={...e,body:await OY(e.body,t)},n=LY(e,r.body);switch(n){case"DependencyTimeoutException":case"com.amazonaws.kms#DependencyTimeoutException":throw await bY(r);case"DisabledException":case"com.amazonaws.kms#DisabledException":throw await wY(r);case"DryRunOperationException":case"com.amazonaws.kms#DryRunOperationException":throw await EY(r);case"InvalidGrantTokenException":case"com.amazonaws.kms#InvalidGrantTokenException":throw await CY(r);case"InvalidKeyUsageException":case"com.amazonaws.kms#InvalidKeyUsageException":throw await SY(r);case"KMSInternalException":case"com.amazonaws.kms#KMSInternalException":throw await kY(r);case"KMSInvalidStateException":case"com.amazonaws.kms#KMSInvalidStateException":throw await RY(r);case"KeyUnavailableException":case"com.amazonaws.kms#KeyUnavailableException":throw await AY(r);case"NotFoundException":case"com.amazonaws.kms#NotFoundException":throw await PY(r);default:const i=r.body;return NY({output:e,parsedBody:i,errorCode:n})}},bY=async(e,t)=>{const r=e.body,n=we(r),i=new Dx({$metadata:Di(e),...n});return Te(i,r)},wY=async(e,t)=>{const r=e.body,n=we(r),i=new Fx({$metadata:Di(e),...n});return Te(i,r)},EY=async(e,t)=>{const r=e.body,n=we(r),i=new jx({$metadata:Di(e),...n});return Te(i,r)},CY=async(e,t)=>{const r=e.body,n=we(r),i=new zx({$metadata:Di(e),...n});return Te(i,r)},SY=async(e,t)=>{const r=e.body,n=we(r),i=new Ux({$metadata:Di(e),...n});return Te(i,r)},AY=async(e,t)=>{const r=e.body,n=we(r),i=new Vx({$metadata:Di(e),...n});return Te(i,r)},kY=async(e,t)=>{const r=e.body,n=we(r),i=new Ox({$metadata:Di(e),...n});return Te(i,r)},RY=async(e,t)=>{const r=e.body,n=we(r),i=new Lx({$metadata:Di(e),...n});return Te(i,r)},PY=async(e,t)=>{const r=e.body,n=we(r),i=new Bx({$metadata:Di(e),...n});return Te(i,r)},TY=(e,t)=>Qf(e,{DryRun:[],EncryptionContext:we,GrantTokens:we,KeyId:[],KeySpec:[],NumberOfBytes:[],Recipient:r=>_Y(r,t)}),_Y=(e,t)=>Qf(e,{AttestationDocument:t.base64Encoder,KeyEncryptionAlgorithm:[]}),MY=(e,t)=>Qf(e,{CiphertextBlob:t.base64Decoder,CiphertextForRecipient:t.base64Decoder,KeyId:Wc,Plaintext:t.base64Decoder}),Di=e=>({httpStatusCode:e.statusCode,requestId:e.headers["x-amzn-requestid"]??e.headers["x-amzn-request-id"]??e.headers["x-amz-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}),IY=(e,t)=>vx(e,t).then(r=>t.utf8Encoder(r)),NY=yx(Rn),$Y=async(e,t,r,n,i)=>{const{hostname:o,protocol:s="https",port:a,path:l}=await e.endpoint(),c={protocol:s,hostname:o,port:a,method:"POST",path:l.endsWith("/")?l.slice(0,-1)+r:l+r,headers:t};return n!==void 0&&(c.hostname=n),i!==void 0&&(c.body=i),new Cn(c)};function DY(e){return{"content-type":"application/x-amz-json-1.1","x-amz-target":`TrentService.${e}`}}const b9=(e,t)=>IY(e,t).then(r=>r.length?JSON.parse(r):{}),OY=async(e,t)=>{const r=await b9(e,t);return r.message=r.message??r.Message,r},LY=(e,t)=>{const r=(o,s)=>Object.keys(o).find(a=>a.toLowerCase()===s.toLowerCase()),n=o=>{let s=o;return typeof s=="number"&&(s=s.toString()),s.indexOf(",")>=0&&(s=s.split(",")[0]),s.indexOf(":")>=0&&(s=s.split(":")[0]),s.indexOf("#")>=0&&(s=s.split("#")[1]),s},i=r(e.headers,"x-amzn-errortype");if(i!==void 0)return n(e.headers[i]);if(t.code!==void 0)return n(t.code);if(t.__type!==void 0)return n(t.__type)};class qx extends Sl{static getEndpointParameterInstructions(){return{UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}}}constructor(t){super(),this.input=t}resolveMiddleware(t,r,n){this.middlewareStack.use(wl(r,this.serialize,this.deserialize)),this.middlewareStack.use(El(r,qx.getEndpointParameterInstructions()));const i=t.concat(this.middlewareStack),{logger:o}=r,l={logger:o,clientName:"KMSClient",commandName:"GenerateDataKeyCommand",inputFilterSensitiveLog:f=>f,outputFilterSensitiveLog:pY,[xl]:{service:"TrentService",operation:"GenerateDataKey"}},{requestHandler:c}=r;return i.resolve(f=>c.handle(f.request,n||{}),l)}serialize(t,r){return mY(t,r)}deserialize(t,r){return xY(t,r)}}const BY=e=>({...e,useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:"cognito-idp"}),FY="@aws-sdk/client-cognito-identity-provider",jY="AWS SDK for JavaScript Cognito Identity Provider Client for Node.js, Browser and React Native",zY="3.445.0",UY={build:"concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'","build:cjs":"tsc -p tsconfig.cjs.json","build:docs":"typedoc","build:es":"tsc -p tsconfig.es.json","build:include:deps":"lerna run --scope $npm_package_name --include-dependencies build","build:types":"tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4",clean:"rimraf ./dist-* && rimraf *.tsbuildinfo","extract:docs":"api-extractor run --local","generate:client":"node ../../scripts/generate-clients/single-service --solo cognito-identity-provider"},VY="./dist-cjs/index.js",qY="./dist-types/index.d.ts",HY="./dist-es/index.js",GY=!1,WY={"@aws-crypto/sha256-browser":"3.0.0","@aws-crypto/sha256-js":"3.0.0","@aws-sdk/client-sts":"3.445.0","@aws-sdk/core":"3.445.0","@aws-sdk/credential-provider-node":"3.445.0","@aws-sdk/middleware-host-header":"3.433.0","@aws-sdk/middleware-logger":"3.433.0","@aws-sdk/middleware-recursion-detection":"3.433.0","@aws-sdk/middleware-signing":"3.433.0","@aws-sdk/middleware-user-agent":"3.438.0","@aws-sdk/region-config-resolver":"3.433.0","@aws-sdk/types":"3.433.0","@aws-sdk/util-endpoints":"3.438.0","@aws-sdk/util-user-agent-browser":"3.433.0","@aws-sdk/util-user-agent-node":"3.437.0","@smithy/config-resolver":"^2.0.16","@smithy/fetch-http-handler":"^2.2.4","@smithy/hash-node":"^2.0.12","@smithy/invalid-dependency":"^2.0.12","@smithy/middleware-content-length":"^2.0.14","@smithy/middleware-endpoint":"^2.1.3","@smithy/middleware-retry":"^2.0.18","@smithy/middleware-serde":"^2.0.12","@smithy/middleware-stack":"^2.0.6","@smithy/node-config-provider":"^2.1.3","@smithy/node-http-handler":"^2.1.8","@smithy/protocol-http":"^3.0.8","@smithy/smithy-client":"^2.1.12","@smithy/types":"^2.4.0","@smithy/url-parser":"^2.0.12","@smithy/util-base64":"^2.0.0","@smithy/util-body-length-browser":"^2.0.0","@smithy/util-body-length-node":"^2.1.0","@smithy/util-defaults-mode-browser":"^2.0.16","@smithy/util-defaults-mode-node":"^2.0.21","@smithy/util-endpoints":"^1.0.2","@smithy/util-retry":"^2.0.5","@smithy/util-utf8":"^2.0.0",tslib:"^2.5.0"},KY={"@smithy/service-client-documentation-generator":"^2.0.0","@tsconfig/node14":"1.0.3","@types/node":"^14.14.31",concurrently:"7.0.0","downlevel-dts":"0.10.1",rimraf:"3.0.2",typedoc:"0.23.23",typescript:"~4.9.5"},YY={node:">=14.0.0"},QY={"<4.0":{"dist-types/*":["dist-types/ts3.4/*"]}},JY=["dist-*/**"],XY={name:"AWS SDK for JavaScript Team",url:"https://aws.amazon.com/javascript/"},ZY="Apache-2.0",eQ={"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.browser"},tQ="https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-cognito-identity-provider",rQ={type:"git",url:"https://github.com/aws/aws-sdk-js-v3.git",directory:"clients/client-cognito-identity-provider"},nQ={name:FY,description:jY,version:zY,scripts:UY,main:VY,types:qY,module:HY,sideEffects:GY,dependencies:WY,devDependencies:KY,engines:YY,typesVersions:QY,files:JY,author:XY,license:ZY,browser:eQ,"react-native":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.native"},homepage:tQ,repository:rQ},w9="required",bi="fn",wi="argv",Rl="ref",h4=!0,v4="isSet",Mf="booleanEquals",Zs="error",uc="endpoint",Fi="tree",Hx="PartitionResult",y4={[w9]:!1,type:"String"},p4={[w9]:!0,default:!1,type:"Boolean"},m4={[Rl]:"Endpoint"},E9={[bi]:Mf,[wi]:[{[Rl]:"UseFIPS"},!0]},C9={[bi]:Mf,[wi]:[{[Rl]:"UseDualStack"},!0]},li={},x4={[bi]:"getAttr",[wi]:[{[Rl]:Hx},"supportsFIPS"]},g4={[bi]:Mf,[wi]:[!0,{[bi]:"getAttr",[wi]:[{[Rl]:Hx},"supportsDualStack"]}]},b4=[E9],w4=[C9],E4=[{[Rl]:"Region"}],iQ={version:"1.0",parameters:{Region:y4,UseDualStack:p4,UseFIPS:p4,Endpoint:y4},rules:[{conditions:[{[bi]:v4,[wi]:[m4]}],rules:[{conditions:b4,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:Zs},{conditions:w4,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:Zs},{endpoint:{url:m4,properties:li,headers:li},type:uc}],type:Fi},{conditions:[{[bi]:v4,[wi]:E4}],rules:[{conditions:[{[bi]:"aws.partition",[wi]:E4,assign:Hx}],rules:[{conditions:[E9,C9],rules:[{conditions:[{[bi]:Mf,[wi]:[h4,x4]},g4],rules:[{endpoint:{url:"https://cognito-idp-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:li,headers:li},type:uc}],type:Fi},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:Zs}],type:Fi},{conditions:b4,rules:[{conditions:[{[bi]:Mf,[wi]:[x4,h4]}],rules:[{endpoint:{url:"https://cognito-idp-fips.{Region}.{PartitionResult#dnsSuffix}",properties:li,headers:li},type:uc}],type:Fi},{error:"FIPS is enabled but this partition does not support FIPS",type:Zs}],type:Fi},{conditions:w4,rules:[{conditions:[g4],rules:[{endpoint:{url:"https://cognito-idp.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:li,headers:li},type:uc}],type:Fi},{error:"DualStack is enabled but this partition does not support DualStack",type:Zs}],type:Fi},{endpoint:{url:"https://cognito-idp.{Region}.{PartitionResult#dnsSuffix}",properties:li,headers:li},type:uc}],type:Fi}],type:Fi},{error:"Invalid Configuration: Missing Region",type:Zs}]},oQ=iQ,sQ=(e,t={})=>ex(oQ,{endpointParams:e,logger:t.logger}),aQ=e=>({apiVersion:"2016-04-18",base64Decoder:(e==null?void 0:e.base64Decoder)??Kf,base64Encoder:(e==null?void 0:e.base64Encoder)??Q0,disableHostPrefix:(e==null?void 0:e.disableHostPrefix)??!1,endpointProvider:(e==null?void 0:e.endpointProvider)??sQ,extensions:(e==null?void 0:e.extensions)??[],logger:(e==null?void 0:e.logger)??new fx,serviceId:(e==null?void 0:e.serviceId)??"Cognito Identity Provider",urlParser:(e==null?void 0:e.urlParser)??tl,utf8Decoder:(e==null?void 0:e.utf8Decoder)??bl,utf8Encoder:(e==null?void 0:e.utf8Encoder)??Wf}),lQ=e=>{const t=Sx(e),r=()=>t().then(px),n=aQ(e);return{...n,...e,runtime:"browser",defaultsMode:t,bodyLengthChecker:(e==null?void 0:e.bodyLengthChecker)??Ex,credentialDefaultProvider:(e==null?void 0:e.credentialDefaultProvider)??(i=>()=>Promise.reject(new Error("Credential is missing"))),defaultUserAgentProvider:(e==null?void 0:e.defaultUserAgentProvider)??bx({serviceId:n.serviceId,clientVersion:nQ.version}),maxAttempts:(e==null?void 0:e.maxAttempts)??nl,region:(e==null?void 0:e.region)??wx("Region is missing"),requestHandler:(e==null?void 0:e.requestHandler)??new dx(r),retryMode:(e==null?void 0:e.retryMode)??(async()=>(await r()).retryMode||ax),sha256:(e==null?void 0:e.sha256)??J0.Sha256,streamCollector:(e==null?void 0:e.streamCollector)??hx,useDualstackEndpoint:(e==null?void 0:e.useDualstackEndpoint)??(()=>Promise.resolve(rx)),useFipsEndpoint:(e==null?void 0:e.useFipsEndpoint)??(()=>Promise.resolve(nx))}},J1=e=>e,cQ=(e,t)=>{const r={...J1(Ax(e)),...J1(mx(e)),...J1(qm(e))};return t.forEach(n=>n.configure(r)),{...e,...kx(r),...xx(r),...Hm(r)}};class fQ extends ux{constructor(...[t]){const r=lQ(t||{}),n=BY(r),i=ix(n),o=sx(i),s=lx(o),a=s,l=Qm(a),c=Jm(l),f=cQ(c,(t==null?void 0:t.extensions)||[]);super(f),this.config=f,this.middlewareStack.use(cx(this.config)),this.middlewareStack.use(ox(this.config)),this.middlewareStack.use(Gm(this.config)),this.middlewareStack.use(Wm(this.config)),this.middlewareStack.use(Km(this.config)),this.middlewareStack.use(tx(this.config))}destroy(){super.destroy()}}class vt extends Yf{constructor(t){super(t),Object.setPrototypeOf(this,vt.prototype)}}class Gx extends vt{constructor(t){super({name:"InternalErrorException",$fault:"server",...t}),this.name="InternalErrorException",this.$fault="server",Object.setPrototypeOf(this,Gx.prototype)}}class Wx extends vt{constructor(t){super({name:"InvalidParameterException",$fault:"client",...t}),this.name="InvalidParameterException",this.$fault="client",Object.setPrototypeOf(this,Wx.prototype)}}class Kx extends vt{constructor(t){super({name:"NotAuthorizedException",$fault:"client",...t}),this.name="NotAuthorizedException",this.$fault="client",Object.setPrototypeOf(this,Kx.prototype)}}class Yx extends vt{constructor(t){super({name:"ResourceNotFoundException",$fault:"client",...t}),this.name="ResourceNotFoundException",this.$fault="client",Object.setPrototypeOf(this,Yx.prototype)}}class Qx extends vt{constructor(t){super({name:"TooManyRequestsException",$fault:"client",...t}),this.name="TooManyRequestsException",this.$fault="client",Object.setPrototypeOf(this,Qx.prototype)}}class Jx extends vt{constructor(t){super({name:"UserNotFoundException",$fault:"client",...t}),this.name="UserNotFoundException",this.$fault="client",Object.setPrototypeOf(this,Jx.prototype)}}class Xx extends vt{constructor(t){super({name:"InvalidLambdaResponseException",$fault:"client",...t}),this.name="InvalidLambdaResponseException",this.$fault="client",Object.setPrototypeOf(this,Xx.prototype)}}class Zx extends vt{constructor(t){super({name:"UnexpectedLambdaException",$fault:"client",...t}),this.name="UnexpectedLambdaException",this.$fault="client",Object.setPrototypeOf(this,Zx.prototype)}}class X0 extends vt{constructor(t){super({name:"UserLambdaValidationException",$fault:"client",...t}),this.name="UserLambdaValidationException",this.$fault="client",Object.setPrototypeOf(this,X0.prototype)}}class eg extends vt{constructor(t){super({name:"CodeDeliveryFailureException",$fault:"client",...t}),this.name="CodeDeliveryFailureException",this.$fault="client",Object.setPrototypeOf(this,eg.prototype)}}class tg extends vt{constructor(t){super({name:"InvalidPasswordException",$fault:"client",...t}),this.name="InvalidPasswordException",this.$fault="client",Object.setPrototypeOf(this,tg.prototype)}}class rg extends vt{constructor(t){super({name:"InvalidSmsRoleAccessPolicyException",$fault:"client",...t}),this.name="InvalidSmsRoleAccessPolicyException",this.$fault="client",Object.setPrototypeOf(this,rg.prototype)}}class ng extends vt{constructor(t){super({name:"InvalidSmsRoleTrustRelationshipException",$fault:"client",...t}),this.name="InvalidSmsRoleTrustRelationshipException",this.$fault="client",Object.setPrototypeOf(this,ng.prototype)}}class ig extends vt{constructor(t){super({name:"UsernameExistsException",$fault:"client",...t}),this.name="UsernameExistsException",this.$fault="client",Object.setPrototypeOf(this,ig.prototype)}}class og extends vt{constructor(t){super({name:"AliasExistsException",$fault:"client",...t}),this.name="AliasExistsException",this.$fault="client",Object.setPrototypeOf(this,og.prototype)}}class sg extends vt{constructor(t){super({name:"InvalidUserPoolConfigurationException",$fault:"client",...t}),this.name="InvalidUserPoolConfigurationException",this.$fault="client",Object.setPrototypeOf(this,sg.prototype)}}class ag extends vt{constructor(t){super({name:"MFAMethodNotFoundException",$fault:"client",...t}),this.name="MFAMethodNotFoundException",this.$fault="client",Object.setPrototypeOf(this,ag.prototype)}}class lg extends vt{constructor(t){super({name:"PasswordResetRequiredException",$fault:"client",...t}),this.name="PasswordResetRequiredException",this.$fault="client",Object.setPrototypeOf(this,lg.prototype)}}class cg extends vt{constructor(t){super({name:"UserNotConfirmedException",$fault:"client",...t}),this.name="UserNotConfirmedException",this.$fault="client",Object.setPrototypeOf(this,cg.prototype)}}class fg extends vt{constructor(t){super({name:"InvalidEmailRoleAccessPolicyException",$fault:"client",...t}),this.name="InvalidEmailRoleAccessPolicyException",this.$fault="client",Object.setPrototypeOf(this,fg.prototype)}}class ug extends vt{constructor(t){super({name:"CodeMismatchException",$fault:"client",...t}),this.name="CodeMismatchException",this.$fault="client",Object.setPrototypeOf(this,ug.prototype)}}class dg extends vt{constructor(t){super({name:"ExpiredCodeException",$fault:"client",...t}),this.name="ExpiredCodeException",this.$fault="client",Object.setPrototypeOf(this,dg.prototype)}}class hg extends vt{constructor(t){super({name:"SoftwareTokenMFANotFoundException",$fault:"client",...t}),this.name="SoftwareTokenMFANotFoundException",this.$fault="client",Object.setPrototypeOf(this,hg.prototype)}}class vg extends vt{constructor(t){super({name:"ForbiddenException",$fault:"client",...t}),this.name="ForbiddenException",this.$fault="client",Object.setPrototypeOf(this,vg.prototype)}}const C4=e=>({...e,...e.Value&&{Value:Yt}}),S9=e=>({...e,...e.AccessToken&&{AccessToken:Yt},...e.RefreshToken&&{RefreshToken:Yt},...e.IdToken&&{IdToken:Yt}}),uQ=e=>({...e,...e.AuthParameters&&{AuthParameters:Yt},...e.ClientId&&{ClientId:Yt},...e.UserContextData&&{UserContextData:Yt}}),dQ=e=>({...e,...e.Session&&{Session:Yt},...e.AuthenticationResult&&{AuthenticationResult:S9(e.AuthenticationResult)}}),hQ=e=>({...e,...e.ClientId&&{ClientId:Yt},...e.Session&&{Session:Yt},...e.ChallengeResponses&&{ChallengeResponses:Yt},...e.UserContextData&&{UserContextData:Yt}}),vQ=e=>({...e,...e.Session&&{Session:Yt},...e.AuthenticationResult&&{AuthenticationResult:S9(e.AuthenticationResult)}}),yQ=e=>({...e,...e.ClientId&&{ClientId:Yt},...e.SecretHash&&{SecretHash:Yt},...e.Username&&{Username:Yt},...e.Password&&{Password:Yt},...e.UserAttributes&&{UserAttributes:e.UserAttributes.map(t=>C4(t))},...e.ValidationData&&{ValidationData:e.ValidationData.map(t=>C4(t))},...e.UserContextData&&{UserContextData:Yt}}),pQ=async(e,t)=>{const r=Pg("InitiateAuth");let n;return n=JSON.stringify(we(e)),Rg(t,r,"/",void 0,n)},mQ=async(e,t)=>{const r=Pg("RespondToAuthChallenge");let n;return n=JSON.stringify(we(e)),Rg(t,r,"/",void 0,n)},xQ=async(e,t)=>{const r=Pg("SignUp");let n;return n=JSON.stringify(we(e)),Rg(t,r,"/",void 0,n)},gQ=async(e,t)=>{if(e.statusCode>=300)return bQ(e,t);const r=await Z0(e.body,t);let n={};return n=we(r),{$metadata:yt(e),...n}},bQ=async(e,t)=>{const r={...e,body:await Tg(e.body,t)},n=_g(e,r.body);switch(n){case"ForbiddenException":case"com.amazonaws.cognitoidentityprovider#ForbiddenException":throw await yg(r);case"InternalErrorException":case"com.amazonaws.cognitoidentityprovider#InternalErrorException":throw await pg(r);case"InvalidLambdaResponseException":case"com.amazonaws.cognitoidentityprovider#InvalidLambdaResponseException":throw await mg(r);case"InvalidParameterException":case"com.amazonaws.cognitoidentityprovider#InvalidParameterException":throw await xg(r);case"InvalidSmsRoleAccessPolicyException":case"com.amazonaws.cognitoidentityprovider#InvalidSmsRoleAccessPolicyException":throw await gg(r);case"InvalidSmsRoleTrustRelationshipException":case"com.amazonaws.cognitoidentityprovider#InvalidSmsRoleTrustRelationshipException":throw await bg(r);case"InvalidUserPoolConfigurationException":case"com.amazonaws.cognitoidentityprovider#InvalidUserPoolConfigurationException":throw await k9(r);case"NotAuthorizedException":case"com.amazonaws.cognitoidentityprovider#NotAuthorizedException":throw await wg(r);case"PasswordResetRequiredException":case"com.amazonaws.cognitoidentityprovider#PasswordResetRequiredException":throw await R9(r);case"ResourceNotFoundException":case"com.amazonaws.cognitoidentityprovider#ResourceNotFoundException":throw await Eg(r);case"TooManyRequestsException":case"com.amazonaws.cognitoidentityprovider#TooManyRequestsException":throw await Cg(r);case"UnexpectedLambdaException":case"com.amazonaws.cognitoidentityprovider#UnexpectedLambdaException":throw await Sg(r);case"UserLambdaValidationException":case"com.amazonaws.cognitoidentityprovider#UserLambdaValidationException":throw await Ag(r);case"UserNotConfirmedException":case"com.amazonaws.cognitoidentityprovider#UserNotConfirmedException":throw await P9(r);case"UserNotFoundException":case"com.amazonaws.cognitoidentityprovider#UserNotFoundException":throw await T9(r);default:const i=r.body;return kg({output:e,parsedBody:i,errorCode:n})}},wQ=async(e,t)=>{if(e.statusCode>=300)return EQ(e,t);const r=await Z0(e.body,t);let n={};return n=we(r),{$metadata:yt(e),...n}},EQ=async(e,t)=>{const r={...e,body:await Tg(e.body,t)},n=_g(e,r.body);switch(n){case"AliasExistsException":case"com.amazonaws.cognitoidentityprovider#AliasExistsException":throw await AQ(r);case"CodeMismatchException":case"com.amazonaws.cognitoidentityprovider#CodeMismatchException":throw await RQ(r);case"ExpiredCodeException":case"com.amazonaws.cognitoidentityprovider#ExpiredCodeException":throw await PQ(r);case"ForbiddenException":case"com.amazonaws.cognitoidentityprovider#ForbiddenException":throw await yg(r);case"InternalErrorException":case"com.amazonaws.cognitoidentityprovider#InternalErrorException":throw await pg(r);case"InvalidLambdaResponseException":case"com.amazonaws.cognitoidentityprovider#InvalidLambdaResponseException":throw await mg(r);case"InvalidParameterException":case"com.amazonaws.cognitoidentityprovider#InvalidParameterException":throw await xg(r);case"InvalidPasswordException":case"com.amazonaws.cognitoidentityprovider#InvalidPasswordException":throw await A9(r);case"InvalidSmsRoleAccessPolicyException":case"com.amazonaws.cognitoidentityprovider#InvalidSmsRoleAccessPolicyException":throw await gg(r);case"InvalidSmsRoleTrustRelationshipException":case"com.amazonaws.cognitoidentityprovider#InvalidSmsRoleTrustRelationshipException":throw await bg(r);case"InvalidUserPoolConfigurationException":case"com.amazonaws.cognitoidentityprovider#InvalidUserPoolConfigurationException":throw await k9(r);case"MFAMethodNotFoundException":case"com.amazonaws.cognitoidentityprovider#MFAMethodNotFoundException":throw await _Q(r);case"NotAuthorizedException":case"com.amazonaws.cognitoidentityprovider#NotAuthorizedException":throw await wg(r);case"PasswordResetRequiredException":case"com.amazonaws.cognitoidentityprovider#PasswordResetRequiredException":throw await R9(r);case"ResourceNotFoundException":case"com.amazonaws.cognitoidentityprovider#ResourceNotFoundException":throw await Eg(r);case"SoftwareTokenMFANotFoundException":case"com.amazonaws.cognitoidentityprovider#SoftwareTokenMFANotFoundException":throw await MQ(r);case"TooManyRequestsException":case"com.amazonaws.cognitoidentityprovider#TooManyRequestsException":throw await Cg(r);case"UnexpectedLambdaException":case"com.amazonaws.cognitoidentityprovider#UnexpectedLambdaException":throw await Sg(r);case"UserLambdaValidationException":case"com.amazonaws.cognitoidentityprovider#UserLambdaValidationException":throw await Ag(r);case"UserNotConfirmedException":case"com.amazonaws.cognitoidentityprovider#UserNotConfirmedException":throw await P9(r);case"UserNotFoundException":case"com.amazonaws.cognitoidentityprovider#UserNotFoundException":throw await T9(r);default:const i=r.body;return kg({output:e,parsedBody:i,errorCode:n})}},CQ=async(e,t)=>{if(e.statusCode>=300)return SQ(e,t);const r=await Z0(e.body,t);let n={};return n=we(r),{$metadata:yt(e),...n}},SQ=async(e,t)=>{const r={...e,body:await Tg(e.body,t)},n=_g(e,r.body);switch(n){case"CodeDeliveryFailureException":case"com.amazonaws.cognitoidentityprovider#CodeDeliveryFailureException":throw await kQ(r);case"ForbiddenException":case"com.amazonaws.cognitoidentityprovider#ForbiddenException":throw await yg(r);case"InternalErrorException":case"com.amazonaws.cognitoidentityprovider#InternalErrorException":throw await pg(r);case"InvalidEmailRoleAccessPolicyException":case"com.amazonaws.cognitoidentityprovider#InvalidEmailRoleAccessPolicyException":throw await TQ(r);case"InvalidLambdaResponseException":case"com.amazonaws.cognitoidentityprovider#InvalidLambdaResponseException":throw await mg(r);case"InvalidParameterException":case"com.amazonaws.cognitoidentityprovider#InvalidParameterException":throw await xg(r);case"InvalidPasswordException":case"com.amazonaws.cognitoidentityprovider#InvalidPasswordException":throw await A9(r);case"InvalidSmsRoleAccessPolicyException":case"com.amazonaws.cognitoidentityprovider#InvalidSmsRoleAccessPolicyException":throw await gg(r);case"InvalidSmsRoleTrustRelationshipException":case"com.amazonaws.cognitoidentityprovider#InvalidSmsRoleTrustRelationshipException":throw await bg(r);case"NotAuthorizedException":case"com.amazonaws.cognitoidentityprovider#NotAuthorizedException":throw await wg(r);case"ResourceNotFoundException":case"com.amazonaws.cognitoidentityprovider#ResourceNotFoundException":throw await Eg(r);case"TooManyRequestsException":case"com.amazonaws.cognitoidentityprovider#TooManyRequestsException":throw await Cg(r);case"UnexpectedLambdaException":case"com.amazonaws.cognitoidentityprovider#UnexpectedLambdaException":throw await Sg(r);case"UserLambdaValidationException":case"com.amazonaws.cognitoidentityprovider#UserLambdaValidationException":throw await Ag(r);case"UsernameExistsException":case"com.amazonaws.cognitoidentityprovider#UsernameExistsException":throw await IQ(r);default:const i=r.body;return kg({output:e,parsedBody:i,errorCode:n})}},AQ=async(e,t)=>{const r=e.body,n=we(r),i=new og({$metadata:yt(e),...n});return Te(i,r)},kQ=async(e,t)=>{const r=e.body,n=we(r),i=new eg({$metadata:yt(e),...n});return Te(i,r)},RQ=async(e,t)=>{const r=e.body,n=we(r),i=new ug({$metadata:yt(e),...n});return Te(i,r)},PQ=async(e,t)=>{const r=e.body,n=we(r),i=new dg({$metadata:yt(e),...n});return Te(i,r)},yg=async(e,t)=>{const r=e.body,n=we(r),i=new vg({$metadata:yt(e),...n});return Te(i,r)},pg=async(e,t)=>{const r=e.body,n=we(r),i=new Gx({$metadata:yt(e),...n});return Te(i,r)},TQ=async(e,t)=>{const r=e.body,n=we(r),i=new fg({$metadata:yt(e),...n});return Te(i,r)},mg=async(e,t)=>{const r=e.body,n=we(r),i=new Xx({$metadata:yt(e),...n});return Te(i,r)},xg=async(e,t)=>{const r=e.body,n=we(r),i=new Wx({$metadata:yt(e),...n});return Te(i,r)},A9=async(e,t)=>{const r=e.body,n=we(r),i=new tg({$metadata:yt(e),...n});return Te(i,r)},gg=async(e,t)=>{const r=e.body,n=we(r),i=new rg({$metadata:yt(e),...n});return Te(i,r)},bg=async(e,t)=>{const r=e.body,n=we(r),i=new ng({$metadata:yt(e),...n});return Te(i,r)},k9=async(e,t)=>{const r=e.body,n=we(r),i=new sg({$metadata:yt(e),...n});return Te(i,r)},_Q=async(e,t)=>{const r=e.body,n=we(r),i=new ag({$metadata:yt(e),...n});return Te(i,r)},wg=async(e,t)=>{const r=e.body,n=we(r),i=new Kx({$metadata:yt(e),...n});return Te(i,r)},R9=async(e,t)=>{const r=e.body,n=we(r),i=new lg({$metadata:yt(e),...n});return Te(i,r)},Eg=async(e,t)=>{const r=e.body,n=we(r),i=new Yx({$metadata:yt(e),...n});return Te(i,r)},MQ=async(e,t)=>{const r=e.body,n=we(r),i=new hg({$metadata:yt(e),...n});return Te(i,r)},Cg=async(e,t)=>{const r=e.body,n=we(r),i=new Qx({$metadata:yt(e),...n});return Te(i,r)},Sg=async(e,t)=>{const r=e.body,n=we(r),i=new Zx({$metadata:yt(e),...n});return Te(i,r)},Ag=async(e,t)=>{const r=e.body,n=we(r),i=new X0({$metadata:yt(e),...n});return Te(i,r)},IQ=async(e,t)=>{const r=e.body,n=we(r),i=new ig({$metadata:yt(e),...n});return Te(i,r)},P9=async(e,t)=>{const r=e.body,n=we(r),i=new cg({$metadata:yt(e),...n});return Te(i,r)},T9=async(e,t)=>{const r=e.body,n=we(r),i=new Jx({$metadata:yt(e),...n});return Te(i,r)},yt=e=>({httpStatusCode:e.statusCode,requestId:e.headers["x-amzn-requestid"]??e.headers["x-amzn-request-id"]??e.headers["x-amz-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}),NQ=(e,t)=>vx(e,t).then(r=>t.utf8Encoder(r)),kg=yx(vt),Rg=async(e,t,r,n,i)=>{const{hostname:o,protocol:s="https",port:a,path:l}=await e.endpoint(),c={protocol:s,hostname:o,port:a,method:"POST",path:l.endsWith("/")?l.slice(0,-1)+r:l+r,headers:t};return n!==void 0&&(c.hostname=n),i!==void 0&&(c.body=i),new Cn(c)};function Pg(e){return{"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityProviderService.${e}`}}const Z0=(e,t)=>NQ(e,t).then(r=>r.length?JSON.parse(r):{}),Tg=async(e,t)=>{const r=await Z0(e,t);return r.message=r.message??r.Message,r},_g=(e,t)=>{const r=(o,s)=>Object.keys(o).find(a=>a.toLowerCase()===s.toLowerCase()),n=o=>{let s=o;return typeof s=="number"&&(s=s.toString()),s.indexOf(",")>=0&&(s=s.split(",")[0]),s.indexOf(":")>=0&&(s=s.split(":")[0]),s.indexOf("#")>=0&&(s=s.split("#")[1]),s},i=r(e.headers,"x-amzn-errortype");if(i!==void 0)return n(e.headers[i]);if(t.code!==void 0)return n(t.code);if(t.__type!==void 0)return n(t.__type)};class Mg extends Sl{static getEndpointParameterInstructions(){return{UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}}}constructor(t){super(),this.input=t}resolveMiddleware(t,r,n){this.middlewareStack.use(wl(r,this.serialize,this.deserialize)),this.middlewareStack.use(El(r,Mg.getEndpointParameterInstructions()));const i=t.concat(this.middlewareStack),{logger:o}=r,l={logger:o,clientName:"CognitoIdentityProviderClient",commandName:"InitiateAuthCommand",inputFilterSensitiveLog:uQ,outputFilterSensitiveLog:dQ,[xl]:{service:"AWSCognitoIdentityProviderService",operation:"InitiateAuth"}},{requestHandler:c}=r;return i.resolve(f=>c.handle(f.request,n||{}),l)}serialize(t,r){return pQ(t,r)}deserialize(t,r){return gQ(t,r)}}class Ig extends Sl{static getEndpointParameterInstructions(){return{UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}}}constructor(t){super(),this.input=t}resolveMiddleware(t,r,n){this.middlewareStack.use(wl(r,this.serialize,this.deserialize)),this.middlewareStack.use(El(r,Ig.getEndpointParameterInstructions()));const i=t.concat(this.middlewareStack),{logger:o}=r,l={logger:o,clientName:"CognitoIdentityProviderClient",commandName:"RespondToAuthChallengeCommand",inputFilterSensitiveLog:hQ,outputFilterSensitiveLog:vQ,[xl]:{service:"AWSCognitoIdentityProviderService",operation:"RespondToAuthChallenge"}},{requestHandler:c}=r;return i.resolve(f=>c.handle(f.request,n||{}),l)}serialize(t,r){return mQ(t,r)}deserialize(t,r){return wQ(t,r)}}class Ng extends Sl{static getEndpointParameterInstructions(){return{UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}}}constructor(t){super(),this.input=t}resolveMiddleware(t,r,n){this.middlewareStack.use(wl(r,this.serialize,this.deserialize)),this.middlewareStack.use(El(r,Ng.getEndpointParameterInstructions()));const i=t.concat(this.middlewareStack),{logger:o}=r,l={logger:o,clientName:"CognitoIdentityProviderClient",commandName:"SignUpCommand",inputFilterSensitiveLog:yQ,outputFilterSensitiveLog:f=>f,[xl]:{service:"AWSCognitoIdentityProviderService",operation:"SignUp"}},{requestHandler:c}=r;return i.resolve(f=>c.handle(f.request,n||{}),l)}serialize(t,r){return xQ(t,r)}deserialize(t,r){return CQ(t,r)}}function jt(){return jt=Object.assign?Object.assign.bind():function(e){for(var t=1;t{if(!o.to||o.to===i7)throw new Error("Contract creation not supported");return{type:"transaction",to:o.to,value:fe.from(o.value||0).toHexString(),data:he(o.data||[])}})})}function FQ({wallet:e,token:t,to:r,value:n,chainId:i,lifespan:o,identifier:s}){return jt({},ei(o),{identifier:s,code:"sendTransaction",wallet:e,network:i.toString(),transactions:[{type:"erc20send",token:t,to:r,value:fe.from(n).toString()}]})}function jQ({wallet:e,token:t,to:r,id:n,chainId:i,lifespan:o,identifier:s,safe:a,data:l}){return jt({},ei(o),{identifier:s,code:"sendTransaction",wallet:e,network:i.toString(),transactions:[{type:"erc721send",token:t,to:r,id:n,safe:a,data:l}]})}function zQ({wallet:e,token:t,to:r,values:n,chainId:i,lifespan:o,identifier:s,data:a}){return jt({},ei(o),{identifier:s,code:"sendTransaction",wallet:e,network:i.toString(),transactions:[{type:"erc1155send",token:t,to:r,vals:n.map(l=>({id:l.id,amount:fe.from(l.amount).toString()})),data:a}]})}function UQ({wallet:e,to:t,value:r,abi:n,func:i,args:o,chainId:s,lifespan:a,identifier:l}){return jt({},ei(a),{identifier:l,code:"sendTransaction",wallet:e,network:s.toString(),transactions:[{type:"delayedEncode",to:t,value:fe.from(r).toString(),data:{abi:n,func:i,args:o}}]})}function VQ(e){if(e.length===0)throw new Error("No packets provided");const t=e[0].network,r=e[0].wallet,n=e[0].expires-e[0].issued,i=e[0].identifier;if(!e.every(o=>o.network===t))throw new Error("All packets must have the same chainId");if(!e.every(o=>o.wallet===r))throw new Error("All packets must have the same wallet");return jt({},ei(n),{identifier:i,code:"sendTransaction",network:t,wallet:r,transactions:e.reduce((o,s)=>o.concat(s.transactions),[])})}function $g(e){return typeof e=="object"&&typeof e.code=="string"&&e.code==="transactionReceipt"&&typeof e.data=="object"&&typeof e.data.txHash=="string"&&typeof e.data.receipt=="object"&&typeof e.data.request=="object"}function qQ(e){return typeof e=="object"&&typeof e.code=="string"&&e.code==="transactionFailed"&&typeof e.data=="object"&&typeof e.data.request=="object"&&Array.isArray(e.data.simulations)&&typeof e.data.error=="string"}function dc(e){return $g(e)||qQ(e)}function HQ(e){return typeof e=="object"&&typeof e.code=="string"&&e.code==="signedMessage"&&typeof e.data=="object"&&typeof e.data.message=="string"&&typeof e.data.signature=="string"}function GQ(e){return typeof e=="object"&&typeof e.code=="string"&&e.code==="validationRequired"&&typeof e.data=="object"&&typeof e.data.sessionId=="string"}function WQ(e){return typeof e=="object"&&typeof e.code=="string"&&e.code==="getSessionResponse"&&typeof e.data=="object"&&typeof e.data.session=="string"&&typeof e.data.wallet=="string"}function KQ(e){"version"in e&&(e=e.packet);const t=Xt(ZV(e));return se(Ct(t))}function YQ(e,t){const r=KQ(t);return e.signMessage(r)}class QQ{constructor(t,r){this.path="/rpc/Guard/",this.ping=n=>this.fetch(this.url("Ping"),Sr({},n)).then(i=>Ar(i).then(o=>({status:o.status}))),this.version=n=>this.fetch(this.url("Version"),Sr({},n)).then(i=>Ar(i).then(o=>({version:o.version}))),this.runtimeStatus=n=>this.fetch(this.url("RuntimeStatus"),Sr({},n)).then(i=>Ar(i).then(o=>({status:o.status}))),this.signTransactions=(n,i)=>this.fetch(this.url("SignTransactions"),Sr(n,i)).then(o=>Ar(o).then(s=>({sig:s.sig}))),this.signMessage=(n,i)=>this.fetch(this.url("SignMessage"),Sr(n,i)).then(o=>Ar(o).then(s=>({sig:s.sig}))),this.getGuardSignerAddress=(n,i)=>this.fetch(this.url("GetGuardSignerAddress"),Sr(n,i)).then(o=>Ar(o).then(s=>({address:s.address}))),this.getWalletTransactionPolicyList=(n,i)=>this.fetch(this.url("GetWalletTransactionPolicyList"),Sr(n,i)).then(o=>Ar(o).then(s=>({policyList:s.policyList}))),this.setWalletTransactionPolicyList=(n,i)=>this.fetch(this.url("SetWalletTransactionPolicyList"),Sr(n,i)).then(o=>Ar(o).then(s=>({}))),this.getSessionUserMapRules=(n,i)=>this.fetch(this.url("GetSessionUserMapRules"),Sr(n,i)).then(o=>Ar(o).then(s=>({rules:s.rules}))),this.setSessionUserMapRules=(n,i)=>this.fetch(this.url("SetSessionUserMapRules"),Sr(n,i)).then(o=>Ar(o).then(s=>({}))),this.getSession=(n,i)=>this.fetch(this.url("GetSession"),Sr(n,i)).then(o=>Ar(o).then(s=>({validated:s.validated}))),this.registerSession=(n,i)=>this.fetch(this.url("RegisterSession"),Sr(n,i)).then(o=>Ar(o).then(s=>({sessionId:s.sessionId}))),this.startSessionValidation=(n,i)=>this.fetch(this.url("StartSessionValidation"),Sr(n,i)).then(o=>Ar(o).then(s=>({salt:s.salt}))),this.validateSession=(n,i)=>this.fetch(this.url("ValidateSession"),Sr(n,i)).then(o=>Ar(o).then(s=>({status:s.status}))),this.invalidateSession=(n,i)=>this.fetch(this.url("InvalidateSession"),Sr(n,i)).then(o=>Ar(o).then(s=>({status:s.status}))),this.hostname=t,this.fetch=(n,i)=>r(n,i)}url(t){return this.hostname+this.path+t}}const Sr=(e={},t={})=>({method:"POST",headers:jt({},t,{"Content-Type":"application/json"}),body:JSON.stringify(e||{})}),Ar=e=>e.text().then(t=>{let r;try{r=JSON.parse(t)}catch{throw{code:"unknown",msg:`expecting JSON, got: ${t}`,status:e.status}}if(!e.ok)throw r;return r});function JQ({wallet:e,chainId:t,message:r,lifespan:n}){return jt({},ei(n),{code:"signMessage",wallet:e,network:t.toString(),message:r.startsWith("0x")?r:he(Xt(r))})}const Gy={mainnet:1,goerli:5,polygon:137,"polygon-zkevm":1101,mumbai:80001,bsc:56,"bsc-testnet":97,arbitrum:42161,"arbitrum-nova":42170,"arbitrum-goerli":421613,optimism:10,gnosis:100,avalanche:43114,"avalanche-testnet":43113,"base-goerli":84531},XQ=Object.entries(Gy).reduce((e,[t,r])=>(e[r]=t,e),{});function S4(e){if(typeof e=="number"){if(e in XQ)return e;throw new Error(`Unknown network id ${e}`)}const t=e.toLowerCase();if(t in Gy)return Gy[t];throw new Error(`Unknown network name ${e}`)}const M9="https://guard2.sequence.app",I9={rpcServer:"http://localhost:9123",kmsRegion:"us-east-2",idpRegion:"us-east-2",emailRegion:"us-east-2",keyId:"arn:aws:kms:us-east-1:000000000000:key/aeb99e0f-9e89-44de-a084-e1817af47778",endpoint:"http://localstack:4566"},ZQ={rpcServer:"https://d14tu8valot5m0.cloudfront.net",kmsRegion:"us-east-2",idpRegion:"us-east-2",emailRegion:"us-east-2",keyId:"arn:aws:kms:us-east-2:170768627592:key/0fd8f803-9cb5-4de5-86e4-41963fb6043d",endpoint:void 0};var eJ=Object.freeze({__proto__:null,DEFAULT_GUARD:M9,TEMPLATE_LOCAL:I9,TEMPLATE_NEXT:ZQ});const tJ="@0xsequence.waas.wallet",rJ="@0xsequence.waas.signer",nJ="@0xsequence.waas.status",ea=5*60;class iJ{constructor(t={network:1},r=new _9,n=M9){this.VERSION="0.0.0-dev1",this.config=t,this.store=r,this.guardUrl=n,this.status=new Kc(this.store,nJ,"signed-out"),this.signer=new Kc(this.store,rJ,void 0),this.wallet=new Kc(this.store,tJ,void 0)}async getAddress(){return this.getWalletAddress()}async getWalletAddress(){if(!await this.isSignedIn())throw new Error("Not signed in");const t=await this.wallet.get();if(!t)throw new Error("No wallet");return t}async commonArgs(t){var r;return jt({},t,{identifier:t==null?void 0:t.identifier,wallet:await this.getWalletAddress(),lifespan:(r=t==null?void 0:t.lifespan)!=null?r:ea,chainId:S4(t.network||this.config.network)})}async buildPayload(t){if(!await this.isSignedIn())throw new Error("Not signed in");const r=await this.signer.get();if(!r)throw new Error("No signer");const n=new qn(r),i=await YQ(n,t);return{version:this.VERSION,packet:t,signatures:[{session:n.address,signature:i}]}}async signUsingSessionKey(t){const r=await this.signer.get();if(!r)throw new Error("No signer");return new qn(r).signMessage(t)}async getSignerAddress(){const t=await this.signer.get();if(!t)throw new Error("No signer");return new qn(t).address}async getSessionID(){return this.getSignerAddress()}async getSessionShortID(){return(await this.getSessionID()).substring(2,8)}async signIn(t){await this.status.get()!=="signed-out"&&await this.completeSignOut();const n=await $Q({proof:t,lifespan:ea});return await Promise.all([this.status.set("pending"),this.signer.set(n.signer.privateKey)]),{version:this.VERSION,packet:n.packet,signatures:[]}}async signOut({lifespan:t,sessionId:r}={}){const n=await DQ({lifespan:t||ea,wallet:await this.getWalletAddress(),session:r||await this.getSignerAddress()});return this.buildPayload(n)}async completeSignOut(){await Promise.all([this.status.set("signed-out"),this.signer.set(void 0),this.wallet.set(void 0)])}async completeSignIn(t){if(t.result)return this.completeSignIn(t.result);const r=await this.status.get(),n=await this.signer.get();if(t.code!=="sessionOpened")throw new Error("Invalid receipt");if(r!=="pending"||!n)throw new Error("No pending sign in");if(new qn(n).address.toLowerCase()!==t.data.sessionId.toLowerCase())throw new Error("Invalid signer");return await Promise.all([this.status.set("signed-in"),this.wallet.set(t.data.wallet)]),t.data.wallet}async isSignedIn(){return await this.status.get()==="signed-in"}async signMessage(t){var r;const n=JQ(jt({chainId:S4(t.network||this.config.network),lifespan:(r=t.lifespan)!=null?r:ea,wallet:await this.getWalletAddress()},t));return this.buildPayload(n)}async sendTransaction(t){const r=BQ(await this.commonArgs(t));return this.buildPayload(r)}async sendERC20(t){if(t.token.toLowerCase()===t.to.toLowerCase())throw new Error("Cannot burn tokens using sendERC20");const r=FQ(await this.commonArgs(t));return this.buildPayload(r)}async sendERC721(t){if(t.token.toLowerCase()===t.to.toLowerCase())throw new Error("Cannot burn tokens using sendERC721");const r=jQ(await this.commonArgs(t));return this.buildPayload(r)}async sendERC1155(t){if(t.token.toLowerCase()===t.to.toLowerCase())throw new Error("Cannot burn tokens using sendERC1155");const r=zQ(await this.commonArgs(t));return this.buildPayload(r)}async callContract(t){const r=UQ(await this.commonArgs(t));return this.buildPayload(r)}async validateSession({deviceMetadata:t,redirectURL:r}){const n=await OQ({lifespan:ea,session:await this.getSignerAddress(),deviceMetadata:t,redirectURL:r,wallet:await this.getWalletAddress()});return this.buildPayload(n)}async getSession(){const t=await LQ({session:await this.getSignerAddress(),wallet:await this.getWalletAddress(),lifespan:ea});return this.buildPayload(t)}async isSessionValid(){const t=await this.getSignerAddress(),r=new QQ(this.guardUrl,fetch);try{if((await r.getSession({sessionAddress:t})).validated)return!0}catch{}return!1}async waitForSessionValid(t=6e5,r=2e3){const n=Date.now();for(;Date.now()-nsetTimeout(i,r))}return!1}async batch(t){const r=VQ(t.map(n=>n.packet));return this.buildPayload(r)}}class oJ{constructor(t,r){this.path="/rpc/WaasAuthenticator/",this.registerSession=(n,i,o)=>this.fetch(this.url("RegisterSession"),hc(n,i,o)).then(s=>vc(s).then(a=>({session:a.session,data:a.data})),s=>{throw So.new({cause:`fetch(): ${s.message||""}`})}),this.listSessions=(n,i,o)=>this.fetch(this.url("ListSessions"),hc(n,i,o)).then(s=>vc(s).then(a=>({sessions:a.sessions})),s=>{throw So.new({cause:`fetch(): ${s.message||""}`})}),this.dropSession=(n,i,o)=>this.fetch(this.url("DropSession"),hc(n,i,o)).then(s=>vc(s).then(a=>({ok:a.ok})),s=>{throw So.new({cause:`fetch(): ${s.message||""}`})}),this.getAddress=(n,i,o)=>this.fetch(this.url("GetAddress"),hc(n,i,o)).then(s=>vc(s).then(a=>({address:a.address})),s=>{throw So.new({cause:`fetch(): ${s.message||""}`})}),this.sendIntent=(n,i,o)=>this.fetch(this.url("SendIntent"),hc(n,i,o)).then(s=>vc(s).then(a=>({code:a.code,data:a.data})),s=>{throw So.new({cause:`fetch(): ${s.message||""}`})}),this.hostname=t,this.fetch=(n,i)=>r(n,i)}url(t){return this.hostname+this.path+t}}const hc=(e={},t={},r=null)=>({method:"POST",headers:jt({},t,{"Content-Type":"application/json"}),body:JSON.stringify(e||{}),signal:r}),vc=e=>e.text().then(t=>{let r;try{r=JSON.parse(t)}catch(n){let i="";throw n instanceof Error&&(i=n.message),eh.new({status:e.status,cause:`JSON.parse(): ${i}: response text: ${t}`})}if(!e.ok){const n=typeof r.code=="number"?r.code:0;throw(sJ[n]||ti).new(r)}return r});class ti extends Error{constructor(t,r,n,i,o){super(n),this.name=t||"WebrpcError",this.code=typeof r=="number"?r:0,this.message=n||`endpoint error ${this.code}`,this.msg=this.message,this.status=typeof i=="number"?i:0,this.cause=o,Object.setPrototypeOf(this,ti.prototype)}static new(t){return new this(t.error,t.code,t.message||t.msg,t.status,t.cause)}}class Dg extends ti{constructor(t="WebrpcEndpoint",r=0,n="endpoint error",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,Dg.prototype)}}class So extends ti{constructor(t="WebrpcRequestFailed",r=-1,n="request failed",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,So.prototype)}}class Og extends ti{constructor(t="WebrpcBadRoute",r=-2,n="bad route",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,Og.prototype)}}class Lg extends ti{constructor(t="WebrpcBadMethod",r=-3,n="bad method",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,Lg.prototype)}}class Bg extends ti{constructor(t="WebrpcBadRequest",r=-4,n="bad request",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,Bg.prototype)}}class eh extends ti{constructor(t="WebrpcBadResponse",r=-5,n="bad response",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,eh.prototype)}}class Fg extends ti{constructor(t="WebrpcServerPanic",r=-6,n="server panic",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,Fg.prototype)}}class jg extends ti{constructor(t="WebrpcInternalError",r=-7,n="internal error",i=0,o){super(t,r,n,i,o),Object.setPrototypeOf(this,jg.prototype)}}const sJ={0:Dg,[-1]:So,[-2]:Og,[-3]:Lg,[-4]:Bg,[-5]:eh,[-6]:Fg,[-7]:jg};function aJ(e){const t=new Uint8Array(e);return window.crypto.getRandomValues(t),Array.from(t).map(r=>r.toString(16).padStart(2,"0")).join("")}class lJ{constructor(t,r){this.region=t,this.clientId=r}cognito(){return this.cognitoMemo||(this.cognitoMemo=new fQ({region:this.region})),this.cognitoMemo}signUp(t){return this.cognito().send(new Ng({ClientId:this.clientId,Username:t,Password:"aB1%"+aJ(14),UserAttributes:[{Name:"email",Value:t}]}))}signIn(t){return this.cognito().send(new Mg({AuthFlow:"CUSTOM_AUTH",ClientId:this.clientId,AuthParameters:{USERNAME:t}}))}async initiateAuth({email:t}){let r;try{r=await this.signIn(t)}catch(n){if(n instanceof X0&&n.message.includes("user not found"))await this.signUp(t),r=await this.signIn(t);else throw n}if(!r.Session)throw new Error("response session is empty");return{instance:r.Session,email:t}}async finalizeAuth({instance:t,email:r,answer:n}){const i=await this.cognito().send(new Ig({ClientId:this.clientId,Session:t,ChallengeName:"CUSTOM_CHALLENGE",ChallengeResponses:{USERNAME:r,ANSWER:n}}));if(!i.AuthenticationResult||!i.AuthenticationResult.IdToken)throw new Error("AuthenticationResult.IdToken is empty");return{idToken:i.AuthenticationResult.IdToken}}}function X1(e){return"0x"+Array.from(typeof e=="string"?new TextEncoder().encode(e):e,t=>t.toString(16).padStart(2,"0")).join("")}function cJ(e){return new Uint8Array(e.substring(2).match(/.{1,2}/g).map(t=>parseInt(t,16)))}function fJ(e){return JSON.parse(atob(e))}function uJ(e,t){const r=e.key,n=r?fJ(r):{},i=jt({},t,e,n);if(i.network===void 0&&(i.network=1),i.tenant===void 0)throw new Error("Missing tenant");if(i.secret===void 0)throw new Error("Missing secret");if(i.identityPoolId===void 0)throw new Error("Missing identityPoolId");return i}class dJ{constructor(t,r=I9,n=new _9){this.validationRequiredCallback=[],this.store=n,this.config=uJ(t,r),this.waas=new iJ(jt({network:1},t),this.store),this.client=new oJ(this.config.rpcServer,window.fetch),this.kmsKey=new Kc(this.store,"@0xsequence.waas.auth.key",void 0),this.deviceName=new Kc(this.store,"@0xsequence.waas.auth.deviceName",void 0)}get email(){if(this.emailClient)return this.emailClient;if(!this.config.emailRegion)throw new Error("Missing emailRegion");if(!this.config.emailClientId)throw new Error("Missing emailClientId");return this.emailClient=new lJ(this.config.emailRegion,this.config.emailClientId),this.emailClient}async onValidationRequired(t){return this.validationRequiredCallback.push(t),()=>{this.validationRequiredCallback=this.validationRequiredCallback.filter(r=>r!==t)}}async handleValidationRequired({onValidationRequired:t,redirectURL:r}={}){var n;if(!(t?t():!0))return!1;for(const s of this.validationRequiredCallback)s();const o=await this.waas.validateSession({redirectURL:r,deviceMetadata:(n=await this.deviceName.get())!=null?n:"Unknown device"});return await this.sendIntent(o),this.waitForSessionValid()}async useStoredCypherKey(){const t=await this.kmsKey.get();if(!t)throw new Error("No stored key");const r=JSON.parse(t);if(r.encryptedPayloadKey&&r.plainHex)return r;throw new Error("Invalid stored key")}async saveCypherKey(t){const r=await t.send(new qx({KeyId:this.config.keyId,KeySpec:"AES_256"}));if(!r.CiphertextBlob||!r.Plaintext)throw new Error("invalid response from KMS");return this.kmsKey.set(JSON.stringify({encryptedPayloadKey:X1(r.CiphertextBlob),plainHex:X1(r.Plaintext)}))}async sendIntent(t){const r={sessionId:await this.waas.getSessionID(),intentJson:JSON.stringify(t,null,0)},{args:n,headers:i}=await this.preparePayload(r);return this.client.sendIntent(n,i)}async preparePayload(t){const{encryptedPayloadKey:r,plainHex:n}=await this.useStoredCypherKey(),i={name:"AES-CBC",iv:window.crypto.getRandomValues(new Uint8Array(16))},o=await window.crypto.subtle.importKey("raw",cJ(n),i,!1,["encrypt"]),s=new TextEncoder().encode(JSON.stringify(t)),a=await window.crypto.subtle.encrypt(i,o,s),l=X1(new Uint8Array([...i.iv,...new Uint8Array(a)])),c=await this.waas.signUsingSessionKey(s);return{headers:{"X-Sequence-Tenant":this.config.tenant},args:{encryptedPayloadKey:r,payloadCiphertext:l,payloadSig:c}}}async isSignedIn(){return this.waas.isSignedIn()}async signIn(t,r){const n=await this.waas.signIn({idToken:t.idToken}),i=UK(t.idToken);if(!i.iss)throw new Error("Invalid idToken");const o=new yY({region:this.config.kmsRegion,endpoint:this.config.endpoint,credentials:FK({identityPoolId:this.config.identityPoolId,logins:{[i.iss.replace("https://","").replace("http://","")]:t.idToken},clientConfig:{region:this.config.idpRegion}})});await this.saveCypherKey(o);const s={projectId:this.config.tenant,idToken:t.idToken,sessionAddress:n.packet.session,friendlyName:r,intentJSON:JSON.stringify(n,null,0)},{args:a,headers:l}=await this.preparePayload(s),c=await this.client.registerSession(a,l);return await this.waas.completeSignIn({code:"sessionOpened",data:{sessionId:c.session.id,wallet:c.data.wallet}}),this.deviceName.set(r),c.session.address}async refreshSession(){throw new Error("Not implemented")}async getSessionID(){return this.waas.getSessionID()}async dropSession({sessionId:t,strict:r}={}){const n=await this.waas.getSessionID(),i=t||n;try{const o={dropSessionId:i,sessionId:n},{args:s,headers:a}=await this.preparePayload(o);await this.client.dropSession(s,a)}catch(o){if(r)throw o;console.error(o)}i.toLowerCase()===n.toLowerCase()&&(await this.waas.completeSignOut(),this.kmsKey.set(void 0),this.deviceName.set(void 0))}async listSessions(){const t={sessionId:await this.waas.getSessionID()},r=await this.waas.getSessionID().then(s=>s.toLowerCase()),{args:n,headers:i}=await this.preparePayload(t);return(await this.client.listSessions(n,i)).sessions.map(s=>jt({},s,{isThis:s.address.toLowerCase()===r}))}async getAddress(){return this.waas.getAddress()}async validateSession(t){return await this.waas.isSessionValid()?!0:this.handleValidationRequired(t)}async isSessionValid(){const t=await this.waas.getSession(),r=await this.sendIntent(t);if(!WQ(r))throw new Error(`Invalid response: ${JSON.stringify(r)}`);return r.data.validated}async waitForSessionValid(t=6e5,r=2e3){const n=Date.now();for(;Date.now()-nsetTimeout(i,r))}return!1}async useIdentifier(t){if(t.identifier)return t;const r=`ts-sdk-${Date.now()}-${await this.waas.getSignerAddress()}`;return jt({},t,{identifier:r})}async trySendIntent(t,r,n){const i=await this.sendIntent(r);if(n(i))return i;if(GQ(i)&&await this.handleValidationRequired(t.validation)){const s=await this.sendIntent(r);if(n(s))return s}throw new Error(JSON.stringify(i))}async signMessage(t){const r=await this.waas.signMessage(await this.useIdentifier(t));return this.trySendIntent(t,r,HQ)}async sendTransaction(t){const r=await this.waas.sendTransaction(await this.useIdentifier(t));return this.trySendIntent(t,r,dc)}async sendERC20(t){const r=await this.waas.sendERC20(await this.useIdentifier(t));return this.trySendIntent(t,r,dc)}async sendERC721(t){const r=await this.waas.sendERC721(await this.useIdentifier(t));return this.trySendIntent(t,r,dc)}async sendERC1155(t){const r=await this.waas.sendERC1155(await this.useIdentifier(t));return this.trySendIntent(t,r,dc)}async callContract(t){const r=await this.waas.callContract(await this.useIdentifier(t));return this.trySendIntent(t,r,dc)}}function hJ(){const[e,t]=x.useState(),[r,n]=x.useState(""),[i,o]=x.useState(""),[s,a]=x.useState(),[l,c]=x.useState(!1),[f,u]=x.useState();x.useEffect(()=>{d()},[]);const d=async()=>{const m=Qt.getAddress();t(await bJ.getBalance(m))},v=async(m,y)=>{try{u(void 0),c(!0);const w=await Qt.sendTransaction({transactions:[{to:m,value:UV(y)}]});$g(w)?a(w.data.txHash):u(w.data.error),c(!1)}catch(w){console.error(w),c(!1)}};return Y.jsxs(le,{children:[Y.jsx(le,{marginBottom:"5",children:Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Send native token transaction"})}),Y.jsxs(We,{variant:"normal",fontWeight:"bold",children:["Native token balance: ",zV(e||0)," MATIC"]}),Y.jsx(Uo,{marginLeft:"2",size:"xs",label:"Fetch",onClick:d}),Y.jsx(le,{marginTop:"5",children:Y.jsx(Ei,{name:"sendNativeTokenTo",type:"text",onChange:m=>{n(m.target.value)},value:r,placeholder:"To address 0x...",required:!0,"data-id":"nativeTokenSendAddress"})}),Y.jsx(le,{marginTop:"5",children:Y.jsx(Ei,{name:"sendNativeTokenAmount",type:"text",onChange:m=>{o(m.target.value)},value:i,placeholder:"Amount",required:!0,"data-id":"nativeTokenSendAmount"})}),f&&Y.jsxs(le,{marginTop:"3",children:["Transaction failed: ",f]}),l?Y.jsx(le,{gap:"2",marginY:"4",alignItems:"center",justifyContent:"center",children:Y.jsx(Qa,{})}):Y.jsx(Uo,{marginTop:"5",label:"Send native token",disabled:r===""&&i==="",onClick:()=>v(r,i)}),s&&Y.jsxs(le,{marginTop:"3",children:[Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Send native token transaction hash:"}),Y.jsx("br",{}),Y.jsx("a",{href:`https://polygonscan.com/tx/${s}`,target:"_blank",rel:"noopener noreferrer",children:s})]})]})}function vJ(){const[e,t]=x.useState(),[r,n]=x.useState(),[i,o]=x.useState(!0),[s,a]=x.useState(),l=async c=>{o(!0),t(void 0);try{await Qt.dropSession({sessionId:c}),t(await Qt.listSessions())}catch(f){a(f.message),t(await Qt.listSessions())}o(!1)};return x.useEffect(()=>{Promise.all([Qt.listSessions(),Qt.getSessionID()]).then(([c,f])=>{t(c),n(f),o(!1)}).catch(c=>{a(c.message),o(!1)})},[]),Y.jsxs(le,{children:[Y.jsxs(le,{marginBottom:"5",children:[Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Your open sessions"}),e&&Y.jsx(Y.Fragment,{children:e.map(c=>Y.jsxs(le,{children:[c.friendlyName,!c.isThis&&Y.jsx("a",{style:{marginLeft:"7px",textDecoration:"underline",cursor:"pointer"},onClick:()=>l(c.id),children:"x"}),c.isThis&&Y.jsx(Y.Fragment,{children:" (current)"})]},c.id))}),i&&Y.jsx(Qa,{})]}),s&&Y.jsxs(We,{variant:"normal",color:"text100",fontWeight:"bold",children:["Error loading sessions: ",s]})]})}function yJ(){const[e,t]=x.useState(""),[r,n]=x.useState(),i=async()=>{const o=await Qt.signMessage({message:e});n(o.data.signature)};return Y.jsxs(le,{children:[Y.jsx(le,{marginBottom:"5",children:Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Sign message"})}),Y.jsx(Ei,{name:"signMessageText",type:"text",onChange:o=>{t(o.target.value),r!=""&&n("")},value:e,placeholder:"Enter a message to sign",required:!0,"data-id":"signMessageInput"}),Y.jsx(Uo,{marginTop:"5",label:"Sign message",disabled:e==="",onClick:()=>i()}),r&&r!==""&&Y.jsxs(le,{flexDirection:"column",marginTop:"5",children:[Y.jsxs(We,{variant:"normal",color:"text100",fontWeight:"bold",children:["Signature for ",e,":"]}),Y.jsx(le,{children:Y.jsx(We,{as:"p",wordBreak:"break-word",children:r})})]})]})}function pJ(){const[e,t]=x.useState(""),[r,n]=x.useState(""),[i,o]=x.useState(""),[s,a]=x.useState(""),[l,c]=x.useState(),[f,u]=x.useState(!1),[d,v]=x.useState(),m=async()=>{try{v(void 0),u(!0);const y=await Qt.callContract({to:e,abi:r,func:i,args:JSON.parse(s),value:0});$g(y)?c(y.data.txHash):v(y.data.error),u(!1)}catch(y){console.error(y),u(!1)}};return Y.jsxs(le,{children:[Y.jsx(le,{marginBottom:"5",children:Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Call any contract"})}),Y.jsx(le,{marginTop:"5",children:Y.jsx(Ei,{name:"callContractAddress",type:"text",onChange:y=>{t(y.target.value)},value:e,placeholder:"Contract address 0x...",required:!0,"data-id":"nativeTokenSendAddress"})}),Y.jsx(le,{marginTop:"5",children:Y.jsx(Ei,{name:"callContractAbi",type:"text",onChange:y=>{n(y.target.value)},value:r,placeholder:"Contract ABI or function ABI, e.g. [{...}] or [{...}, {...}] or transfer(address,uint256)",required:!0,"data-id":"nativeTokenSendAmount"})}),Y.jsx(le,{marginTop:"5",children:Y.jsx(Ei,{name:"callContractMethod",type:"text",onChange:y=>{o(y.target.value)},value:i,placeholder:"Method name, e.g. transfer",required:!0,"data-id":"nativeTokenSendAmount"})}),Y.jsx(le,{marginTop:"5",children:Y.jsx(Ei,{name:"callContractArgs",type:"text",onChange:y=>{a(y.target.value)},value:s,placeholder:'Method args, e.g. [0x..., 1000] or named { "to": "0x...", "amount": "1000" }',required:!0,"data-id":"nativeTokenSendAmount"})}),d&&Y.jsxs(le,{marginTop:"3",children:["Transaction failed: ",d]}),f?Y.jsx(le,{gap:"2",marginY:"4",alignItems:"center",justifyContent:"center",children:Y.jsx(Qa,{})}):Y.jsx(Uo,{marginTop:"5",label:"Call contract",disabled:e===""&&r===""&&i===""&&s==="",onClick:()=>m()}),l&&Y.jsxs(le,{marginTop:"3",children:[Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Send native token transaction hash:"}),Y.jsx("br",{}),Y.jsx("a",{href:`https://polygonscan.com/tx/${l}`,target:"_blank",rel:"noopener noreferrer",children:l})]})]})}function mJ(){const[e,t]=x.useState(),[r,n]=x.useState(),[i,o]=x.useState();return x.useEffect(()=>{Qt.getAddress().then(s=>{t(s)}).catch(s=>{n(s.message)})},[]),x.useEffect(()=>{Qt.isSignedIn().then(s=>{s||Oa.navigate("/login")})},[]),Qt.onValidationRequired(()=>{o("Check your email to validate your session"),Qt.waitForSessionValid(600*1e3,4e3).then(()=>{o(void 0)})}),Y.jsxs(Y.Fragment,{children:[Y.jsx(gI,{children:i&&Y.jsx(rO,{children:Y.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"Helvetica, Arial, sans-serif",fontSize:"1.2em",height:"50vh"},children:i})})}),Y.jsxs(le,{marginY:"0",marginX:"auto",paddingX:"6",style:{maxWidth:"720px",marginTop:"80px",marginBottom:"80px"},children:[Y.jsx(le,{marginBottom:"10",children:Y.jsx(GS,{})}),Y.jsxs(le,{marginBottom:"5",flexDirection:"row",children:[Y.jsxs(We,{marginTop:"1",variant:"normal",color:"text100",children:["Logged in with email:"," "]}),Y.jsx(Uo,{marginLeft:"auto",label:"Log out",size:"xs",onClick:async()=>{try{await Qt.dropSession({strict:!1})}catch(s){console.warn(`Could not drop session: ${s.message}`)}xF(),Oa.navigate("/login")}})]}),Y.jsx(Fl,{background:"buttonGlass"}),Y.jsx(le,{marginBottom:"5",children:Y.jsx(We,{variant:"normal",color:"text100",fontWeight:"bold",children:"Your wallet address:"})}),Y.jsx(le,{marginBottom:"4",children:e?Y.jsx(le,{children:Y.jsx(We,{children:e})}):Y.jsx(Qa,{})}),Y.jsx(le,{children:r&&Y.jsxs(We,{children:["Error fetching wallet address: ",r]})}),Y.jsx(Fl,{background:"buttonGlass"}),Y.jsx(vJ,{}),Y.jsx(Fl,{background:"buttonGlass"}),Y.jsx(hJ,{}),Y.jsx(Fl,{background:"buttonGlass"}),Y.jsx(yJ,{}),Y.jsx(Fl,{background:"buttonGlass"}),Y.jsx(pJ,{})]})]})}const xJ="970987756660-35a6tc48hvi8cev9cnknp0iugv9poa23.apps.googleusercontent.com",gJ={}.VITE_SEQUENCE_API_KEY,bJ=new OV("https://nodes.sequence.app/polygon"),Qt=new dJ({network:"polygon",key:gJ},eJ.TEMPLATE_NEXT),Oa=aF([{path:"/login",element:Y.jsx(XV,{})},{path:"/",element:Y.jsx(mJ,{})}]);Z1.createRoot(document.getElementById("root")).render(Y.jsx(er.StrictMode,{children:Y.jsx(YL,{children:Y.jsx(hF,{clientId:xJ,children:Y.jsx(nF,{router:Oa})})})})); diff --git a/index.html b/index.html index 5461962..5835748 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ Demo Waas App - +