UNPKG

@walletconnect/utils

Version:
12 lines (11 loc) • 42.1 kB
"use strict";var Qt=require("detect-browser"),j=require("@walletconnect/time"),v=require("@walletconnect/window-getters"),Xt=require("@walletconnect/window-metadata"),Zt=require("@noble/hashes/sha3"),Ue=require("ox"),oe=require("@noble/hashes/sha2"),en=require("@noble/hashes/blake2"),Pe=require("@msgpack/msgpack"),x=require("@scure/base"),l=require("uint8arrays"),$e=require("@noble/ciphers/chacha"),tn=require("@noble/hashes/hkdf"),W=require("@noble/hashes/utils"),J=require("@noble/hashes/sha256"),ae=require("@noble/curves/ed25519"),nn=require("@noble/curves/p256"),rn=require("@walletconnect/relay-auth"),sn=require("@walletconnect/relay-api"),on=require("blakejs"),an=require("@walletconnect/logger");const z=":";function ie(e){const[t,n]=e.split(z);return{namespace:t,reference:n}}function je(e){const{namespace:t,reference:n}=e;return[t,n].join(z)}function ce(e){const[t,n,r]=e.split(z);return{namespace:t,reference:n,address:r}}function xe(e){const{namespace:t,reference:n,address:r}=e;return[t,n,r].join(z)}function ue(e,t){const n=[];return e.forEach(r=>{const s=t(r);n.includes(s)||n.push(s)}),n}function De(e){const{address:t}=ce(e);return t}function _e(e){const{namespace:t,reference:n}=ce(e);return je({namespace:t,reference:n})}function cn(e,t){const{namespace:n,reference:r}=ie(t);return xe({namespace:n,reference:r,address:e})}function un(e){return ue(e,De)}function ke(e){return ue(e,_e)}function dn(e,t=[]){const n=[];return Object.keys(e).forEach(r=>{if(t.length&&!t.includes(r))return;const s=e[r];n.push(...s.accounts)}),n}function ln(e,t=[]){const n=[];return Object.keys(e).forEach(r=>{if(t.length&&!t.includes(r))return;const s=e[r];n.push(...ke(s.accounts))}),n}function pn(e,t=[]){const n=[];return Object.keys(e).forEach(r=>{if(t.length&&!t.includes(r))return;const s=e[r];n.push(...Y(r,s))}),n}function Y(e,t){return e.includes(":")?[e]:t.chains||[]}const Ve={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},Me={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function w(e,t){const{message:n,code:r}=Me[e];return{message:t?`${n} ${t}`:n,code:r}}function C(e,t){const{message:n,code:r}=Ve[e];return{message:t?`${n} ${t}`:n,code:r}}const Le="ReactNative",h={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},G=" ",fn=":",Fe="/",de=2,mn=1e3,qe="js";function le(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function R(){return!v.getDocument()&&!!v.getNavigator()&&navigator.product===Le}function hn(){return R()&&typeof global<"u"&&typeof global?.Platform<"u"&&global?.Platform.OS==="android"}function gn(){return R()&&typeof global<"u"&&typeof global?.Platform<"u"&&global?.Platform.OS==="ios"}function D(){return!le()&&!!v.getNavigator()&&!!v.getDocument()}function U(){return R()?h.reactNative:le()?h.node:D()?h.browser:h.unknown}function yn(){try{return R()&&typeof global<"u"&&typeof global?.Application<"u"?global.Application?.applicationId:void 0}catch{return}}function Ke(e,t){const n=new URLSearchParams(e);return Object.entries(t).sort(([r],[s])=>r.localeCompare(s)).forEach(([r,s])=>{s!=null&&n.set(r,String(s))}),n.toString()}function En(e){const t=Be();try{return e?.url&&t.url&&new URL(e.url).host!==new URL(t.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${e.url} differs from the actual page url:${t.url}. This is probably unintended and can lead to issues.`),e.url=t.url),e?.icons?.length&&e.icons.length>0&&(e.icons=e.icons.filter(n=>n!=="")),{...t,...e,url:e?.url||t.url,name:e?.name||t.name,description:e?.description||t.description,icons:e?.icons?.length&&e.icons.length>0?e.icons:t.icons}}catch(n){return console.warn("Error populating app metadata",n),e||t}}function Be(){return Xt.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function bn(e,t){const n=U(),r={protocol:e,version:t,env:n};return n==="browser"&&(r.host=v.getLocation()?.host||"unknown"),r}function He(){if(U()===h.reactNative&&typeof global<"u"&&typeof global?.Platform<"u"){const{OS:n,Version:r}=global.Platform;return[n,r].join("-")}const e=Qt.detect();if(e===null)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return e.type==="browser"?[t,e.name,e.version].join("-"):[t,e.version].join("-")}function We(){const e=U();return e===h.browser?[e,v.getLocation()?.host||"unknown"].join(":"):e}function Je(e,t,n){const r=He(),s=We();return[[e,t].join("-"),[qe,n].join("-"),r,s].join("/")}function wn({protocol:e,version:t,relayUrl:n,sdkVersion:r,auth:s,projectId:o,useOnCloseEvent:a,bundleId:c,packageName:d}){const i=n.split("?"),p=Je(e,t,r),u={auth:s,ua:p,projectId:o,useOnCloseEvent:a||void 0,packageName:d||void 0,bundleId:c||void 0},m=Ke(i[1]||"",u);return i[0]+"?"+m}function Nn(e){let t=(e.match(/^[^:]+(?=:\/\/)/gi)||[])[0];const n=typeof t<"u"?e.split("://")[1]:e;return t=t==="wss"?"https":"http",[t,n].join("://")}function vn(e,t,n){if(!e[t]||typeof e[t]!==n)throw new Error(`Missing or invalid "${t}" param`)}function ze(e,t=de){return Ye(e.split(Fe),t)}function Sn(e){return ze(e).join(G)}function T(e,t){return e.filter(n=>t.includes(n)).length===e.length}function Ye(e,t=de){return e.slice(Math.max(e.length-t,0))}function An(e){return Object.fromEntries(e.entries())}function Rn(e){return new Map(Object.entries(e))}function Tn(e,t){const n={};return Object.keys(e).forEach(r=>{n[r]=t(e[r])}),n}const On=e=>e;function Ge(e){return e.trim().replace(/^\w/,t=>t.toUpperCase())}function In(e){return e.split(G).map(t=>Ge(t)).join(G)}function Cn(e=j.FIVE_MINUTES,t){const n=j.toMiliseconds(e||j.FIVE_MINUTES);let r,s,o,a;return{resolve:c=>{o&&r&&(clearTimeout(o),r(c),a=Promise.resolve(c))},reject:c=>{o&&s&&(clearTimeout(o),s(c))},done:()=>new Promise((c,d)=>{if(a)return c(a);o=setTimeout(()=>{const i=w("EXPIRED"),p=new Error(t||i.message);p.code=i.code,d(p)},n),r=c,s=d})}}function Un(e,t,n){return new Promise(async(r,s)=>{const o=setTimeout(()=>s(new Error(n)),t);try{const a=await e;r(a)}catch(a){s(a)}clearTimeout(o)})}function pe(e,t){if(typeof t=="string"&&t.startsWith(`${e}:`))return t;if(e.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(e.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function Pn(e){return pe("topic",e)}function $n(e){return pe("id",e)}function jn(e){const[t,n]=e.split(":"),r={id:void 0,topic:void 0};if(t==="topic"&&typeof n=="string")r.topic=n;else if(t==="id"&&Number.isInteger(Number(n)))r.id=Number(n);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${n}`);return r}function xn(e,t){return j.fromMiliseconds((t||Date.now())+j.toMiliseconds(e))}function Dn(e){return Date.now()>=j.toMiliseconds(e)}function _n(e,t){return`${e}${t?`:${t}`:""}`}function b(e=[],t=[]){return[...new Set([...e,...t])]}async function kn({id:e,topic:t,wcDeepLink:n}){try{if(!n)return;const r=(typeof n=="string"?JSON.parse(n):n)?.href;if(typeof r!="string")return;const s=Qe(r,e,t),o=U();if(o===h.browser){if(!v.getDocument()?.hasFocus()){console.warn("Document does not have focus, skipping deeplink.");return}Xe(s)}else o===h.reactNative&&typeof global?.Linking<"u"&&await global.Linking.openURL(s)}catch(r){console.error(r)}}function Qe(e,t,n){const r=`requestId=${t}&sessionTopic=${n}`;e.endsWith("/")&&(e=e.slice(0,-1));let s=`${e}`;if(e.startsWith("https://t.me")){const o=e.includes("?")?"&startapp=":"?startapp=";s=`${s}${o}${tt(r,!0)}`}else s=`${s}/wc?${r}`;return s}function Xe(e){let t="_self";et()?t="_top":(Ze()||e.startsWith("https://")||e.startsWith("http://"))&&(t="_blank"),window.open(e,t,"noreferrer noopener")}async function Vn(e,t){let n="";try{if(D()&&(n=localStorage.getItem(t),n))return n;n=await e.getItem(t)}catch(r){console.error(r)}return n}function fe(e,t){return e.filter(n=>t.includes(n))}function Mn(e,t){if(!e.includes(t))return null;const n=e.split(/([&,?,=])/),r=n.indexOf(t);return n[r+2]}function Ln(){return typeof crypto<"u"&&crypto?.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Fn(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function Ze(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function et(){try{return window.self!==window.top}catch{return!1}}function tt(e,t=!1){const n=new TextEncoder().encode(e),r=new Array(n.length);for(let o=0;o<n.length;o++)r[o]=String.fromCharCode(n[o]);const s=btoa(r.join(""));return t?s.replace(/[=]/g,""):s}function me(e){const t=e+"=".repeat((4-e.length%4)%4),n=atob(t),r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return new TextDecoder().decode(r)}function qn(e){return new Promise(t=>setTimeout(t,e))}class Kn{constructor({limit:t}){this.limit=t,this.set=new Set}add(t){if(!this.set.has(t)){if(this.set.size>=this.limit){const n=this.set.values().next().value;n&&this.set.delete(n)}this.set.add(t)}}has(t){return this.set.has(t)}}const Bn="https://rpc.walletconnect.org/v1";function _(e){const t=e+"=".repeat((4-e.length%4)%4),n=atob(t),r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return r}function he(e){const t=`Ethereum Signed Message: ${e.length}`,n=new TextEncoder().encode(t+e);return"0x"+l.toString(Zt.keccak_256(n),"base16")}async function nt(e,t,n,r,s,o){switch(n.t){case"eip191":return await rt(e,t,n.s);case"eip1271":return await st(e,t,n.s,r,s,o);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${n.t}`)}}function rt(e,t,n){const r=Ue.Signature.fromHex(n);return Ue.Secp256k1.recoverAddress({payload:he(t),signature:r}).toLowerCase()===e.toLowerCase()}async function st(e,t,n,r,s,o){const a=ie(r);if(!a.namespace||!a.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${r}`);try{const c="0x1626ba7e",d="0000000000000000000000000000000000000000000000000000000000000040",i=n.substring(2),p=(i.length/2).toString(16).padStart(64,"0"),u=(t.startsWith("0x")?t:he(t)).substring(2),m=c+u+d+p+i,E=await fetch(`${o||Bn}/?chainId=${r}&projectId=${s}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({id:Hn(),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:m},"latest"]})}),{result:f}=await E.json();return f?f.slice(0,c.length).toLowerCase()===c.toLowerCase():!1}catch(c){return console.error("isValidEip1271Signature: ",c),!1}}function Hn(){return Date.now()+Math.floor(Math.random()*1e3)}function Wn(e){const t=_(e),n=t[0];if(n===0)throw new Error("No signatures found");const r=1+n*64;if(t.length<r)throw new Error("Transaction data too short for claimed signature count");if(t.length<100)throw new Error("Transaction too short");const s=t.slice(1,65);return x.base58.encode(s)}function Jn(e){const t=_(e),n=new TextEncoder().encode("TransactionData::"),r=new Uint8Array(n.length+t.length);r.set(n),r.set(t,n.length);const s=en.blake2b(r,{dkLen:32});return x.base58.encode(s)}function zn(e){const t=new Uint8Array(oe.sha256(ot(e)));return x.base58.encode(t)}function ot(e){if(e instanceof Uint8Array)return e;if(Array.isArray(e))return new Uint8Array(e);if(typeof e=="object"&&e?.data)return new Uint8Array(Object.values(e.data));if(typeof e=="object"&&e)return new Uint8Array(Object.values(e));throw new Error("getNearUint8ArrayFromBytes: Unexpected result type from bytes array")}function Yn(e){const t=_(e),n=Pe.decode(t).txn;if(!n)throw new Error("Invalid signed transaction: missing 'txn' field");const r=Pe.encode(n),s=new TextEncoder().encode("TX"),o=l.concat([s,new Uint8Array(r)]),a=oe.sha512_256(o);return x.base32.encode(a).replace(/=+$/,"")}function ge(e){const t=[];let n=BigInt(e);for(;n>=0x80n;)t.push(Number(n&0x7fn|0x80n)),n>>=7n;return t.push(Number(n)),new Uint8Array(t)}function Gn(e){const t=_(e.signed.bodyBytes),n=_(e.signed.authInfoBytes),r=_(e.signature.signature),s=[];s.push(new Uint8Array([10])),s.push(ge(t.length)),s.push(t),s.push(new Uint8Array([18])),s.push(ge(n.length)),s.push(n),s.push(new Uint8Array([26])),s.push(ge(r.length)),s.push(r);const o=l.concat(s),a=oe.sha256(o);return l.toString(a,"base16").toUpperCase()}function Qn(e){const t=[];try{if(typeof e=="string")return t.push(e),t;if(typeof e!="object")return t;e?.id&&t.push(e.id);const n=e?.capabilities?.caip345?.transactionHashes;n&&t.push(...n)}catch(n){console.warn("getWalletSendCallsHashes failed: ",n)}return t}const at="did:pkh:",Xn={eip155:"Ethereum",solana:"Solana",bip122:"Bitcoin"},Zn=e=>e?Xn[e]||e:"",L=e=>e?.split(":"),it=e=>{const t=e&&L(e);if(t)return e.includes(at)?t[3]:t[1]},ct=e=>{const t=e&&L(e);if(t)return e.includes(at)?t[2]:t[0]},ut=e=>{const t=e&&L(e);if(t)return t[2]+":"+t[3]},ye=e=>{const t=e&&L(e);if(t)return t.pop()};async function er(e){const{cacao:t,projectId:n}=e,{s:r,p:s}=t,o=dt(s,s.iss),a=ye(s.iss);return await nt(a,o,r,ut(s.iss),n)}const dt=(e,t)=>{const n=ct(t);if(!n)throw new Error("Invalid issuer: "+t);const r=`${e.domain} wants you to sign in with your ${Zn(n)} account:`,s=ye(t);if(!e.aud&&!e.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let o=e.statement||void 0;const a=`URI: ${e.aud||e.uri}`,c=`Version: ${e.version}`,d=`Chain ID: ${it(t)}`,i=`Nonce: ${e.nonce}`,p=`Issued At: ${e.iat}`,u=e.exp?`Expiration Time: ${e.exp}`:void 0,m=e.nbf?`Not Before: ${e.nbf}`:void 0,E=e.requestId?`Request ID: ${e.requestId}`:void 0,f=e.resources?`Resources:${e.resources.map(M=>` - ${M}`).join("")}`:void 0,A=X(e.resources);if(A){const M=O(A);o=we(o,M)}return[r,s,"",o,"",a,c,d,i,p,u,m,E,f].filter(M=>M!=null).join(` `)};function tr(e,t,n){return n.includes("did:pkh:")||(n=`did:pkh:${n}`),{h:{t:"caip122"},p:{iss:n,domain:e.domain,aud:e.aud,version:e.version,nonce:e.nonce,iat:e.iat,statement:e.statement,requestId:e.requestId,resources:e.resources,nbf:e.nbf,exp:e.exp},s:t}}function nr(e){const{authPayload:t,chains:n,methods:r}=e,s=t.statement||"";if(!n?.length)return t;const o=t.chains,a=fe(o,n);if(!a?.length)throw new Error("No supported chains");const c=lt(t.resources);if(!c)return t;N(c);const d=pt(c,"eip155");let i=t?.resources||[];if(d?.length){const p=ft(d),u=fe(p,r);if(!u?.length)throw new Error(`Supported methods don't satisfy the requested: ${JSON.stringify(p)}, supported: ${JSON.stringify(r)}`);const m=Ee("request",u,{chains:a}),E=yt(c,"eip155",m);i=t?.resources?.slice(0,-1)||[],i.push(Q(E))}return{...t,statement:bt(s,X(i)),chains:a,resources:t?.resources||i.length>0?i:void 0}}function lt(e){const t=X(e);if(t&&be(t))return O(t)}function rr(e,t){return e?.att?.hasOwnProperty(t)}function pt(e,t){return e?.att?.[t]?Object.keys(e?.att?.[t]):[]}function sr(e){return e?.map(t=>Object.keys(t))||[]}function ft(e){return e?.map(t=>t.split("/")?.[1])||[]}function mt(e){const t=JSON.stringify(e),n=new TextEncoder().encode(t),r=new Array(n.length);for(let s=0;s<n.length;s++)r[s]=String.fromCharCode(n[s]);return btoa(r.join(""))}function ht(e){const t=e+"=".repeat((4-e.length%4)%4),n=atob(t),r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return JSON.parse(new TextDecoder().decode(r))}function N(e){if(!e)throw new Error("No recap provided, value is undefined");if(!e.att)throw new Error("No `att` property found");const t=Object.keys(e.att);if(!t?.length)throw new Error("No resources found in `att` property");t.forEach(n=>{const r=e.att[n];if(Array.isArray(r))throw new Error(`Resource must be an object: ${n}`);if(typeof r!="object")throw new Error(`Resource must be an object: ${n}`);if(!Object.keys(r).length)throw new Error(`Resource object is empty: ${n}`);Object.keys(r).forEach(s=>{const o=r[s];if(!Array.isArray(o))throw new Error(`Ability limits ${s} must be an array of objects, found: ${o}`);if(!o.length)throw new Error(`Value of ${s} is empty array, must be an array with objects`);o.forEach(a=>{if(typeof a!="object")throw new Error(`Ability limits (${s}) must be an array of objects, found: ${a}`)})})})}function gt(e,t,n,r={}){return n?.sort((s,o)=>s.localeCompare(o)),{att:{[e]:Ee(t,n,r)}}}function yt(e,t,n){e.att[t]={...n};const r=Object.keys(e.att)?.sort((o,a)=>o.localeCompare(a)),s={att:{}};return r.reduce((o,a)=>(o.att[a]=e.att[a],o),s)}function Ee(e,t,n={}){t=t?.sort((s,o)=>s.localeCompare(o));const r=t.map(s=>({[`${e}/${s}`]:[n]}));return Object.assign({},...r)}function Q(e){return N(e),`urn:recap:${mt(e).replace(/=/g,"")}`}function O(e){const t=ht(e.replace("urn:recap:",""));return N(t),t}function or(e,t,n){const r=gt(e,t,n);return Q(r)}function be(e){return e&&e.includes("urn:recap:")}function ar(e,t){const n=O(e),r=O(t),s=Et(n,r);return Q(s)}function Et(e,t){N(e),N(t);const n=Object.keys(e.att).concat(Object.keys(t.att)).sort((s,o)=>s.localeCompare(o)),r={att:{}};return n.forEach(s=>{Object.keys(e.att?.[s]||{}).concat(Object.keys(t.att?.[s]||{})).sort((o,a)=>o.localeCompare(a)).forEach(o=>{r.att[s]={...r.att[s],[o]:e.att[s]?.[o]||t.att[s]?.[o]}})}),r}function we(e="",t){N(t);const n="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(n))return e;const r=[];let s=0;Object.keys(t.att).forEach(c=>{const d=Object.keys(t.att[c]).map(u=>({ability:u.split("/")[0],action:u.split("/")[1]}));d.sort((u,m)=>u.action.localeCompare(m.action));const i={};d.forEach(u=>{i[u.ability]||(i[u.ability]=[]),i[u.ability].push(u.action)});const p=Object.keys(i).map(u=>(s++,`(${s}) '${u}': '${i[u].join("', '")}' for '${c}'.`));r.push(p.join(", ").replace(".,","."))});const o=r.join(" "),a=`${n}${o}`;return`${e?e+" ":""}${a}`}function ir(e){const t=O(e);N(t);const n=t.att?.eip155;return n?Object.keys(n).map(r=>r.split("/")[1]):[]}function cr(e){const t=O(e);N(t);const n=[];return Object.values(t.att).forEach(r=>{Object.values(r).forEach(s=>{s?.[0]?.chains&&n.push(s[0].chains)})}),[...new Set(n.flat())]}function bt(e,t){if(!t)return e;const n=O(t);return N(n),we(e,n)}function X(e){if(!e)return;const t=e?.[e.length-1];return be(t)?t:void 0}const Ne="base10",g="base16",S="base64pad",Z="base64url",k="utf8",ve=0,V=1,F=2,ur=0,wt=1,q=12,Se=32;function dr(){const e=ae.x25519.utils.randomPrivateKey(),t=ae.x25519.getPublicKey(e);return{privateKey:l.toString(e,g),publicKey:l.toString(t,g)}}function lr(){const e=W.randomBytes(Se);return l.toString(e,g)}function pr(e,t){const n=ae.x25519.getSharedSecret(l.fromString(e,g),l.fromString(t,g)),r=tn.hkdf(J.sha256,n,void 0,void 0,Se);return l.toString(r,g)}function fr(e){const t=J.sha256(l.fromString(e,g));return l.toString(t,g)}function mr(e){const t=J.sha256(l.fromString(e,k));return l.toString(t,g)}function Ae(e){return l.fromString(`${e}`,Ne)}function P(e){return Number(l.toString(e,Ne))}function Nt(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ee(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4;return t+"=".repeat(n)}function hr(e){const t=Ae(typeof e.type<"u"?e.type:ve);if(P(t)===V&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const n=typeof e.senderPublicKey<"u"?l.fromString(e.senderPublicKey,g):void 0,r=typeof e.iv<"u"?l.fromString(e.iv,g):W.randomBytes(q),s=l.fromString(e.symKey,g),o=$e.chacha20poly1305(s,r).encrypt(l.fromString(e.message,k)),a=Re({type:t,sealed:o,iv:r,senderPublicKey:n});return e.encoding===Z?Nt(a):a}function gr(e){const t=l.fromString(e.symKey,g),{sealed:n,iv:r}=te({encoded:e.encoded,encoding:e.encoding}),s=$e.chacha20poly1305(t,r).decrypt(n);if(s===null)throw new Error("Failed to decrypt");return l.toString(s,k)}function yr(e,t){const n=Ae(F),r=W.randomBytes(q),s=l.fromString(e,k),o=Re({type:n,sealed:s,iv:r});return t===Z?Nt(o):o}function Er(e,t){const{sealed:n}=te({encoded:e,encoding:t});return l.toString(n,k)}function Re(e){if(P(e.type)===F)return l.toString(l.concat([e.type,e.sealed]),S);if(P(e.type)===V){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return l.toString(l.concat([e.type,e.senderPublicKey,e.iv,e.sealed]),S)}return l.toString(l.concat([e.type,e.iv,e.sealed]),S)}function te(e){const t=(e.encoding||S)===Z?ee(e.encoded):e.encoded,n=l.fromString(t,S),r=n.slice(ur,wt),s=wt;if(P(r)===V){const d=s+Se,i=d+q,p=n.slice(s,d),u=n.slice(d,i),m=n.slice(i);return{type:r,sealed:m,iv:u,senderPublicKey:p}}if(P(r)===F){const d=n.slice(s),i=W.randomBytes(q);return{type:r,sealed:d,iv:i}}const o=s+q,a=n.slice(s,o),c=n.slice(o);return{type:r,sealed:c,iv:a}}function br(e,t){const n=te({encoded:e,encoding:t?.encoding});return vt({type:P(n.type),senderPublicKey:typeof n.senderPublicKey<"u"?l.toString(n.senderPublicKey,g):void 0,receiverPublicKey:t?.receiverPublicKey})}function vt(e){const t=e?.type||ve;if(t===V){if(typeof e?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function wr(e){return e.type===V&&typeof e.senderPublicKey=="string"&&typeof e.receiverPublicKey=="string"}function Nr(e){return e.type===F}function St(e){const t=l.fromString(ee(e.x),S),n=l.fromString(ee(e.y),S);return l.concat([new Uint8Array([4]),t,n])}function vr(e,t){const[n,r,s]=e.split("."),o=l.fromString(ee(s),S);if(o.length!==64)throw new Error("Invalid signature length");const a=o.slice(0,32),c=o.slice(32,64),d=`${n}.${r}`,i=J.sha256(d),p=St(t);if(!nn.p256.verify(l.concat([a,c]),i,p))throw new Error("Invalid signature");return rn.decodeJWT(e).payload}const At="irn";function Sr(e){return e?.relay||{protocol:At}}function Ar(e){const t=sn.RELAY_JSONRPC[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}function Rt(e,t="-"){const n={},r="relay"+t;return Object.keys(e).forEach(s=>{if(s.startsWith(r)){const o=s.replace(r,""),a=e[s];n[o]=a}}),n}function Rr(e){if(!e.includes("wc:")){const i=me(e);i?.includes("wc:")&&(e=i)}e=e.includes("wc://")?e.replace("wc://",""):e,e=e.includes("wc:")?e.replace("wc:",""):e;const t=e.indexOf(":"),n=e.indexOf("?")!==-1?e.indexOf("?"):void 0,r=e.substring(0,t),s=e.substring(t+1,n).split("@"),o=typeof n<"u"?e.substring(n):"",a=new URLSearchParams(o),c=Object.fromEntries(a.entries()),d=typeof c.methods=="string"?c.methods.split(","):void 0;return{protocol:r,topic:Tt(s[0]),version:parseInt(s[1],10),symKey:c.symKey,relay:Rt(c),methods:d,expiryTimestamp:c.expiryTimestamp?parseInt(c.expiryTimestamp,10):void 0}}function Tt(e){return e.startsWith("//")?e.substring(2):e}function Ot(e,t="-"){const n="relay",r={};return Object.keys(e).forEach(s=>{const o=s,a=n+t+o;e[o]&&(r[a]=e[o])}),r}function Tr(e){const t=new URLSearchParams,n={...Ot(e.relay),symKey:e.symKey,...e.expiryTimestamp&&{expiryTimestamp:e.expiryTimestamp.toString()},...e.methods&&{methods:e.methods.join(",")}};return Object.entries(n).sort(([r],[s])=>r.localeCompare(s)).forEach(([r,s])=>{s!==void 0&&t.append(r,String(s))}),`${e.protocol}:${e.topic}@${e.version}?${t}`}function Or(e,t,n){return`${e}?wc_ev=${n}&topic=${t}`}function $(e){const t=[];return e.forEach(n=>{const[r,s]=n.split(":");t.push(`${r}:${s}`)}),t}function It(e){const t=[];return Object.values(e).forEach(n=>{t.push(...$(n.accounts))}),[...new Set(t)]}function Ir(e){const t=[];return Object.values(e).forEach(n=>{t.push(...n.methods)}),[...new Set(t)]}function Cr(e){const t=[];return Object.values(e).forEach(n=>{t.push(...n.events)}),[...new Set(t)]}function Ct(e,t){const n=[];return Object.values(e).forEach(r=>{$(r.accounts).includes(t)&&n.push(...r.methods)}),n}function Ut(e,t){const n=[];return Object.values(e).forEach(r=>{$(r.accounts).includes(t)&&n.push(...r.events)}),n}function Ur(e,t){const n=Mt(e,t);if(n)throw new Error(n.message);const r={};for(const[s,o]of Object.entries(e))r[s]={methods:o.methods,events:o.events,chains:o.accounts.map(a=>`${a.split(":")[0]}:${a.split(":")[1]}`)};return r}function Pr(e){const{proposal:{requiredNamespaces:t,optionalNamespaces:n={}},supportedNamespaces:r}=e,s=K(t),o=K(n),a={};Object.keys(r).forEach(i=>{const p=r[i].chains,u=r[i].methods,m=r[i].events,E=r[i].accounts;p.forEach(f=>{if(!E.some(A=>A.includes(f)))throw new Error(`No accounts provided for chain ${f} in namespace ${i}`)}),a[i]={chains:p,methods:u,events:m,accounts:E}});const c=Ft(t,a,"approve()");if(c)throw new Error(c.message);const d={};if(!Object.keys(t).length&&!Object.keys(n).length)return a;Object.keys(s).forEach(i=>{const p=r[i].chains.filter(f=>s[i]?.chains?.includes(f)),u=r[i].methods.filter(f=>s[i]?.methods?.includes(f)),m=r[i].events.filter(f=>s[i]?.events?.includes(f)),E=p.map(f=>r[i].accounts.filter(A=>A.includes(`${f}:`))).flat();d[i]={chains:p,methods:u,events:m,accounts:E}}),Object.keys(o).forEach(i=>{if(!r[i])return;const p=o[i]?.chains?.filter(f=>r[i].chains.includes(f)),u=r[i].methods.filter(f=>o[i]?.methods?.includes(f)),m=r[i].events.filter(f=>o[i]?.events?.includes(f)),E=p?.map(f=>r[i].accounts.filter(A=>A.includes(`${f}:`))).flat();d[i]={chains:b(d[i]?.chains,p),methods:b(d[i]?.methods,u),events:b(d[i]?.events,m),accounts:b(d[i]?.accounts,E)}});for(const[i,p]of Object.entries(d))(p.accounts.length===0||p?.chains?.length===0)&&delete d[i];return d}function Te(e){return e.includes(":")}function Pt(e){return Te(e)?e.split(":")[0]:e}function K(e){const t={};if(!ne(e))return t;for(const[n,r]of Object.entries(e)){const s=Te(n)?[n]:r.chains,o=r.methods||[],a=r.events||[],c=Pt(n);t[c]={...t[c],chains:b(s,t[c]?.chains),methods:b(o,t[c]?.methods),events:b(a,t[c]?.events)}}return t}function $t(e){const t={};return e?.forEach(n=>{const[r,s]=n.split(":");t[r]||(t[r]={accounts:[],chains:[],events:[],methods:[]}),t[r].accounts.push(n),t[r].chains?.push(`${r}:${s}`)}),t}function $r(e,t){t=t.map(r=>r.replace("did:pkh:",""));const n=$t(t);for(const[r,s]of Object.entries(n))s.methods?s.methods=b(s.methods,e):s.methods=e,s.events=["chainChanged","accountsChanged"];return n}function jr(e,t){const n=K(e),r=K(t),s={},o=Object.keys(n).concat(Object.keys(r));for(const a of o)s[a]={chains:b(n[a]?.chains,r[a]?.chains),methods:b(n[a]?.methods,r[a]?.methods),events:b(n[a]?.events,r[a]?.events)};return s}function B(e,t){return Array.isArray(e)?typeof t<"u"&&e.length?e.every(t):!0:!1}function ne(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function I(e){return typeof e>"u"}function y(e,t){return t&&I(e)?!0:typeof e=="string"&&!!e.trim().length}function re(e,t){return t&&I(e)?!0:typeof e=="number"&&!isNaN(e)}function xr(e,t){const{requiredNamespaces:n}=t,r=Object.keys(e.namespaces),s=Object.keys(n);let o=!0;return T(s,r)?(r.forEach(a=>{const{accounts:c,methods:d,events:i}=e.namespaces[a],p=$(c),u=n[a];(!T(Y(a,u),p)||!T(u.methods,d)||!T(u.events,i))&&(o=!1)}),o):!1}function H(e){return y(e,!1)&&e.includes(":")?e.split(":").length===2:!1}function jt(e){if(y(e,!1)&&e.includes(":")){const t=e.split(":");if(t.length===3){const n=t[0]+":"+t[1];return!!t[2]&&H(n)}}return!1}function Dr(e){function t(n){try{return typeof new URL(n)<"u"}catch{return!1}}try{if(y(e,!1)){if(t(e))return!0;const n=me(e);return t(n)}}catch{}return!1}function _r(e){return e?.proposer?.publicKey}function kr(e){return e?.topic}function Vr(e,t){let n=null;return y(e?.publicKey,!1)||(n=w("MISSING_OR_INVALID",`${t} controller public key should be a string`)),n}function Oe(e){let t=!0;return B(e)?e.length&&(t=e.every(n=>y(n,!1))):t=!1,t}function xt(e,t,n){let r=null;return B(t)&&t.length?t.forEach(s=>{r||H(s)||(r=C("UNSUPPORTED_CHAINS",`${n}, chain ${s} should be a string and conform to "namespace:chainId" format`))}):H(e)||(r=C("UNSUPPORTED_CHAINS",`${n}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),r}function Dt(e,t,n){let r=null;return Object.entries(e).forEach(([s,o])=>{if(r)return;const a=xt(s,Y(s,o),`${t} ${n}`);a&&(r=a)}),r}function _t(e,t){let n=null;return B(e)?e.forEach(r=>{n||jt(r)||(n=C("UNSUPPORTED_ACCOUNTS",`${t}, account ${r} should be a string and conform to "namespace:chainId:address" format`))}):n=C("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),n}function kt(e,t){let n=null;return Object.values(e).forEach(r=>{if(n)return;const s=_t(r?.accounts,`${t} namespace`);s&&(n=s)}),n}function Vt(e,t){let n=null;return Oe(e?.methods)?Oe(e?.events)||(n=C("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):n=C("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),n}function Ie(e,t){let n=null;return Object.values(e).forEach(r=>{if(n)return;const s=Vt(r,`${t}, namespace`);s&&(n=s)}),n}function Mr(e,t,n){let r=null;if(e&&ne(e)){const s=Ie(e,t);s&&(r=s);const o=Dt(e,t,n);o&&(r=o)}else r=w("MISSING_OR_INVALID",`${t}, ${n} should be an object with data`);return r}function Mt(e,t){let n=null;if(e&&ne(e)){const r=Ie(e,t);r&&(n=r);const s=kt(e,t);s&&(n=s)}else n=w("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return n}function Lt(e){return y(e.protocol,!0)}function Lr(e,t){let n=!1;return t&&!e?n=!0:e&&B(e)&&e.length&&e.forEach(r=>{n=Lt(r)}),n}function Fr(e){return typeof e=="number"}function qr(e){return typeof e<"u"&&typeof e!==null}function Kr(e){return!(!e||typeof e!="object"||!e.code||!re(e.code,!1)||!e.message||!y(e.message,!1))}function Br(e){return!(I(e)||!y(e.method,!1))}function Hr(e){return!(I(e)||I(e.result)&&I(e.error)||!re(e.id,!1)||!y(e.jsonrpc,!1))}function Wr(e){return!(I(e)||!y(e.name,!1))}function Jr(e,t){return!(!H(t)||!It(e).includes(t))}function zr(e,t,n){return y(n,!1)?Ct(e,t).includes(n):!1}function Yr(e,t,n){return y(n,!1)?Ut(e,t).includes(n):!1}function Ft(e,t,n){let r=null;const s=Gr(e),o=Qr(t),a=Object.keys(s),c=Object.keys(o),d=qt(Object.keys(e)),i=qt(Object.keys(t)),p=d.filter(u=>!i.includes(u));return p.length&&(r=w("NON_CONFORMING_NAMESPACES",`${n} namespaces keys don't satisfy requiredNamespaces. Required: ${p.toString()} Received: ${Object.keys(t).toString()}`)),T(a,c)||(r=w("NON_CONFORMING_NAMESPACES",`${n} namespaces chains don't satisfy required namespaces. Required: ${a.toString()} Approved: ${c.toString()}`)),Object.keys(t).forEach(u=>{if(!u.includes(":")||r)return;const m=$(t[u].accounts);m.includes(u)||(r=w("NON_CONFORMING_NAMESPACES",`${n} namespaces accounts don't satisfy namespace accounts for ${u} Required: ${u} Approved: ${m.toString()}`))}),a.forEach(u=>{r||(T(s[u].methods,o[u].methods)?T(s[u].events,o[u].events)||(r=w("NON_CONFORMING_NAMESPACES",`${n} namespaces events don't satisfy namespace events for ${u}`)):r=w("NON_CONFORMING_NAMESPACES",`${n} namespaces methods don't satisfy namespace methods for ${u}`))}),r}function Gr(e){const t={};return Object.keys(e).forEach(n=>{n.includes(":")?t[n]=e[n]:e[n].chains?.forEach(r=>{t[r]={methods:e[n].methods,events:e[n].events}})}),t}function qt(e){return[...new Set(e.map(t=>t.includes(":")?t.split(":")[0]:t))]}function Qr(e){const t={};return Object.keys(e).forEach(n=>{n.includes(":")?t[n]=e[n]:$(e[n].accounts)?.forEach(r=>{t[r]={accounts:e[n].accounts.filter(s=>s.includes(`${r}:`)),methods:e[n].methods,events:e[n].events}})}),t}function Xr(e,t){return re(e,!1)&&e<=t.max&&e>=t.min}function Zr(){const e=U();return new Promise(t=>{switch(e){case h.browser:t(Kt());break;case h.reactNative:t(Bt());break;case h.node:t(Ht());break;default:t(!0)}})}function Kt(){return D()&&navigator?.onLine}async function Bt(){return R()&&typeof global<"u"&&global?.NetInfo?(await global?.NetInfo.fetch())?.isConnected:!0}function Ht(){return!0}function es(e){switch(U()){case h.browser:Wt(e);break;case h.reactNative:Jt(e);break;case h.node:break}}function Wt(e){!R()&&D()&&(window.addEventListener("online",()=>e(!0)),window.addEventListener("offline",()=>e(!1)))}function Jt(e){R()&&typeof global<"u"&&global?.NetInfo&&global?.NetInfo.addEventListener(t=>e(t?.isConnected))}function ts(){return D()&&v.getDocument()?v.getDocument()?.visibilityState==="visible":!0}const Ce={};class ns{static get(t){return Ce[t]}static set(t,n){Ce[t]=n}static delete(t){delete Ce[t]}}function zt(e){const t=x.base58.decode(e);if(t.length<33)throw new Error("Too short to contain a public key");return t.slice(1,33)}function Yt({publicKey:e,signature:t,payload:n}){const r=se(n.method),s=128|parseInt(n.version?.toString()||"4"),o=ss(n.address),a=n.era==="00"?new Uint8Array([0]):se(n.era);if(a.length!==1&&a.length!==2)throw new Error("Invalid era length");const c=parseInt(n.nonce,16),d=new Uint8Array([c&255,c>>8&255]),i=BigInt(`0x${rs(n.tip)}`),p=as(i),u=new Uint8Array([0,...e,o,...t,...a,...d,...p,...r]),m=os(u.length+1);return new Uint8Array([...m,s,...u])}function Gt(e){const t=se(e),n=on.blake2b(t,void 0,32);return"0x"+l.toString(n,"base16")}function se(e){return new Uint8Array(e.replace(/^0x/,"").match(/.{1,2}/g).map(t=>parseInt(t,16)))}function rs(e){return e.startsWith("0x")?e.slice(2):e}function ss(e){const t=x.base58.decode(e)[0];return t===42?0:t===60?2:1}function os(e){if(e<64)return new Uint8Array([e<<2]);if(e<16384){const t=e<<2|1;return new Uint8Array([t&255,t>>8&255])}else if(e<1<<30){const t=e<<2|2;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}else throw new Error("Compact encoding > 2^30 not supported")}function as(e){if(e<1n<<6n)return new Uint8Array([Number(e<<2n)]);if(e<1n<<14n){const t=e<<2n|0x01n;return new Uint8Array([Number(t&0xffn),Number(t>>8n&0xffn)])}else if(e<1n<<30n){const t=e<<2n|0x02n;return new Uint8Array([Number(t&0xffn),Number(t>>8n&0xffn),Number(t>>16n&0xffn),Number(t>>24n&0xffn)])}else throw new Error("BigInt compact encoding not supported > 2^30")}function is(e){const t=se(e.signature),n=zt(e.transaction.address),r=Yt({publicKey:n,signature:t,payload:e.transaction}),s=l.toString(r,"base16");return Gt(s)}function cs({logger:e,name:t}){const n=typeof e=="string"?an.generatePlatformLogger({opts:{level:e,name:t}}).logger:e;return n.level=typeof e=="string"?e:e.level,n}exports.BASE10=Ne,exports.BASE16=g,exports.BASE64=S,exports.BASE64URL=Z,exports.COLON=fn,exports.DEFAULT_DEPTH=de,exports.EMPTY_SPACE=G,exports.ENV_MAP=h,exports.INTERNAL_ERRORS=Me,exports.LimitedSet=Kn,exports.MemoryStore=ns,exports.ONE_THOUSAND=mn,exports.REACT_NATIVE_PRODUCT=Le,exports.RELAYER_DEFAULT_PROTOCOL=At,exports.SDK_ERRORS=Ve,exports.SDK_TYPE=qe,exports.SLASH=Fe,exports.TYPE_0=ve,exports.TYPE_1=V,exports.TYPE_2=F,exports.UTF8=k,exports.addResourceToRecap=yt,exports.addSignatureToExtrinsic=Yt,exports.appendToQueryString=Ke,exports.assertType=vn,exports.assignAbilityToActions=Ee,exports.base64Decode=ht,exports.base64Encode=mt,exports.buildApprovedNamespaces=Pr,exports.buildAuthObject=tr,exports.buildNamespacesFromAuth=$r,exports.buildRecapStatement=bt,exports.buildSignedExtrinsicHash=is,exports.calcExpiry=xn,exports.capitalize=In,exports.capitalizeWord=Ge,exports.createDelayedPromise=Cn,exports.createEncodedRecap=or,exports.createExpiringPromise=Un,exports.createLogger=cs,exports.createRecap=gt,exports.decodeRecap=O,exports.decodeTypeByte=P,exports.decodeTypeTwoEnvelope=Er,exports.decrypt=gr,exports.deriveExtrinsicHash=Gt,exports.deriveSymKey=pr,exports.deserialize=te,exports.encodeRecap=Q,exports.encodeTypeByte=Ae,exports.encodeTypeTwoEnvelope=yr,exports.encrypt=hr,exports.engineEvent=_n,exports.enumify=On,exports.extractSolanaTransactionId=Wn,exports.formatAccountId=xe,exports.formatAccountWithChain=cn,exports.formatChainId=je,exports.formatDeeplinkUrl=Qe,exports.formatExpirerTarget=pe,exports.formatIdTarget=$n,exports.formatMessage=dt,exports.formatMessageContext=Sn,exports.formatRelayParams=Ot,exports.formatRelayRpcUrl=wn,exports.formatStatementFromRecap=we,exports.formatTopicTarget=Pn,exports.formatUA=Je,exports.formatUri=Tr,exports.fromBase64=me,exports.generateKeyPair=dr,exports.generateRandomBytes32=lr,exports.getAccountsChains=$,exports.getAccountsFromNamespaces=dn,exports.getAddressFromAccount=De,exports.getAddressesFromAccounts=un,exports.getAlgorandTransactionId=Yn,exports.getAppId=yn,exports.getAppMetadata=Be,exports.getBrowserOnlineStatus=Kt,exports.getChainFromAccount=_e,exports.getChainsFromAccounts=ke,exports.getChainsFromNamespace=Y,exports.getChainsFromNamespaces=ln,exports.getChainsFromRecap=cr,exports.getChainsFromRequiredNamespaces=pn,exports.getCommonValuesInArrays=fe,exports.getCryptoKeyFromKeyData=St,exports.getDecodedRecapFromResources=lt,exports.getDeepLink=Vn,exports.getDidAddress=ye,exports.getDidAddressNamespace=ct,exports.getDidAddressSegments=L,exports.getDidChainId=it,exports.getEnvironment=U,exports.getHttpUrl=Nn,exports.getInternalError=w,exports.getJavascriptID=We,exports.getJavascriptOS=He,exports.getLastItems=Ye,exports.getLinkModeURL=Or,exports.getMethodsFromRecap=ir,exports.getNamespacedDidChainId=ut,exports.getNamespacesChains=It,exports.getNamespacesEvents=Cr,exports.getNamespacesEventsForChainId=Ut,exports.getNamespacesFromAccounts=$t,exports.getNamespacesMethods=Ir,exports.getNamespacesMethodsForChainId=Ct,exports.getNearTransactionIdFromSignedTransaction=zn,exports.getNearUint8ArrayFromBytes=ot,exports.getNodeOnlineStatus=Ht,exports.getReCapActions=ft,exports.getReactNativeOnlineStatus=Bt,exports.getRecapAbilitiesFromResource=sr,exports.getRecapFromResources=X,exports.getRecapResource=pt,exports.getRelayClientMetadata=bn,exports.getRelayProtocolApi=Ar,exports.getRelayProtocolName=Sr,exports.getRequiredNamespacesFromNamespaces=Ur,exports.getSdkError=C,exports.getSearchParamFromURL=Mn,exports.getSignDirectHash=Gn,exports.getSuiDigest=Jn,exports.getUniqueValues=ue,exports.getWalletSendCallsHashes=Qn,exports.handleDeeplinkRedirect=kn,exports.hasOverlap=T,exports.hashEthereumMessage=he,exports.hashKey=fr,exports.hashMessage=mr,exports.isAndroid=hn,exports.isAppVisible=ts,exports.isBrowser=D,exports.isCaipNamespace=Te,exports.isConformingNamespaces=Ft,exports.isExpired=Dn,exports.isIframe=et,exports.isIos=gn,exports.isNode=le,exports.isOnline=Zr,exports.isProposalStruct=_r,exports.isReactNative=R,exports.isRecap=be,exports.isSessionCompatible=xr,exports.isSessionStruct=kr,exports.isTelegram=Ze,exports.isTestRun=Fn,exports.isTypeOneEnvelope=wr,exports.isTypeTwoEnvelope=Nr,exports.isUndefined=I,exports.isValidAccountId=jt,exports.isValidAccounts=_t,exports.isValidActions=Vt,exports.isValidArray=B,exports.isValidChainId=H,exports.isValidChains=xt,exports.isValidController=Vr,exports.isValidEip1271Signature=st,exports.isValidEip191Signature=rt,exports.isValidErrorReason=Kr,exports.isValidEvent=Wr,exports.isValidId=Fr,exports.isValidNamespaceAccounts=kt,exports.isValidNamespaceActions=Ie,exports.isValidNamespaceChains=Dt,exports.isValidNamespaceMethodsOrEvents=Oe,exports.isValidNamespaces=Mt,exports.isValidNamespacesChainId=Jr,exports.isValidNamespacesEvent=Yr,exports.isValidNamespacesRequest=zr,exports.isValidNumber=re,exports.isValidObject=ne,exports.isValidParams=qr,exports.isValidRecap=N,exports.isValidRelay=Lt,exports.isValidRelays=Lr,exports.isValidRequest=Br,exports.isValidRequestExpiry=Xr,exports.isValidRequiredNamespaces=Mr,exports.isValidResponse=Hr,exports.isValidString=y,exports.isValidUrl=Dr,exports.mapEntries=Tn,exports.mapToObj=An,exports.mergeArrays=b,exports.mergeEncodedRecaps=ar,exports.mergeRecaps=Et,exports.mergeRequiredAndOptionalNamespaces=jr,exports.normalizeNamespaces=K,exports.objToMap=Rn,exports.openDeeplink=Xe,exports.parseAccountId=ce,exports.parseChainId=ie,exports.parseContextNames=ze,exports.parseExpirerTarget=jn,exports.parseNamespaceKey=Pt,exports.parseRelayParams=Rt,exports.parseTopic=Tt,exports.parseUri=Rr,exports.populateAppMetadata=En,exports.populateAuthPayload=nr,exports.recapHasResource=rr,exports.serialize=Re,exports.sleep=qn,exports.ss58AddressToPublicKey=zt,exports.subscribeToBrowserNetworkChange=Wt,exports.subscribeToNetworkChange=es,exports.subscribeToReactNativeNetworkChange=Jt,exports.toBase64=tt,exports.uuidv4=Ln,exports.validateDecoding=br,exports.validateEncoding=vt,exports.validateSignedCacao=er,exports.verifyP256Jwt=vr,exports.verifySignature=nt; //# sourceMappingURL=index.cjs.map