@onflow/fcl
Advanced tools
Comparing version 0.0.79-alpha.3 to 0.0.79-alpha.4
@@ -1,2 +0,2 @@ | ||
var e=require("@onflow/sdk"),n=require("@onflow/util-invariant"),r=require("@onflow/types"),t=require("@onflow/util-actor"),o=require("@onflow/util-address"),i=require("@onflow/rlp"),a=require("@onflow/util-uid"),s=require("@onflow/util-template");function u(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),n.default=e,n}var c=u(e),l=u(r),d=u(i),f="0.0.79-alpha.3",p=function(n){try{return Promise.resolve(e.config().where(n)).then(function(e){return Object.fromEntries(Object.entries(e).map(function(e){var r=e[1];return[e[0].replace(n,""),r]}))})}catch(e){return Promise.reject(e)}},h={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};e.config({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":h});var v=function(e){return function(n){return typeof n===e}},m=function(e){return null!=e},g=v("object"),y=v("string"),P=v("function"),E=v("number");function b(e){return P(e)?e(c.arg,l):[]}var w=function(e){return void 0===e&&(e={}),Promise.resolve(function(e){try{return n.invariant(m(e.cadence),"query({ cadence }) -- cadence is required"),n.invariant(y(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(c.config.get("accessNode.api")).then(function(e){n.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return c.send([c.script(e.cadence),c.args(b(e.args||[])),e.limit&&"number"==typeof e.limit&&c.limit(e.limit)]).then(c.decode)})};function S(){return S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},S.apply(this,arguments)}function R(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function x(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return R(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?R(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var I={f_type:"Service",f_vsn:"1.0.0"},C={f_type:"Identity",f_vsn:"1.0.0"},A={f_type:"USER",f_vsn:"1.0.0"},O={f_type:"PollingResponse",f_vsn:"1.0.0"},j={f_type:"CompositeSignature",f_vsn:"1.0.0"};function D(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({old:e},I,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function N(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},I,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function k(e){return null==e?null:(null==e.method&&(e=S({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:S({},I,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var L={"back-channel-rpc":N,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},I,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},C,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},I,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},C,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},I,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:o.withPrefix(e.addr),name:e.name,icon:e.icon}})},frame:D,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":k,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function T(e){return d.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var F=function(e){try{var n=(e=function(e){return e.addr=e.addr?o.withPrefix(e.addr):null,e.paddr=e.paddr?o.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var r=new URL(e);return r.searchParams.append("code",n),Promise.resolve(fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var r,t=x(e.authorizations);!(r=t()).done;)n.push(S({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&n.push(S({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(r){var t,i,a=(t=n,i=r,void 0===t&&(t=[]),void 0===i&&(i=[]),[].concat(t,i)).map(function(n){return function(e,n){try{return L[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,a);return S({},A,{addr:o.withPrefix(e.addr),cid:T(s),loggedIn:!0,services:a,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function _(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function U(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var r=0,t=Object.entries(e.params||{});r<t.length;r++){var o=t[r];n.searchParams.append(o[0],o[1])}return n}function B(e,n){void 0===n&&(n={});var r=n.method||"POST",t="GET"===r?void 0:JSON.stringify(n.data||e.data||{});return fetch(U(e),{method:r,headers:S({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function V(e){var n,r;return null==e?null:"1.0.0"===e.f_vsn?e:S({},O,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(r=e.reason)?r:null,data:e.compositeSignature||e.data||S({},e)||{},updates:N(e.authorizationUpdates),local:D((e.local||[])[0])})}var M=function e(r,t){void 0===t&&(t=function(){return!0});try{if(n.invariant(r,"Missing Polling Service",{service:r}),!t())throw new Error("Externally Halted");return Promise.resolve(B(r,{method:z(r)}).then(V)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,t)})}})}catch(e){return Promise.reject(e)}},H={"HTTP/GET":"GET","HTTP/POST":"POST"},z=function(e){return n.invariant(H[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),H[e.method]},W="FCL_IFRAME";function K(e){n.invariant(!document.getElementById(W),"Attempt at triggering multiple Frames",{src:e});var r=document.createElement("iframe");return r.src=e,r.id=W,r.allow="usb *; hid *",r.frameBorder="0",r.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(r),[r.contentWindow,function(){document.getElementById(W)&&document.getElementById(W).remove()}]}var Y=null,q=null;function J(e){var n,r;return null==Y||null!=(n=Y)&&n.closed?(r=window,Y=r.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(r.top.outerHeight/2+r.top.screenY-385)+", left="+(r.top.outerWidth/2+r.top.screenX-320))):q!==e?(Y.location.replace(e),Y.focus()):Y.focus(),q=e,[Y,function(){Y&&!Y.closed&&Y.close(),Y=null}]}var G=null,X=null;function Z(e){var n;return null==G||null!=(n=G)&&n.closed?G=window.open(e,"_blank"):X!==e?(G.location.replace(e),G.focus()):G.focus(),X=e,[G,function(){G&&!G.closed&&G.close(),G=null}]}var $,Q={"VIEW/IFRAME":K,"VIEW/POP":J,"VIEW/TAB":Z},ee=function(e,n,r,t){try{return Promise.resolve(B(e,{data:S({fclVersion:f,service:{params:e.params,data:e.data,type:e.type},config:t},n)}).then(V)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var r=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(Q[e.method](U(e),n))}catch(r){throw console.error("execLocal({service, opts = {}})",r,{service:e,opts:n}),r}}catch(e){return Promise.reject(e)}}(k(n.local))).then(function(e){var t=e[1],o=function(){try{t(),r=!1}catch(e){console.error("Frame Close Error",e)}};return M(n.updates,function(){return r}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})}catch(e){return Promise.reject(e)}},ne=function(e){return"string"==typeof e&&e.toLowerCase()},re=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),te=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},oe=function(e){var n=e.close,r=e.send,t=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(re.has(e.data.type))return;ne(e.data.type)===ne("FCL:VIEW:CLOSE")&&n(),ne(e.data.type)===ne("FCL:VIEW:READY")&&t(e,{send:r,close:n}),ne(e.data.type)===ne("FCL:VIEW:RESPONSE")&&o(e,{send:r,close:n}),i(e,{send:r,close:n}),ne(e.data.type)===ne("FCL:FRAME:READY")&&(te(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),ne(e.data.type)===ne("FCL:FRAME:RESPONSE")&&(te(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),ne(e.data.type)===ne("FCL:FRAME:CLOSE")&&(te(e.data.type,"FCL:VIEW:CLOSE"),n()),ne(e.data.type)===ne("FCL::CHALLENGE::RESPONSE")&&(te(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),ne(e.data.type)===ne("FCL::AUTHZ_READY")&&(te(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),ne(e.data.type)===ne("FCL::CHALLENGE::CANCEL")&&(te(e.data.type,"FCL:VIEW:CLOSE"),n()),ne(e.data.type)===ne("FCL::CANCEL")&&(te(e.data.type,"FCL:VIEW:CLOSE"),n())}catch(e){console.error("Frame Callback Error",e),n()}}},ie=function(){},ae=function(){},se=function(){},ue=function(){},ce=function e(r){var t=r.service,o=r.msg,i=void 0===o?{}:o,a=r.opts,s=void 0===a?{}:a,u=r.config,c=void 0===u?{}:u;try{return Promise.resolve(p(/^service\./)).then(function(r){return Promise.resolve(p(/^app\.detail\./)).then(function(o){var a=S({},c,{services:r,app:o});return function(r,o){try{var u=Promise.resolve(le[t.method](t,i,s,a)).then(function(r){return"REDIRECT"===r.status?(n.invariant(t.type===r.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:r.data,msg:i,opts:s,config:a}))):r})}catch(e){return o(e)}return u&&u.then?u.then(void 0,o):u}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:t,msg:i,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},le={"HTTP/RPC":ee,"HTTP/POST":ee,"IFRAME/RPC":function(e,n,r,t){return new Promise(function(o,i){var s,u=a.uid(),c=r.includeOlderJsonRpcCall;n.data=null!=(s=e.data)?s:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ie,close:ie};var r=n.onClose||ie;window.addEventListener("message",oe({close:a,send:s,onReady:n.onReady||ie,onResponse:n.onResponse||ie,onMessage:n.onMessage||ie}));var t=K(U(e)),o=t[0],i=t[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",oe),i(),r()}catch(e){console.error("Frame Close Error",e)}}function s(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:f,body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:u,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=V(e.data);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==u)return;var t=V(e.data.result);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,r,t){return new Promise(function(o,i){var s=a.uid(),u=r.redir,c=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ae,close:ae};var r=n.onClose||ae;window.addEventListener("message",oe({close:s,send:u,onReady:n.onReady||ae,onResponse:n.onResponse||ae,onMessage:n.onMessage||ae}));var t=J(U(e)),o=t[0],i=t[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",oe),clearInterval(a),i(),r()}catch(e){console.error("Popup Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=V(e.data);switch(t.status){case"APPROVED":o(t.data),!u&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=V(e.data.result);switch(t.status){case"APPROVED":o(t.data),!u&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,r,t){return new Promise(function(o,i){var s=a.uid(),u=r.redir,c=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:se,close:se};var r=n.onClose||se;window.addEventListener("message",oe({close:s,send:u,onReady:n.onReady||se,onResponse:n.onResponse||se,onMessage:n.onMessage||se}));var t=Z(U(e)),o=t[0],i=t[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",oe),clearInterval(a),i(),r()}catch(e){console.error("Tab Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=V(e.data);switch(t.status){case"APPROVED":o(t.data),!u&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=V(e.data.result);switch(t.status){case"APPROVED":o(t.data),!u&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,r,t){return new Promise(function(r,o){!function(e,n){void 0===n&&(n={});try{var r,t=function(){try{window.removeEventListener("message",oe),a()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:ue,close:ue});var i=e.endpoint,a=n.onClose||ue;window.addEventListener("message",oe({close:t,send:o,onReady:n.onReady||ue,onResponse:n.onResponse||ue,onMessage:n.onMessage||ue})),Promise.resolve(null==(r=window[i])?void 0:r.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var i=V(e.data);switch(i.status){case"APPROVED":r(i.data),t();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),t();break;case"REDIRECT":r(i),t();break;default:o("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},de=function(e,n){try{fe(e,n);var r=n[0].addr,t=[],o=[];return n.map(function(e){t.push(e.signature),o.push(e.keyId)}),Promise.resolve(w({cadence:pe,args:function(n,i){return[n(r,i.Address),n(e,i.String),n(o,i.Array([i.Int])),n(t,i.Array([i.String]))]}}))}catch(e){return Promise.reject(e)}},fe=function(e,r){return n.invariant(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),n.invariant(Array.isArray(r)&&r.every(function(e,n,r){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),n.invariant(r.map(function(e){return e.addr}).every(function(e,n,r){return e===r[0]}),"User signatures to be verified must be from a single account address"),!0},pe='\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\n\n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_secp256k1 : SignatureAlgorithm.ECDSA_P256\n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i]\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n';function he(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},j,{addr:o.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function ve(e,n,r){if(!e.s){if(r instanceof ge){if(!r.s)return void(r.o=ve.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(ve.bind(null,e,n),ve.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var me=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(de(e,n))}catch(e){return Promise.reject(e)}},ge=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{ve(t,1,i(this.v))}catch(e){ve(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?ve(t,1,n?n(o):o):r?ve(t,1,r(o)):ve(t,2,o)}catch(e){ve(t,2,e)}},t},e}();function ye(e){return e instanceof ge&&1&e.s}var Pe=function(e){try{return je(),Promise.resolve(Se({redir:!0})).then(function(r){var t=_(r.services,"user-signature");return n.invariant(t,"Current user must have authorized a signing service."),Ee(function(){return Promise.resolve(ce({service:t,msg:Te(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return he(e)}):[he(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function Ee(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}var be=function(){return Promise.resolve(Se()).then(function(n){return e.arg(o.withPrefix(n.addr),l.Address)})},we=function(e){try{return je(),Promise.resolve(S({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Se({redir:!0})).then(function(r){var t;function i(n){if(t)return n;if(a)return S({},e,{tempId:"CURRENT_USER",resolve:null,addr:o.sansPrefix(a.identity.address),keyId:a.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(ce({service:a,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(he)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var a=_(r.services,"authz"),s=_(r.services,"pre-authz"),u=function(){if(s)return Promise.resolve(ce({service:s,msg:n})).then(function(e){var n=function(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),r=[];null!=n.proposer&&r.push(["PROPOSER",n.proposer]);for(var t,o=x(n.payer||[]);!(t=o()).done;)r.push(["PAYER",t.value]);for(var i,a=x(n.authorization||[]);!(i=a()).done;)r.push(["AUTHORIZER",i.value]);return r.map(function(e){var n=e[0],r=e[1];return{tempId:[r.identity.address,r.identity.keyId].join("|"),addr:r.identity.address,keyId:r.identity.keyId,signingFunction:function(e){return ce({service:r,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return t=1,n})}();return u&&u.then?u.then(i):i(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Se=function(r){var o=void 0===r?{}:r,i=o.service,a=o.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(r,o){try{return je(),Promise.resolve(ke()).then(function(o){return Promise.resolve(Re()).then(function(a){var u={redir:s};return Promise.resolve(function(){try{return Promise.resolve(e.config.first(["discovery.wallet","challenge.handshake"])).then(function(n){return Promise.resolve(e.config.get("discovery.authn.include",[])).then(function(r){return Promise.resolve(e.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(e){return{type:"authn",endpoint:n,method:e,discoveryAuthnInclude:r}})})})}catch(e){return Promise.reject(e)}}()).then(function(c){var l=_(o.services,"authn-refresh");return Promise.resolve(e.config.get("fcl.warning.suppress.redir")).then(function(e){var d;function f(e){if(d)return e;var n=function(e,n){try{var r=Ee(function(){return Promise.resolve(ce({service:S({},i||c,{method:(null==c?void 0:c.method)||i.method||"IFRAME/RPC"}),msg:a,opts:u,config:{discoveryAuthnInclude:c.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(F(e)).then(function(e){t.send(xe,Ce,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return r&&r.then?r.then(n.bind(null,!1),n.bind(null,!0)):n(!1,r)}(0,function(e,n){return Promise.resolve(ke()).then(function(t){if(r(t),e)throw n;return n})});return n&&n.then?n.then(function(){}):void 0}s&&!e&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config"),n.invariant(i||c.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');var p=function(){if(o.loggedIn){if(l)return function(e,n){try{var r=Ee(function(){return Promise.resolve(ce({service:l,msg:a,opts:u})).then(function(e){return Promise.resolve(F(e)).then(function(e){t.send(xe,Ce,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return r&&r.then?r.then(n,n):n()}(0,function(){return Promise.resolve(ke()).then(function(e){var n=r(e);return d=1,n})});var e=r(o);return d=1,e}}();return p&&p.then?p.then(f):f(p)})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Re=function(){try{var n=Date.now();return Promise.resolve(e.config.get("fcl.appDomainTag")).then(function(e){return{timestamp:n,appDomainTag:e,extensions:window.fcl_extensions||[]}})}catch(e){return Promise.reject(e)}},xe="CURRENT_USER",Ie="CURRENT_USER/UPDATED",Ce="SET_CURRENT_USER",Ae='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Oe=(($={})[t.INIT]=function(n){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),n.merge(JSON.parse(Ae)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){var r=function(){if(e.can)return Promise.resolve(function(e){try{var n=JSON.parse(Ae);return Promise.resolve(e.get(xe)).then(function(r){return null!=r&&n.f_vsn!==r.f_vsn?(e.removeItem(xe),n):r||n})}catch(e){return Promise.reject(e)}}(e)).then(function(e){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(e)&&n.merge(e)})}();if(r&&r.then)return r.then(function(){})})}catch(e){return Promise.reject(e)}},$[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,Ie,S({},e.all()))},$[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},$.SNAPSHOT=function(e,n){try{return n.reply(S({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},$[Ce]=function(n,r,t){try{return n.merge(t),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(xe,n.all()),n.broadcast(Ie,S({},n.all()))})}catch(e){return Promise.reject(e)}},$.DEL_CURRENT_USER=function(n,r){try{return n.merge(JSON.parse(Ae)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(xe,n.all()),n.broadcast(Ie,S({},n.all()))})}catch(e){return Promise.reject(e)}},$),je=function(){return t.spawn(Oe,xe)};function De(){je(),t.send(xe,"DEL_CURRENT_USER")}function Ne(e){je();var n="@EXIT",r=t.spawn(function(r){try{var o;return r.send(xe,t.SUBSCRIBE),Promise.resolve(function(e,n,r){for(var t;;){var o=e();if(ye(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=r();if(i&&i.then){if(!ye(i)){t=1;break}i=i.s}}var a=new ge,s=ve.bind(null,a,2);return(0===t?o.then(c):1===t?i.then(u):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):ve(a,1,i)})).then(void 0,s),a;function u(n){i=n;do{if(!(o=e())||ye(o)&&!o.v)return void ve(a,1,i);if(o.then)return void o.then(c).then(void 0,s);ye(i=r())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,s)}function c(e){e?(i=r())&&i.then?i.then(u).then(void 0,s):u(i):ve(a,1,i)}}(function(){return!o&&1},0,function(){return Promise.resolve(r.receive()).then(function(i){if(i.tag===n)return r.send(xe,t.UNSUBSCRIBE),void(o=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return t.send(r,n)}}function ke(){return je(),t.send(xe,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Le,Te=function(e){return n.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Fe=function(){return{authenticate:Se,unauthenticate:De,authorization:we,signUserMessage:Pe,verifyUserSignatures:me,subscribe:Ne,snapshot:ke,resolveArgument:be}};Fe.authenticate=Se,Fe.unauthenticate=De,Fe.authorization=we,Fe.signUserMessage=Pe,Fe.verifyUserSignatures=me,Fe.subscribe=Ne,Fe.snapshot=ke,Fe.resolveArgument=be;var _e=function(n){try{return Promise.resolve(e.send([e.getTransactionStatus(n)]).then(e.decode))}catch(e){return Promise.reject(e)}},Ue=function(e){return e.status>=4},Be=function(e){return e.status>=3},Ve=function(e){return e.status>=2},Me=((Le={})[t.INIT]=function(e){try{return Promise.resolve(_e(e.self())).then(function(n){Ue(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Le[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,t.UPDATED,e.all())},Le[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Le[t.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Le.POLL=function(e){try{return Promise.resolve(_e(e.self())).then(function(n){var r,o;Ue(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),r=e.all(),o=n,JSON.stringify(r)!==JSON.stringify(o)&&e.broadcast(t.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Le),He=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},ze=function(e){return t.spawn(Me,He(e))};function We(e){function n(n){return t.subscriber(He(e),ze,n)}function r(e){return function(r){void 0===r&&(r={});var t=r.suppress||!1;return new Promise(function(r,o){var i=n(function(n){n.statusCode&&!t?(o(n.errorMessage),i()):e(n)&&(r(n),i())})})}}return{snapshot:function(){return t.snapshoter(e,ze)},subscribe:n,onceFinalized:r(Ve),onceExecuted:r(Be),onceSealed:r(Ue)}}We.isUnknown=function(e){return e.status>=0},We.isPending=function(e){return e.status>=1},We.isFinalized=Ve,We.isExecuted=Be,We.isSealed=Ue,We.isExpired=function(e){return 5===e.status};var Ke,Ye=function(n){try{var r=setTimeout;return Promise.resolve(e.config().get("fcl.eventPollRate",1e4)).then(function(e){return r(function(){return n.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},qe=((Ke={}).TICK=function(n){try{if(!n.hasSubs())return Promise.resolve();var r=n.get("hwm"),t=function(){if(null==r){var t=n.put;return Promise.resolve(e.latestBlock()).then(function(e){t.call(n,"hwm",e);var r=n.put;return Promise.resolve(Ye(n)).then(function(e){r.call(n,"tick",e)})})}return Promise.resolve(e.latestBlock()).then(function(t){return n.put("hwm",t),Promise.resolve(e.send([e.getEvents(n.self(),r.height,t.height-1)]).then(e.decode)).then(function(e){for(var r,t=x(e);!(r=t()).done;)n.broadcast("UPDATED",r.value.data);var o=n.put;return Promise.resolve(Ye(n)).then(function(e){o.call(n,"tick",e)})})})}();return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},Ke[t.SUBSCRIBE]=function(e,n){try{var r=function(){e.subscribe(n.from)},t=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(Ye(e)).then(function(r){n.call(e,"tick",r)})}}();return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},Ke[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},Ke),Je=function(e){return t.spawn(qe,e)},Ge=function(r){void 0===r&&(r=[]);try{return Promise.resolve(e.config.get("discovery.authn.endpoint")).then(function(t){return n.invariant(Boolean(t),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(e.config.get("discovery.authn.include",[])).then(function(e){var n=new URL(t);return fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:f,include:e})}).then(function(e){return e.json()}).then(function(e){return[].concat(r,e)})})})}catch(e){return Promise.reject(e)}};function Xe(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var Ze,$e=((Ze={})[t.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:"authn"},r=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(Ge,Xe,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,r)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,r},Ze[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",S({},e.all()))},Ze[t.UNSUBSCRIBE]=function(e,n){return e.unsubscribe(n.from)},Ze.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(S({},e.all())))}catch(e){return Promise.reject(e)}},Ze),Qe=function(){return t.spawn($e,"authn")},en={authn:{subscribe:function(e){return t.subscriber("authn",Qe,e)},snapshot:function(){return t.snapshoter("authn",Qe)}}},nn=function(e,n){void 0===n&&(n=function(){});var r=function(r){var t=r.data;"object"==typeof t&&null!=typeof t&&t.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(t))};return window.addEventListener("message",r),function(){return window.removeEventListener("message",r)}},rn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(S({},n,{type:e}),"*"):window.opener.postMessage(S({},n,{type:e}),"*")},tn=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},on={__proto__:null,sendMsgToFCL:rn,ready:function(e,n){nn("FCL:VIEW:READY:RESPONSE",e),rn("FCL:VIEW:READY")},close:function(){rn("FCL:VIEW:CLOSE")},approve:function(e){rn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){rn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){rn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:nn,encodeMessageFromSignable:e.encodeMessageFromSignable,CompositeSignature:function(e,n,r){this.f_type=j.f_type,this.f_vsn=j.f_vsn,this.addr=o.withPrefix(e),this.keyId=Number(n),this.signature=r},encodeMessageForProvableAuthnSigning:function(e,r,t){void 0===t&&(t=""),n.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),n.invariant(r,"Encode Message From Provable Authn Error: timestamp must be defined");var a=tn(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),s=tn(Buffer.from(t).toString("hex"),32).toString("hex");return a+(t?i.encode([s,o.withPrefix(e),r]).toString("hex"):i.encode([o.withPrefix(e),r]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,r,t){void 0===t&&(t=""),n.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),n.invariant(r,"Encode Message From Provable Authn Error: timestamp must be defined");var a,s=t?(a=Buffer.from(t).toString("hex"),Buffer.from(a.padEnd(64,0),"hex")).toString("hex"):null;return t?i.encode([s,o.withPrefix(e),r]).toString("hex"):i.encode([o.withPrefix(e),r]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},an=Fe().authorization,sn=l;Object.defineProperty(exports,"TestUtils",{enumerable:!0,get:function(){return e.TestUtils}}),Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return e.account}}),Object.defineProperty(exports,"arg",{enumerable:!0,get:function(){return e.arg}}),Object.defineProperty(exports,"args",{enumerable:!0,get:function(){return e.args}}),Object.defineProperty(exports,"atBlockHeight",{enumerable:!0,get:function(){return e.atBlockHeight}}),Object.defineProperty(exports,"atBlockId",{enumerable:!0,get:function(){return e.atBlockId}}),Object.defineProperty(exports,"authorization",{enumerable:!0,get:function(){return e.authorization}}),Object.defineProperty(exports,"authorizations",{enumerable:!0,get:function(){return e.authorizations}}),Object.defineProperty(exports,"block",{enumerable:!0,get:function(){return e.block}}),Object.defineProperty(exports,"build",{enumerable:!0,get:function(){return e.build}}),Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return e.config}}),Object.defineProperty(exports,"createSignableVoucher",{enumerable:!0,get:function(){return e.createSignableVoucher}}),Object.defineProperty(exports,"decode",{enumerable:!0,get:function(){return e.decode}}),Object.defineProperty(exports,"getAccount",{enumerable:!0,get:function(){return e.getAccount}}),Object.defineProperty(exports,"getBlock",{enumerable:!0,get:function(){return e.getBlock}}),Object.defineProperty(exports,"getBlockByHeight",{enumerable:!0,get:function(){return e.getBlockByHeight}}),Object.defineProperty(exports,"getBlockById",{enumerable:!0,get:function(){return e.getBlockById}}),Object.defineProperty(exports,"getBlockHeader",{enumerable:!0,get:function(){return e.getBlockHeader}}),Object.defineProperty(exports,"getCollection",{enumerable:!0,get:function(){return e.getCollection}}),Object.defineProperty(exports,"getEvents",{enumerable:!0,get:function(){return e.getEvents}}),Object.defineProperty(exports,"getEventsAtBlockHeightRange",{enumerable:!0,get:function(){return e.getEventsAtBlockHeightRange}}),Object.defineProperty(exports,"getEventsAtBlockIds",{enumerable:!0,get:function(){return e.getEventsAtBlockIds}}),Object.defineProperty(exports,"getLatestBlock",{enumerable:!0,get:function(){return e.getLatestBlock}}),Object.defineProperty(exports,"getTransaction",{enumerable:!0,get:function(){return e.getTransaction}}),Object.defineProperty(exports,"getTransactionStatus",{enumerable:!0,get:function(){return e.getTransactionStatus}}),Object.defineProperty(exports,"invariant",{enumerable:!0,get:function(){return e.invariant}}),Object.defineProperty(exports,"isBad",{enumerable:!0,get:function(){return e.isBad}}),Object.defineProperty(exports,"isOk",{enumerable:!0,get:function(){return e.isOk}}),Object.defineProperty(exports,"latestBlock",{enumerable:!0,get:function(){return e.latestBlock}}),Object.defineProperty(exports,"limit",{enumerable:!0,get:function(){return e.limit}}),Object.defineProperty(exports,"param",{enumerable:!0,get:function(){return e.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return e.params}}),Object.defineProperty(exports,"payer",{enumerable:!0,get:function(){return e.payer}}),Object.defineProperty(exports,"ping",{enumerable:!0,get:function(){return e.ping}}),Object.defineProperty(exports,"pipe",{enumerable:!0,get:function(){return e.pipe}}),Object.defineProperty(exports,"proposer",{enumerable:!0,get:function(){return e.proposer}}),Object.defineProperty(exports,"ref",{enumerable:!0,get:function(){return e.ref}}),Object.defineProperty(exports,"script",{enumerable:!0,get:function(){return e.script}}),Object.defineProperty(exports,"send",{enumerable:!0,get:function(){return e.send}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return e.transaction}}),Object.defineProperty(exports,"validator",{enumerable:!0,get:function(){return e.validator}}),Object.defineProperty(exports,"voucherIntercept",{enumerable:!0,get:function(){return e.voucherIntercept}}),Object.defineProperty(exports,"voucherToTxId",{enumerable:!0,get:function(){return e.voucherToTxId}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return e.why}}),Object.defineProperty(exports,"display",{enumerable:!0,get:function(){return o.display}}),Object.defineProperty(exports,"sansPrefix",{enumerable:!0,get:function(){return o.sansPrefix}}),Object.defineProperty(exports,"withPrefix",{enumerable:!0,get:function(){return o.withPrefix}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return s.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return s.template}}),exports.VERSION=f,exports.WalletUtils=on,exports.authenticate=function(e){return void 0===e&&(e={}),Fe().authenticate(e)},exports.authz=an,exports.currentUser=Fe,exports.discovery=en,exports.events=function(e){return{subscribe:function(n){return t.subscriber(e,Je,n)}}},exports.logIn=function(e){return void 0===e&&(e={}),Fe().authenticate(e)},exports.mutate=function(e){void 0===e&&(e={});try{return Promise.resolve(function(r,t){try{var o=Promise.resolve(function(e){try{return n.invariant(m(e),"mutate(opts) -- opts is required"),n.invariant(g(e),"mutate(opts) -- opts must be an object"),n.invariant(m(e.cadence),"mutate({ cadence }) -- cadence is required"),n.invariant(y(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(c.config.get("accessNode.api")).then(function(e){n.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return Promise.resolve(c.config().get("fcl.authz",Fe().authorization)).then(function(n){return c.send([c.transaction(e.cadence),c.args(b(e.args||[])),e.limit&&E(e.limit)&&c.limit(e.limit),c.proposer(e.proposer||e.authz||n),c.payer(e.payer||e.authz||n),c.authorizations(e.authorizations||[e.authz||n])]).then(c.decode)})})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},exports.query=w,exports.reauthenticate=function(e){return void 0===e&&(e={}),Fe().unauthenticate(),Fe().authenticate(e)},exports.serialize=function(n,r){void 0===n&&(n=[]),void 0===r&&(r={});try{return Promise.resolve(e.config.first(["sdk.resolve"],r.resolve||e.resolve)).then(function(r){function t(){return Promise.resolve(r(n)).then(function(n){return JSON.stringify(e.createSignableVoucher(n),null,2)})}var o=function(){if(Array.isArray(n))return Promise.resolve(e.pipe(e.interaction(),n)).then(function(e){n=e})}();return o&&o.then?o.then(t):t()})}catch(e){return Promise.reject(e)}},exports.signUp=function(e){return void 0===e&&(e={}),Fe().authenticate(e)},exports.t=sn,exports.tx=We,exports.unauthenticate=function(){return Fe().unauthenticate()},exports.verifyUserSignatures=de; | ||
var e=require("@onflow/sdk"),r=require("@onflow/util-invariant"),n=require("@onflow/types"),t=require("@onflow/util-actor"),o=require("@onflow/util-address"),i=require("@onflow/rlp"),s=require("@onflow/util-uid"),a=require("@onflow/util-template");function u(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var t=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,t.get?t:{enumerable:!0,get:function(){return e[n]}})}}),r.default=e,r}var c=u(e),d=u(n),f=u(i),l="0.0.79-alpha.4",p=function(r){try{return Promise.resolve(e.config().where(r)).then(function(e){return Object.fromEntries(Object.entries(e).map(function(e){var n=e[1];return[e[0].replace(r,""),n]}))})}catch(e){return Promise.reject(e)}},v={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,r){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(r)))}catch(e){return Promise.reject(e)}}};e.config({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":v});var h=function(e){return function(r){return typeof r===e}},m=function(e){return null!=e},y=h("object"),g=h("string"),P=h("function"),E=h("number");function b(e){return P(e)?e(c.arg,d):[]}var R=function(e){return void 0===e&&(e={}),Promise.resolve(function(e){try{return r.invariant(m(e.cadence),"query({ cadence }) -- cadence is required"),r.invariant(g(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(c.config.get("accessNode.api")).then(function(e){r.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return c.send([c.script(e.cadence),c.args(b(e.args||[])),e.limit&&"number"==typeof e.limit&&c.limit(e.limit)]).then(c.decode)})};function w(){return w=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},w.apply(this,arguments)}function S(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function C(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return S(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?S(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var I={f_type:"Service",f_vsn:"1.0.0"},O={f_type:"Identity",f_vsn:"1.0.0"},x={f_type:"USER",f_vsn:"1.0.0"},j={f_type:"PollingResponse",f_vsn:"1.0.0"},A={f_type:"CompositeSignature",f_vsn:"1.0.0"};function N(e){return null==e?null:"1.0.0"===e.f_vsn?e:w({old:e},I,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function D(e){return null==e?null:"1.0.0"===e.f_vsn?e:w({},I,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function L(e){return null==e?null:(null==e.method&&(e=w({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:w({},I,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var k={"back-channel-rpc":D,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:w({},I,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:w({},O,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:w({},I,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:w({},O,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:w({},I,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:o.withPrefix(e.addr),name:e.name,icon:e.icon}})},frame:N,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":L,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("FCL Normalizer Error: Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function F(e){return f.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var T=function(e){try{var r=(e=function(e){return e.addr=e.addr?o.withPrefix(e.addr):null,e.paddr=e.paddr?o.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,r){try{if(null==e||null==r)return Promise.resolve([]);var n=new URL(e);return n.searchParams.append("code",r),Promise.resolve(fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var r=[];if(Array.isArray(e.authorizations))for(var n,t=C(e.authorizations);!(n=t()).done;)r.push(w({type:"authz",keyId:e.keyId},n.value));return null!=e.provider&&r.push(w({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(n){var t,i,s=(t=r,i=n,void 0===t&&(t=[]),void 0===i&&(i=[]),[].concat(t,i)).map(function(r){return function(e,r){try{return k[e.type](e,r)}catch(r){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,r),e}}(r,e)}),a=function(e,r){return r.find(function(e){return"authn"===e.type})}(0,s);return w({},x,{addr:o.withPrefix(e.addr),cid:F(a),loggedIn:!0,services:s,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function _(e,r){return void 0===e&&(e=[]),e.find(function(e){return e.type===r})}function U(e){var r=new URL(e.endpoint);if(r.searchParams.append("l6n",window.location.origin),null!=e.params)for(var n=0,t=Object.entries(e.params||{});n<t.length;n++){var o=t[n];r.searchParams.append(o[0],o[1])}return r}function B(e,r){void 0===r&&(r={});var n=r.method||"POST",t="GET"===n?void 0:JSON.stringify(r.data||e.data||{});return fetch(U(e),{method:n,headers:w({},e.headers||{},r.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function M(e){var r,n;return null==e?null:"1.0.0"===e.f_vsn?e:w({},j,{status:null!=(r=e.status)?r:"APPROVED",reason:null!=(n=e.reason)?n:null,data:e.compositeSignature||e.data||w({},e)||{},updates:D(e.authorizationUpdates),local:N((e.local||[])[0])})}var V=function e(n,t){void 0===t&&(t=function(){return!0});try{if(r.invariant(n,"Missing Polling Service",{service:n}),!t())throw new Error("Externally Halted");return Promise.resolve(B(n,{method:W(n)}).then(M)).then(function(r){switch(r.status){case"APPROVED":return r.data;case"DECLINED":throw new Error("Declined: "+(r.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(r.updates,t)})}})}catch(e){return Promise.reject(e)}},z={"HTTP/GET":"GET","HTTP/POST":"POST"},W=function(e){return r.invariant(z[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),z[e.method]},H="FCL_IFRAME";function Y(e){r.invariant(!document.getElementById(H),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=H,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,function(){document.getElementById(H)&&document.getElementById(H).remove()}]}var J=null,q=null;function G(e){var r,n;return null==J||null!=(r=J)&&r.closed?(n=window,J=n.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(n.top.outerHeight/2+n.top.screenY-385)+", left="+(n.top.outerWidth/2+n.top.screenX-320))):q!==e?(J.location.replace(e),J.focus()):J.focus(),q=e,[J,function(){J&&!J.closed&&J.close(),J=null}]}var $=null,K=null;function X(e){var r;return null==$||null!=(r=$)&&r.closed?$=window.open(e,"_blank"):K!==e?($.location.replace(e),$.focus()):$.focus(),K=e,[$,function(){$&&!$.closed&&$.close(),$=null}]}var Z,Q={"VIEW/IFRAME":Y,"VIEW/POP":G,"VIEW/TAB":X},ee=function(e,r,n,t){try{return Promise.resolve(B(e,{data:w({fclVersion:l,service:{params:e.params,data:e.data,type:e.type},config:t},r)}).then(M)).then(function(r){if("APPROVED"===r.status)return r.data;if("DECLINED"===r.status)throw new Error("Declined: "+(r.reason||"No reason supplied."));if("REDIRECT"===r.status)return r;if("PENDING"===r.status){var n=!0;return Promise.resolve(function(e,r){void 0===r&&(r={});try{try{return Promise.resolve(Q[e.method](U(e),r))}catch(n){throw console.error("execLocal({service, opts = {}})",n,{service:e,opts:r}),n}}catch(e){return Promise.reject(e)}}(L(r.local))).then(function(e){var t=e[1],o=function(){try{t(),n=!1}catch(e){console.error("Frame Close Error",e)}};return V(r.updates,function(){return n}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:r}),new Error("Auto Decline: Invalid Response")})}catch(e){return Promise.reject(e)}},re=function(e){return"string"==typeof e&&e.toLowerCase()},ne=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),te=function(e,r){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+r+" for this and future versions of FCL")},oe=function(e){var r=e.close,n=e.send,t=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(ne.has(e.data.type))return;re(e.data.type)===re("FCL:VIEW:CLOSE")&&r(),re(e.data.type)===re("FCL:VIEW:READY")&&t(e,{send:n,close:r}),re(e.data.type)===re("FCL:VIEW:RESPONSE")&&o(e,{send:n,close:r}),i(e,{send:n,close:r}),re(e.data.type)===re("FCL:FRAME:READY")&&(te(e.data.type,"FCL:VIEW:READY"),t(e,{send:n,close:r})),re(e.data.type)===re("FCL:FRAME:RESPONSE")&&(te(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:n,close:r})),re(e.data.type)===re("FCL:FRAME:CLOSE")&&(te(e.data.type,"FCL:VIEW:CLOSE"),r()),re(e.data.type)===re("FCL::CHALLENGE::RESPONSE")&&(te(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:n,close:r})),re(e.data.type)===re("FCL::AUTHZ_READY")&&(te(e.data.type,"FCL:VIEW:READY"),t(e,{send:n,close:r})),re(e.data.type)===re("FCL::CHALLENGE::CANCEL")&&(te(e.data.type,"FCL:VIEW:CLOSE"),r()),re(e.data.type)===re("FCL::CANCEL")&&(te(e.data.type,"FCL:VIEW:CLOSE"),r())}catch(e){console.error("Frame Callback Error",e),r()}}},ie=function(){},se=function(){},ae=function(){},ue=function(){},ce=function e(n){var t=n.service,o=n.msg,i=void 0===o?{}:o,s=n.opts,a=void 0===s?{}:s,u=n.config,c=void 0===u?{}:u;try{return i.extensions=window.fcl_extensions||[],i.data=t.data,Promise.resolve(p(/^service\./)).then(function(n){return Promise.resolve(p(/^app\.detail\./)).then(function(o){var s=w({},c,{services:n,app:o});return function(n,o){try{var u=Promise.resolve(de[t.method](t,i,a,s)).then(function(n){return"REDIRECT"===n.status?(r.invariant(t.type===n.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:n.data,msg:i,opts:a,config:s}))):n})}catch(e){return o(e)}return u&&u.then?u.then(void 0,o):u}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:t,msg:i,opts:a,config:c}),e})})})}catch(e){return Promise.reject(e)}},de={"HTTP/RPC":ee,"HTTP/POST":ee,"IFRAME/RPC":function(e,r,n,t){return new Promise(function(o,i){var a=s.uid(),u=n.includeOlderJsonRpcCall;!function(e,r){if(void 0===r&&(r={}),null==e)return{send:ie,close:ie};var n=r.onClose||ie;window.addEventListener("message",oe({close:s,send:a,onReady:r.onReady||ie,onResponse:r.onResponse||ie,onMessage:r.onMessage||ie}));var t=Y(U(e)),o=t[0],i=t[1];return{send:a,close:s};function s(){try{window.removeEventListener("message",oe),i(),n()}catch(e){console.error("Frame Close Error",e)}}function a(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(r){console.error("Frame Send Error",e,r)}}}(e,{onReady:function(n,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:l,body:r,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:l,type:"FCL:FRAME:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[r,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;var t=M(e.data);switch(t.status){case"APPROVED":o(t.data),n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var t=M(e.data.result);switch(t.status){case"APPROVED":o(t.data),n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,r,n,t){return new Promise(function(o,i){var a=s.uid(),u=n.redir,c=n.includeOlderJsonRpcCall;!function(e,r){if(void 0===r&&(r={}),null==e)return{send:se,close:se};var n=r.onClose||se;window.addEventListener("message",oe({close:a,send:u,onReady:r.onReady||se,onResponse:r.onResponse||se,onMessage:r.onMessage||se}));var t=G(U(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:u,close:a};function a(){try{window.removeEventListener("message",oe),clearInterval(s),i(),n()}catch(e){console.error("Popup Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(r){console.error("Popup Send Error",e,r)}}}(e,{onReady:function(n,o){var i=o.send;try{try{i({fclVersion:l,type:"FCL:VIEW:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:l,type:"FCL:FRAME:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[r,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;var t=M(e.data);switch(t.status){case"APPROVED":o(t.data),!u&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var t=M(e.data.result);switch(t.status){case"APPROVED":o(t.data),!u&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,r,n,t){return new Promise(function(o,i){var a=s.uid(),u=n.redir,c=n.includeOlderJsonRpcCall;!function(e,r){if(void 0===r&&(r={}),null==e)return{send:ae,close:ae};var n=r.onClose||ae;window.addEventListener("message",oe({close:a,send:u,onReady:r.onReady||ae,onResponse:r.onResponse||ae,onMessage:r.onMessage||ae}));var t=X(U(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:u,close:a};function a(){try{window.removeEventListener("message",oe),clearInterval(s),i(),n()}catch(e){console.error("Tab Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(r){console.error("Tab Send Error",e,r)}}}(e,{onReady:function(n,o){var i=o.send;try{try{i({fclVersion:l,type:"FCL:VIEW:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:l,type:"FCL:FRAME:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[r,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;var t=M(e.data);switch(t.status){case"APPROVED":o(t.data),!u&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var t=M(e.data.result);switch(t.status){case"APPROVED":o(t.data),!u&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,r,n,t){return new Promise(function(n,o){!function(e,r){void 0===r&&(r={});try{var n,t=function(){try{window.removeEventListener("message",oe),s()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var r;null==(r=window[i])||r.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(r){console.error("Extension Send Error",e,r)}};if(null==e)return Promise.resolve({send:ue,close:ue});var i=e.endpoint,s=r.onClose||ue;window.addEventListener("message",oe({close:t,send:o,onReady:r.onReady||ue,onResponse:r.onResponse||ue,onMessage:r.onMessage||ue})),Promise.resolve(null==(n=window[i])?void 0:n.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(n,o){var i=o.send;try{try{i({fclVersion:l,type:"FCL:VIEW:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var t=r.close;try{if("object"!=typeof e.data)return;var i=M(e.data);switch(i.status){case"APPROVED":n(i.data),t();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),t();break;case"REDIRECT":n(i),t();break;default:o("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},fe=function(r,n){try{le(r,n);for(var t,o=n[0].addr,i=[],s=[],a=C(n);!(t=a()).done;){var u=t.value;i.push(u.signature),s.push(u.keyId)}return Promise.resolve(function(){try{return Promise.resolve(e.config.get("env")).then(function(e){return"\n import FCLCrypto from "+("testnet"===e?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284")+"\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyUserSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n "})}catch(e){return Promise.reject(e)}}()).then(function(e){return Promise.resolve(R({cadence:e,args:function(e,n){return[e(o,n.Address),e(r,n.String),e(s,n.Array([n.Int])),e(i,n.Array([n.String]))]}}))})}catch(e){return Promise.reject(e)}},le=function(e,n){return r.invariant(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),r.invariant(Array.isArray(n)&&n.every(function(e,r,n){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),r.invariant(n.map(function(e){return e.addr}).every(function(e,r,n){return e===n[0]}),"User signatures to be verified must be from a single account address"),!0};function pe(e){return null==e?null:"1.0.0"===e.f_vsn?e:w({},A,{addr:o.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function ve(e,r,n){if(!e.s){if(n instanceof me){if(!n.s)return void(n.o=ve.bind(null,e,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(ve.bind(null,e,r),ve.bind(null,e,2));e.s=r,e.v=n;var t=e.o;t&&t(e)}}var he=function(e,r){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(fe(e,r))}catch(e){return Promise.reject(e)}},me=function(){function e(){}return e.prototype.then=function(r,n){var t=new e,o=this.s;if(o){var i=1&o?r:n;if(i){try{ve(t,1,i(this.v))}catch(e){ve(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?ve(t,1,r?r(o):o):n?ve(t,1,n(o)):ve(t,2,o)}catch(e){ve(t,2,e)}},t},e}();function ye(e){return e instanceof me&&1&e.s}var ge=function(e){try{return je(),Promise.resolve(Re({redir:!0})).then(function(n){var t=_(n.services,"user-signature");return r.invariant(t,"Current user must have authorized a signing service."),Pe(function(){return Promise.resolve(ce({service:t,msg:ke(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return pe(e)}):[pe(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function Pe(e,r){try{var n=e()}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}var Ee=function(){return Promise.resolve(Re()).then(function(r){return e.arg(o.withPrefix(r.addr),d.Address)})},be=function(e){try{return je(),Promise.resolve(w({},e,{tempId:"CURRENT_USER",resolve:function(e,r){try{return Promise.resolve(Re({redir:!0})).then(function(n){var t;function i(r){if(t)return r;if(s)return w({},e,{tempId:"CURRENT_USER",resolve:null,addr:o.sansPrefix(s.identity.address),keyId:s.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(ce({service:s,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(pe)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var s=_(n.services,"authz"),a=_(n.services,"pre-authz"),u=function(){if(a)return Promise.resolve(ce({service:a,msg:r})).then(function(e){var r=function(e){var r=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),n=[];null!=r.proposer&&n.push(["PROPOSER",r.proposer]);for(var t,o=C(r.payer||[]);!(t=o()).done;)n.push(["PAYER",t.value]);for(var i,s=C(r.authorization||[]);!(i=s()).done;)n.push(["AUTHORIZER",i.value]);return n.map(function(e){var r=e[0],n=e[1];return{tempId:[n.identity.address,n.identity.keyId].join("|"),addr:n.identity.address,keyId:n.identity.keyId,signingFunction:function(e){return ce({service:n,msg:e})},role:{proposer:"PROPOSER"===r,payer:"PAYER"===r,authorizer:"AUTHORIZER"===r}}})}(e);return t=1,r})}();return u&&u.then?u.then(i):i(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Re=function(n){var o=void 0===n?{}:n,i=o.service,s=o.redir,a=void 0!==s&&s;try{return Promise.resolve(new Promise(function(n,o){try{je();var s={redir:a};return Promise.resolve(De()).then(function(a){return Promise.resolve(function(){try{return Promise.resolve(e.config.first(["discovery.wallet","challenge.handshake"])).then(function(r){return Promise.resolve(e.config.get("discovery.authn.include",[])).then(function(n){return Promise.resolve(e.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(e){return{type:"authn",endpoint:r,method:e,discoveryAuthnInclude:n}})})})}catch(e){return Promise.reject(e)}}()).then(function(e){var u;function c(o){var c;if(u)return o;function l(r){if(c)return r;var o=function(r,n){try{var o=Pe(function(){return Promise.resolve(ce({service:w({},i||e,{method:(null==e?void 0:e.method)||i.method||"IFRAME/RPC"}),msg:d,opts:s,config:{discoveryAuthnInclude:e.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(T(e)).then(function(e){t.send(Se,Ie,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return o&&o.then?o.then(n.bind(null,!1),n.bind(null,!0)):n(!1,o)}(0,function(e,r){return Promise.resolve(De()).then(function(t){if(n(t),e)throw r;return r})});return o&&o.then?o.then(function(){}):void 0}r.invariant(i||e.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');var p=function(){if(a.loggedIn){if(f)return function(e,r){try{var n=Pe(function(){return Promise.resolve(ce({service:f,msg:d,opts:s})).then(function(e){return Promise.resolve(T(e)).then(function(e){t.send(Se,Ie,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return r()}return n&&n.then?n.then(r,r):r()}(0,function(){return Promise.resolve(De()).then(function(e){var r=n(e);return c=1,r})});var e=n(a);return c=1,e}}();return p&&p.then?p.then(l):l(p)}var d,f=_(a.services,"authn-refresh"),l=Pe(function(){return Promise.resolve(we()).then(function(e){d=e})},function(e){console.error("Error During Authentication: Could not resolve account proof data.\n "+e);var r=o(e);return u=1,r});return l&&l.then?l.then(c):c(l)})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},we=function(){try{return Promise.resolve(e.config.get("fcl.accountProof.resolver")).then(function(e){function n(e){if(null!=e)return r.invariant("string"==typeof e.appIdentifier,"appIdentifier must be a string"),r.invariant(/^[0-9a-f]+$/i.test(e.nonce),"Nonce must be a hex string"),e}return e?Promise.resolve(e()).then(n):n(e)})}catch(e){return Promise.reject(e)}},Se="CURRENT_USER",Ce="CURRENT_USER/UPDATED",Ie="SET_CURRENT_USER",Oe='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',xe=((Z={})[t.INIT]=function(r){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),r.merge(JSON.parse(Oe)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){var n=function(){if(e.can)return Promise.resolve(function(e){try{var r=JSON.parse(Oe);return Promise.resolve(e.get(Se)).then(function(n){return null!=n&&r.f_vsn!==n.f_vsn?(e.removeItem(Se),r):n||r})}catch(e){return Promise.reject(e)}}(e)).then(function(e){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(e)&&r.merge(e)})}();if(n&&n.then)return n.then(function(){})})}catch(e){return Promise.reject(e)}},Z[t.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,Ce,w({},e.all()))},Z[t.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},Z.SNAPSHOT=function(e,r){try{return r.reply(w({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},Z[Ie]=function(r,n,t){try{return r.merge(t),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(Se,r.all()),r.broadcast(Ce,w({},r.all()))})}catch(e){return Promise.reject(e)}},Z.DEL_CURRENT_USER=function(r,n){try{return r.merge(JSON.parse(Oe)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(Se,r.all()),r.broadcast(Ce,w({},r.all()))})}catch(e){return Promise.reject(e)}},Z),je=function(){return t.spawn(xe,Se)};function Ae(){je(),t.send(Se,"DEL_CURRENT_USER")}function Ne(e){je();var r="@EXIT",n=t.spawn(function(n){try{var o;return n.send(Se,t.SUBSCRIBE),Promise.resolve(function(e,r,n){for(var t;;){var o=e();if(ye(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=n();if(i&&i.then){if(!ye(i)){t=1;break}i=i.s}}var s=new me,a=ve.bind(null,s,2);return(0===t?o.then(c):1===t?i.then(u):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,a):c(o):ve(s,1,i)})).then(void 0,a),s;function u(r){i=r;do{if(!(o=e())||ye(o)&&!o.v)return void ve(s,1,i);if(o.then)return void o.then(c).then(void 0,a);ye(i=n())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,a)}function c(e){e?(i=n())&&i.then?i.then(u).then(void 0,a):u(i):ve(s,1,i)}}(function(){return!o&&1},0,function(){return Promise.resolve(n.receive()).then(function(i){if(i.tag===r)return n.send(Se,t.UNSUBSCRIBE),void(o=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return t.send(n,r)}}function De(){return je(),t.send(Se,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Le,ke=function(e){return r.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Fe=function(){return{authenticate:Re,unauthenticate:Ae,authorization:be,signUserMessage:ge,verifyUserSignatures:he,subscribe:Ne,snapshot:De,resolveArgument:Ee}};Fe.authenticate=Re,Fe.unauthenticate=Ae,Fe.authorization=be,Fe.signUserMessage=ge,Fe.verifyUserSignatures=he,Fe.subscribe=Ne,Fe.snapshot=De,Fe.resolveArgument=Ee;var Te=function(r){try{return Promise.resolve(e.send([e.getTransactionStatus(r)]).then(e.decode))}catch(e){return Promise.reject(e)}},_e=function(e){return e.status>=4},Ue=function(e){return e.status>=3},Be=function(e){return e.status>=2},Me=((Le={})[t.INIT]=function(e){try{return Promise.resolve(Te(e.self())).then(function(r){_e(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},Le[t.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,t.UPDATED,e.all())},Le[t.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},Le[t.SNAPSHOT]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Le.POLL=function(e){try{return Promise.resolve(Te(e.self())).then(function(r){var n,o;_e(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),n=e.all(),o=r,JSON.stringify(n)!==JSON.stringify(o)&&e.broadcast(t.UPDATED,r),e.merge(r)})}catch(e){return Promise.reject(e)}},Le),Ve=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},ze=function(e){return t.spawn(Me,Ve(e))};function We(e){function r(r){return t.subscriber(Ve(e),ze,r)}function n(e){return function(n){void 0===n&&(n={});var t=n.suppress||!1;return new Promise(function(n,o){var i=r(function(r){r.statusCode&&!t?(o(r.errorMessage),i()):e(r)&&(n(r),i())})})}}return{snapshot:function(){return t.snapshoter(e,ze)},subscribe:r,onceFinalized:n(Be),onceExecuted:n(Ue),onceSealed:n(_e)}}We.isUnknown=function(e){return e.status>=0},We.isPending=function(e){return e.status>=1},We.isFinalized=Be,We.isExecuted=Ue,We.isSealed=_e,We.isExpired=function(e){return 5===e.status};var He,Ye=function(r){try{var n=setTimeout;return Promise.resolve(e.config().get("fcl.eventPollRate",1e4)).then(function(e){return n(function(){return r.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},Je=((He={}).TICK=function(r){try{if(!r.hasSubs())return Promise.resolve();var n=r.get("hwm"),t=function(){if(null==n){var t=r.put;return Promise.resolve(e.latestBlock()).then(function(e){t.call(r,"hwm",e);var n=r.put;return Promise.resolve(Ye(r)).then(function(e){n.call(r,"tick",e)})})}return Promise.resolve(e.latestBlock()).then(function(t){return r.put("hwm",t),Promise.resolve(e.send([e.getEvents(r.self(),n.height,t.height-1)]).then(e.decode)).then(function(e){for(var n,t=C(e);!(n=t()).done;)r.broadcast("UPDATED",n.value.data);var o=r.put;return Promise.resolve(Ye(r)).then(function(e){o.call(r,"tick",e)})})})}();return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},He[t.SUBSCRIBE]=function(e,r){try{var n=function(){e.subscribe(r.from)},t=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(Ye(e)).then(function(n){r.call(e,"tick",n)})}}();return Promise.resolve(t&&t.then?t.then(n):n())}catch(e){return Promise.reject(e)}},He[t.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},He),qe=function(e){return t.spawn(Je,e)},Ge=function(n){void 0===n&&(n=[]);try{return Promise.resolve(e.config.get("discovery.authn.endpoint")).then(function(t){return r.invariant(Boolean(t),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(e.config.get("discovery.authn.include",[])).then(function(e){var r=new URL(t);return fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:l,include:e})}).then(function(e){return e.json()}).then(function(e){return[].concat(n,e)})})})}catch(e){return Promise.reject(e)}};function $e(e){void 0===e&&(e=[]);var r=window.fcl_extensions||[];return[].concat(r,e)}var Ke,Xe=((Ke={})[t.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((r={type:"authn"},n=r.type,function(){var e=arguments;return function(r){return[].slice.call(e).reduce(function(e,r){return e.then(r)},Promise.resolve(r))}}(Ge,$e,function(e){return function(e,r){return void 0===e&&(e=[]),e.filter(function(e){return e.type===r})}(e,n)})([]))).then(function(r){e.put("results",r)})}catch(e){return Promise.reject(e)}var r,n},Ke[t.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,"UPDATED",w({},e.all()))},Ke[t.UNSUBSCRIBE]=function(e,r){return e.unsubscribe(r.from)},Ke.SNAPSHOT=function(e,r){try{return Promise.resolve(r.reply(w({},e.all())))}catch(e){return Promise.reject(e)}},Ke),Ze=function(){return t.spawn(Xe,"authn")},Qe={authn:{subscribe:function(e){return t.subscriber("authn",Ze,e)},snapshot:function(){return t.snapshoter("authn",Ze)}}},er=function(e,r){void 0===r&&(r=function(){});var n=function(n){var t=n.data;"object"==typeof t&&null!=typeof t&&t.type===e&&r(function(e){var r;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(r=e.body)||delete r.interaction,e}(t))};return window.addEventListener("message",n),function(){return window.removeEventListener("message",n)}},rr=function(e,r){void 0===r&&(r={}),window.location!==window.parent.location?window.parent.postMessage(w({},r,{type:e}),"*"):window.opener.postMessage(w({},r,{type:e}),"*")},nr=function(e){return Buffer.from(e.padStart(16,0),"hex")},tr=function(e){return Buffer.from(e,"hex")},or=function(e,n){var t=e.address,s=e.nonce,a=e.appIdentifier;void 0===n&&(n=!0),r.invariant(t,"Encode Message For Provable Authn Error: address must be defined"),r.invariant(s,"Encode Message For Provable Authn Error: nonce must be defined"),r.invariant(a,"Encode Message For Provable Authn Error: appIdentifier must be defined"),r.invariant(s.length>=64,"Encode Message For Provable Authn Error: nonce must be minimum of 32 bytes");var u,c=(u=Buffer.from("FLOW-V0.0-user").toString("hex"),Buffer.from(u.padEnd(64,0),"hex"));return n?Buffer.concat([c,i.encode([a,nr(o.sansPrefix(t)),tr(s)])]).toString("hex"):i.encode([a,nr(o.sansPrefix(t)),tr(s)]).toString("hex")},ir={__proto__:null,sendMsgToFCL:rr,ready:function(e,r){er("FCL:VIEW:READY:RESPONSE",e),rr("FCL:VIEW:READY")},close:function(){rr("FCL:VIEW:CLOSE")},approve:function(e){rr("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){rr("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){rr("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:er,encodeMessageFromSignable:e.encodeMessageFromSignable,CompositeSignature:function(e,r,n){this.f_type=A.f_type,this.f_vsn=A.f_vsn,this.addr=o.withPrefix(e),this.keyId=Number(r),this.signature=n},encodeAccountProof:or,injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},sr={__proto__:null,verifyAccountProof:function(n,t){var o=t.address,i=t.nonce,s=t.signatures;try{!function(e,n,t,o){r.invariant("string"==typeof e,"appIdentifier must be a string"),r.invariant(/^[0-9a-f]+$/i.test(t),"Nonce must be a hex string"),r.invariant(Array.isArray(o)&&o.every(function(e,r,n){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),r.invariant(o.map(function(e){return e.addr}).every(function(e,r,n){return e===n[0]}),"User signatures to be verified must be from a single account address")}(n,0,i,s);for(var a,u=or({address:o,nonce:i,appIdentifier:n},!1),c=[],d=[],f=C(s);!(a=f()).done;){var l=a.value;c.push(l.signature),d.push(l.keyId)}return Promise.resolve(function(){try{return Promise.resolve(e.config.get("env")).then(function(e){return"\n import FCLCrypto from "+("testnet"===e?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284")+"\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyAccountProofSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n "})}catch(e){return Promise.reject(e)}}()).then(function(e){return Promise.resolve(R({cadence:e,args:function(e,r){return[e(o,r.Address),e(u,r.String),e(d,r.Array([r.Int])),e(c,r.Array([r.String]))]}}))})}catch(e){return Promise.reject(e)}}},ar=Fe().authorization,ur=d;Object.defineProperty(exports,"TestUtils",{enumerable:!0,get:function(){return e.TestUtils}}),Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return e.account}}),Object.defineProperty(exports,"arg",{enumerable:!0,get:function(){return e.arg}}),Object.defineProperty(exports,"args",{enumerable:!0,get:function(){return e.args}}),Object.defineProperty(exports,"atBlockHeight",{enumerable:!0,get:function(){return e.atBlockHeight}}),Object.defineProperty(exports,"atBlockId",{enumerable:!0,get:function(){return e.atBlockId}}),Object.defineProperty(exports,"authorization",{enumerable:!0,get:function(){return e.authorization}}),Object.defineProperty(exports,"authorizations",{enumerable:!0,get:function(){return e.authorizations}}),Object.defineProperty(exports,"block",{enumerable:!0,get:function(){return e.block}}),Object.defineProperty(exports,"build",{enumerable:!0,get:function(){return e.build}}),Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return e.config}}),Object.defineProperty(exports,"createSignableVoucher",{enumerable:!0,get:function(){return e.createSignableVoucher}}),Object.defineProperty(exports,"decode",{enumerable:!0,get:function(){return e.decode}}),Object.defineProperty(exports,"getAccount",{enumerable:!0,get:function(){return e.getAccount}}),Object.defineProperty(exports,"getBlock",{enumerable:!0,get:function(){return e.getBlock}}),Object.defineProperty(exports,"getBlockByHeight",{enumerable:!0,get:function(){return e.getBlockByHeight}}),Object.defineProperty(exports,"getBlockById",{enumerable:!0,get:function(){return e.getBlockById}}),Object.defineProperty(exports,"getBlockHeader",{enumerable:!0,get:function(){return e.getBlockHeader}}),Object.defineProperty(exports,"getCollection",{enumerable:!0,get:function(){return e.getCollection}}),Object.defineProperty(exports,"getEvents",{enumerable:!0,get:function(){return e.getEvents}}),Object.defineProperty(exports,"getEventsAtBlockHeightRange",{enumerable:!0,get:function(){return e.getEventsAtBlockHeightRange}}),Object.defineProperty(exports,"getEventsAtBlockIds",{enumerable:!0,get:function(){return e.getEventsAtBlockIds}}),Object.defineProperty(exports,"getLatestBlock",{enumerable:!0,get:function(){return e.getLatestBlock}}),Object.defineProperty(exports,"getTransaction",{enumerable:!0,get:function(){return e.getTransaction}}),Object.defineProperty(exports,"getTransactionStatus",{enumerable:!0,get:function(){return e.getTransactionStatus}}),Object.defineProperty(exports,"invariant",{enumerable:!0,get:function(){return e.invariant}}),Object.defineProperty(exports,"isBad",{enumerable:!0,get:function(){return e.isBad}}),Object.defineProperty(exports,"isOk",{enumerable:!0,get:function(){return e.isOk}}),Object.defineProperty(exports,"latestBlock",{enumerable:!0,get:function(){return e.latestBlock}}),Object.defineProperty(exports,"limit",{enumerable:!0,get:function(){return e.limit}}),Object.defineProperty(exports,"param",{enumerable:!0,get:function(){return e.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return e.params}}),Object.defineProperty(exports,"payer",{enumerable:!0,get:function(){return e.payer}}),Object.defineProperty(exports,"ping",{enumerable:!0,get:function(){return e.ping}}),Object.defineProperty(exports,"pipe",{enumerable:!0,get:function(){return e.pipe}}),Object.defineProperty(exports,"proposer",{enumerable:!0,get:function(){return e.proposer}}),Object.defineProperty(exports,"ref",{enumerable:!0,get:function(){return e.ref}}),Object.defineProperty(exports,"script",{enumerable:!0,get:function(){return e.script}}),Object.defineProperty(exports,"send",{enumerable:!0,get:function(){return e.send}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return e.transaction}}),Object.defineProperty(exports,"validator",{enumerable:!0,get:function(){return e.validator}}),Object.defineProperty(exports,"voucherIntercept",{enumerable:!0,get:function(){return e.voucherIntercept}}),Object.defineProperty(exports,"voucherToTxId",{enumerable:!0,get:function(){return e.voucherToTxId}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return e.why}}),Object.defineProperty(exports,"display",{enumerable:!0,get:function(){return o.display}}),Object.defineProperty(exports,"sansPrefix",{enumerable:!0,get:function(){return o.sansPrefix}}),Object.defineProperty(exports,"withPrefix",{enumerable:!0,get:function(){return o.withPrefix}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return a.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return a.template}}),exports.AppUtils=sr,exports.VERSION=l,exports.WalletUtils=ir,exports.authenticate=function(e){return void 0===e&&(e={}),Fe().authenticate(e)},exports.authz=ar,exports.currentUser=Fe,exports.discovery=Qe,exports.events=function(e){return{subscribe:function(r){return t.subscriber(e,qe,r)}}},exports.logIn=function(e){return void 0===e&&(e={}),Fe().authenticate(e)},exports.mutate=function(e){void 0===e&&(e={});try{return Promise.resolve(function(n,t){try{var o=Promise.resolve(function(e){try{return r.invariant(m(e),"mutate(opts) -- opts is required"),r.invariant(y(e),"mutate(opts) -- opts must be an object"),r.invariant(m(e.cadence),"mutate({ cadence }) -- cadence is required"),r.invariant(g(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(c.config.get("accessNode.api")).then(function(e){r.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return Promise.resolve(c.config().get("fcl.authz",Fe().authorization)).then(function(r){return c.send([c.transaction(e.cadence),c.args(b(e.args||[])),e.limit&&E(e.limit)&&c.limit(e.limit),c.proposer(e.proposer||e.authz||r),c.payer(e.payer||e.authz||r),c.authorizations(e.authorizations||[e.authz||r])]).then(c.decode)})})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},exports.query=R,exports.reauthenticate=function(e){return void 0===e&&(e={}),Fe().unauthenticate(),Fe().authenticate(e)},exports.serialize=function(r,n){void 0===r&&(r=[]),void 0===n&&(n={});try{return Promise.resolve(e.config.first(["sdk.resolve"],n.resolve||e.resolve)).then(function(n){function t(){return Promise.resolve(n(r)).then(function(r){return JSON.stringify(e.createSignableVoucher(r),null,2)})}var o=function(){if(Array.isArray(r))return Promise.resolve(e.pipe(e.interaction(),r)).then(function(e){r=e})}();return o&&o.then?o.then(t):t()})}catch(e){return Promise.reject(e)}},exports.signUp=function(e){return void 0===e&&(e={}),Fe().authenticate(e)},exports.t=ur,exports.tx=We,exports.unauthenticate=function(){return Fe().unauthenticate()},exports.verifyUserSignatures=fe; | ||
//# sourceMappingURL=fcl.js.map |
@@ -1,2 +0,2 @@ | ||
import*as e from"@onflow/sdk";import{config as n,arg as t,send as r,getTransactionStatus as a,decode as s,resolve as o,pipe as i,interaction as c,createSignableVoucher as d,latestBlock as l,getEvents as u,encodeMessageFromSignable as p}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,block,build,config,createSignableVoucher,decode,getAccount,getBlock,getBlockByHeight,getBlockById,getBlockHeader,getCollection,getEvents,getEventsAtBlockHeightRange,getEventsAtBlockIds,getLatestBlock,getTransaction,getTransactionStatus,invariant,isBad,isOk,latestBlock,limit,param,params,payer,ping,pipe,proposer,ref,script,send,transaction,validator,voucherIntercept,voucherToTxId,why}from"@onflow/sdk";import{invariant as f}from"@onflow/util-invariant";import*as y from"@onflow/types";import{spawn as h,send as g,SUBSCRIBE as m,UNSUBSCRIBE as E,INIT as w,subscriber as R,snapshoter as v,UPDATED as S,SNAPSHOT as b}from"@onflow/util-actor";import{withPrefix as C,sansPrefix as A}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as P from"@onflow/rlp";import{encode as I}from"@onflow/rlp";import{uid as D}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";const L="0.0.79-alpha.3",N={can:!("undefined"==typeof window),get:async e=>JSON.parse(sessionStorage.getItem(e)),put:async(e,n)=>sessionStorage.setItem(e,JSON.stringify(n))};async function O(e){return Object.fromEntries(Object.entries(await n().where(e)).map(([n,t])=>[n.replace(e,""),t]))}n({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":N});const k=e=>n=>typeof n===e,F=e=>null!=e,x=k("object"),T=k("string"),_=k("function"),U=k("number");function V(n){return _(n)?n(e.arg,y):[]}async function M(n={}){return await async function(n){f(F(n.cadence),"query({ cadence }) -- cadence is required"),f(T(n.cadence),"query({ cadence }) -- cadence must be a string"),f(await e.config.get("accessNode.api"),'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')}(n),e.send([e.script(n.cadence),e.args(V(n.args||[])),n.limit&&"number"==typeof n.limit&&e.limit(n.limit)]).then(e.decode)}function H(){return H=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},H.apply(this,arguments)}const j={f_type:"Service",f_vsn:"1.0.0"},z={f_type:"Identity",f_vsn:"1.0.0"},W={f_type:"USER",f_vsn:"1.0.0"},B={f_type:"PollingResponse",f_vsn:"1.0.0"},K={f_type:"CompositeSignature",f_vsn:"1.0.0"};function Y(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({old:e},j,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function J(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},j,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function $(e){return null==e?null:(null==e.method&&(e=H({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:H({},j,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}const q={"back-channel-rpc":J,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},j,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:H({},z,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},j,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:H({},z,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},j,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:C(e.addr),name:e.name,icon:e.icon}})},frame:Y,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":$,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function G(e){return P.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}async function X(e){var n=function(e=[],n=[]){return[...e,...n]}((e=function(e){return e.addr=e.addr?C(e.addr):null,e.paddr=e.paddr?C(e.paddr):null,e}(e)).services||[],await async function(e,n){if(null==e||null==n)return[];const t=new URL(e);t.searchParams.append("code",n);const r=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json());if(Array.isArray(r))return r;const a=[];if(Array.isArray(r.authorizations))for(let e of r.authorizations)a.push(H({type:"authz",keyId:r.keyId},e));return null!=r.provider&&a.push(H({type:"authn",id:"wallet-provider#authn"},r.provider)),a}(e.hks,e.code)).map(n=>function(e,n){try{return q[e.type](e,n)}catch(n){return console.error(`Unrecognized FCL Service Type [${e.type}]`,e,n),e}}(n,e));const t=function(e,n){return n.find(e=>"authn"===e.type)}(0,n);return H({},W,{addr:C(e.addr),cid:G(t),loggedIn:!0,services:n,expiresAt:e.expires})}function Z(e=[],n){return e.find(e=>e.type===n)}function Q(e){const n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(let[t,r]of Object.entries(e.params||{}))n.searchParams.append(t,r);return n}function ee(e,n={}){const t=n.method||"POST",r="GET"===t?void 0:JSON.stringify(n.data||e.data||{});return fetch(Q(e),{method:t,headers:H({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:r}).then(e=>e.json())}function ne(e){var n,t;return null==e?null:"1.0.0"===e.f_vsn?e:H({},B,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(t=e.reason)?t:null,data:e.compositeSignature||e.data||H({},e)||{},updates:J(e.authorizationUpdates),local:Y((e.local||[])[0])})}const te={"HTTP/GET":"GET","HTTP/POST":"POST"},re=e=>(f(te[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),te[e.method]);async function ae(e,n=(()=>!0)){if(f(e,"Missing Polling Service",{service:e}),!n())throw new Error("Externally Halted");const t=await ee(e,{method:re(e)}).then(ne);switch(t.status){case"APPROVED":return t.data;case"DECLINED":throw new Error(`Declined: ${t.reason||"No reason supplied."}`);default:return await new Promise(e=>setTimeout(e,500)),ae(t.updates,n)}}const se="FCL_IFRAME";function oe(e){f(!document.getElementById(se),"Attempt at triggering multiple Frames",{src:e});const n=document.createElement("iframe");return n.src=e,n.id=se,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,()=>{document.getElementById(se)&&document.getElementById(se).remove()}]}let ie=null,ce=null;function de(e){var n,t;return null==ie||null!=(n=ie)&&n.closed?(t=window,ie=t.open(e,"FCL_POP",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top=${t.top.outerHeight/2+t.top.screenY-385}, left=${t.top.outerWidth/2+t.top.screenX-320}`)):ce!==e?(ie.location.replace(e),ie.focus()):ie.focus(),ce=e,[ie,()=>{ie&&!ie.closed&&ie.close(),ie=null}]}let le=null,ue=null;function pe(e){var n;return null==le||null!=(n=le)&&n.closed?le=window.open(e,"_blank"):ue!==e?(le.location.replace(e),le.focus()):le.focus(),ue=e,[le,()=>{le&&!le.closed&&le.close(),le=null}]}const fe={"VIEW/IFRAME":oe,"VIEW/POP":de,"VIEW/TAB":pe};async function ye(e,n,t,r){const a=await ee(e,{data:H({fclVersion:L,service:{params:e.params,data:e.data,type:e.type},config:r},n)}).then(ne);if("APPROVED"===a.status)return a.data;if("DECLINED"===a.status)throw new Error(`Declined: ${a.reason||"No reason supplied."}`);if("REDIRECT"===a.status)return a;if("PENDING"===a.status){var s=!0;const[e,n]=await async function(e,n={}){try{return fe[e.method](Q(e),n)}catch(t){throw console.error("execLocal({service, opts = {}})",t,{service:e,opts:n}),t}}($(a.local)),t=()=>{try{n(),s=!1}catch(e){console.error("Frame Close Error",e)}};return ae(a.updates,()=>s).then(e=>(t(),e)).catch(e=>{throw console.error(e),t(),e})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:a}),new Error("Auto Decline: Invalid Response")}const he=e=>"string"==typeof e&&e.toLowerCase(),ge=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),me=(e,n)=>console.warn("DEPRECATION NOTICE",`Received ${e}, please use ${n} for this and future versions of FCL`),Ee=({close:e,send:n,onReady:t,onResponse:r,onMessage:a})=>s=>{try{if("object"!=typeof s.data)return;if(ge.has(s.data.type))return;he(s.data.type)===he("FCL:VIEW:CLOSE")&&e(),he(s.data.type)===he("FCL:VIEW:READY")&&t(s,{send:n,close:e}),he(s.data.type)===he("FCL:VIEW:RESPONSE")&&r(s,{send:n,close:e}),a(s,{send:n,close:e}),he(s.data.type)===he("FCL:FRAME:READY")&&(me(s.data.type,"FCL:VIEW:READY"),t(s,{send:n,close:e})),he(s.data.type)===he("FCL:FRAME:RESPONSE")&&(me(s.data.type,"FCL:VIEW:RESPONSE"),r(s,{send:n,close:e})),he(s.data.type)===he("FCL:FRAME:CLOSE")&&(me(s.data.type,"FCL:VIEW:CLOSE"),e()),he(s.data.type)===he("FCL::CHALLENGE::RESPONSE")&&(me(s.data.type,"FCL:VIEW:RESPONSE"),r(s,{send:n,close:e})),he(s.data.type)===he("FCL::AUTHZ_READY")&&(me(s.data.type,"FCL:VIEW:READY"),t(s,{send:n,close:e})),he(s.data.type)===he("FCL::CHALLENGE::CANCEL")&&(me(s.data.type,"FCL:VIEW:CLOSE"),e()),he(s.data.type)===he("FCL::CANCEL")&&(me(s.data.type,"FCL:VIEW:CLOSE"),e())}catch(n){console.error("Frame Callback Error",n),e()}},we=()=>{},Re=()=>{},ve=()=>{},Se=()=>{},be={"HTTP/RPC":ye,"HTTP/POST":ye,"IFRAME/RPC":function(e,n,t,r){return new Promise((a,s)=>{var o;const i=D(),c=t.includeOlderJsonRpcCall;n.data=null!=(o=e.data)?o:null,function(e,n={}){if(null==e)return{send:we,close:we};const t=n.onClose||we;window.addEventListener("message",Ee({close:s,send:o,onReady:n.onReady||we,onResponse:n.onResponse||we,onMessage:n.onMessage||we}));const[r,a]=oe(Q(e));return{send:o,close:s};function s(){try{window.removeEventListener("message",Ee),a(),t()}catch(e){console.error("Frame Close Error",e)}}function o(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{async onReady(t,{send:a}){try{a({type:"FCL:VIEW:READY:RESPONSE",fclVersion:L,body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}},onResponse(e,{close:n}){try{if("object"!=typeof e.data)return;const t=ne(e.data);switch(t.status){case"APPROVED":a(t.data),n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage(e,{close:n}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;const t=ne(e.data.result);switch(t.status){case"APPROVED":a(t.data),n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,t,r){return new Promise((a,s)=>{const o=D(),{redir:i,includeOlderJsonRpcCall:c}=t;n.data=e.data,function(e,n={}){if(null==e)return{send:Re,close:Re};const t=n.onClose||Re;window.addEventListener("message",Ee({close:o,send:i,onReady:n.onReady||Re,onResponse:n.onResponse||Re,onMessage:n.onMessage||Re}));const[r,a]=de(Q(e)),s=setInterval(function(){r&&r.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",Ee),clearInterval(s),a(),t()}catch(e){console.error("Popup Close Error",e)}}function i(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{async onReady(t,{send:a}){try{a({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}},onResponse(e,{close:n}){try{if("object"!=typeof e.data)return;const t=ne(e.data);switch(t.status){case"APPROVED":a(t.data),!i&&n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage(e,{close:n}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==o)return;const t=ne(e.data.result);switch(t.status){case"APPROVED":a(t.data),!i&&n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,t,r){return new Promise((a,s)=>{const o=D(),{redir:i,includeOlderJsonRpcCall:c}=t;n.data=e.data,function(e,n={}){if(null==e)return{send:ve,close:ve};const t=n.onClose||ve;window.addEventListener("message",Ee({close:o,send:i,onReady:n.onReady||ve,onResponse:n.onResponse||ve,onMessage:n.onMessage||ve}));const[r,a]=pe(Q(e)),s=setInterval(function(){r&&r.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",Ee),clearInterval(s),a(),t()}catch(e){console.error("Tab Close Error",e)}}function i(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{async onReady(t,{send:a}){try{a({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}},onResponse(e,{close:n}){try{if("object"!=typeof e.data)return;const t=ne(e.data);switch(t.status){case"APPROVED":a(t.data),!i&&n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage(e,{close:n}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==o)return;const t=ne(e.data.result);switch(t.status){case"APPROVED":a(t.data),!i&&n();break;case"DECLINED":s(`Declined: ${t.reason||"No reason supplied"}`),n();break;case"REDIRECT":a(t),n();break;default:s("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,t,r){return new Promise((t,a)=>{!async function(e,n={}){var t;if(null==e)return{send:Se,close:Se};const{endpoint:r}=e,a=n.onClose||Se;window.addEventListener("message",Ee({close:function(){try{window.removeEventListener("message",Ee),a()}catch(e){console.error("Extension Close Error",e)}},send:function(e){try{var n;null==(n=window[r])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}},onReady:n.onReady||Se,onResponse:n.onResponse||Se,onMessage:n.onMessage||Se})),await(null==(t=window[r])?void 0:t.flow.enable())}(e,{async onReady(t,{send:a}){try{a({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r})}catch(e){throw e}},onResponse(e,{close:n}){try{if("object"!=typeof e.data)return;const r=ne(e.data);switch(r.status){case"APPROVED":t(r.data),n();break;case"DECLINED":a(`Declined: ${r.reason||"No reason supplied"}`),n();break;case"REDIRECT":t(r),n();break;default:a("Declined: No reason supplied"),n()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose(){a("Declined: Externally Halted")}})})}};async function Ce({service:e,msg:n={},opts:t={},config:r={}}){const a=H({},r,{services:await O(/^service\./),app:await O(/^app\.detail\./)});try{const r=await be[e.method](e,n,t,a);return"REDIRECT"===r.status?(f(e.type===r.data.type,"Cannot shift recursive service type in execService"),await Ce({service:r.data,msg:n,opts:t,config:a})):r}catch(a){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",a,{service:e,msg:n,opts:t,config:r}),a}}async function Ae(e,n){((e,n)=>{f(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),f(Array.isArray(n)&&n.every((e,n,t)=>"CompositeSignature"===e.f_type),"Must include an Array of CompositeSignatures to verify"),f(n.map(e=>e.addr).every((e,n,t)=>e===t[0]),"User signatures to be verified must be from a single account address")})(e,n);const t=n[0].addr;let r=[],a=[];return n.map(e=>{r.push(e.signature),a.push(e.keyId)}),await M({cadence:Pe,args:(n,s)=>[n(t,s.Address),n(e,s.String),n(a,s.Array([s.Int])),n(r,s.Array([s.String]))]})}const Pe='\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\n\n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_secp256k1 : SignatureAlgorithm.ECDSA_P256\n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i]\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n';function Ie(e){return null==e?null:"1.0.0"===e.f_vsn?e:H({},K,{addr:A(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}const De="CURRENT_USER",Le="CURRENT_USER/UPDATED",Ne='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Oe={[w]:async e=>{"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(Ne));const t=await n.first(["fcl.storage","fcl.storage.default"]);if(t.can){const n=await(async e=>{const n=JSON.parse(Ne),t=await e.get(De);return null!=t&&n.f_vsn!==t.f_vsn?(e.removeItem(De),n):t||n})(t);(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(n)&&e.merge(n)}},[m]:(e,n)=>{e.subscribe(n.from),e.send(n.from,Le,H({},e.all()))},[E]:(e,n)=>{e.unsubscribe(n.from)},SNAPSHOT:async(e,n)=>{n.reply(H({},e.all()))},SET_CURRENT_USER:async(e,t,r)=>{e.merge(r);const a=await n.first(["fcl.storage","fcl.storage.default"]);a.can&&a.put(De,e.all()),e.broadcast(Le,H({},e.all()))},DEL_CURRENT_USER:async(e,t)=>{e.merge(JSON.parse(Ne));const r=await n.first(["fcl.storage","fcl.storage.default"]);r.can&&r.put(De,e.all()),e.broadcast(Le,H({},e.all()))}},ke=()=>h(Oe,De);async function Fe({service:e,redir:t=!1}={}){return new Promise(async(r,a)=>{ke();const s=await Ue(),o=await async function(){return{timestamp:Date.now(),appDomainTag:await n.get("fcl.appDomainTag"),extensions:window.fcl_extensions||[]}}(),i={redir:t},c=await async function(){const e=await n.first(["discovery.wallet","challenge.handshake"]),t=await n.get("discovery.authn.include",[]);return{type:"authn",endpoint:e,method:await n.first(["discovery.wallet.method","discovery.wallet.method.default"]),discoveryAuthnInclude:t}}(),d=Z(s.services,"authn-refresh"),l=await n.get("fcl.warning.suppress.redir");if(t&&!l&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config"),f(e||c.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n '),s.loggedIn){if(!d)return r(s);try{const e=await Ce({service:d,msg:o,opts:i});g(De,"SET_CURRENT_USER",await X(e))}catch(e){console.error("Error: Could not refresh authentication.",e)}finally{return r(await Ue())}}try{const n=await Ce({service:H({},e||c,{method:(null==c?void 0:c.method)||e.method||"IFRAME/RPC"}),msg:o,opts:i,config:{discoveryAuthnInclude:c.discoveryAuthnInclude}});g(De,"SET_CURRENT_USER",await X(n))}catch(e){console.error("Error while authenticating",e)}finally{r(await Ue())}})}function xe(){ke(),g(De,"DEL_CURRENT_USER")}async function Te(e){return ke(),H({},e,{tempId:"CURRENT_USER",async resolve(e,n){const t=await Fe({redir:!0}),r=Z(t.services,"authz"),a=Z(t.services,"pre-authz");if(a)return function(e){const n=(e=>({f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}))(e),t=[];null!=n.proposer&&t.push(["PROPOSER",n.proposer]);for(let e of n.payer||[])t.push(["PAYER",e]);for(let e of n.authorization||[])t.push(["AUTHORIZER",e]);return t.map(([e,n])=>({tempId:[n.identity.address,n.identity.keyId].join("|"),addr:n.identity.address,keyId:n.identity.keyId,signingFunction:e=>Ce({service:n,msg:e}),role:{proposer:"PROPOSER"===e,payer:"PAYER"===e,authorizer:"AUTHORIZER"===e}}))}(await Ce({service:a,msg:n}));if(r)return H({},e,{tempId:"CURRENT_USER",resolve:null,addr:A(r.identity.address),keyId:r.identity.keyId,sequenceNum:null,signature:null,signingFunction:async e=>Ie(await Ce({service:r,msg:e,opts:{includeOlderJsonRpcCall:!0}}))});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}})}function _e(e){ke();const n="@EXIT",t=h(async t=>{for(t.send(De,m);;){const r=await t.receive();if(r.tag===n)return void t.send(De,E);e(r.data)}});return()=>g(t,n)}function Ue(){return ke(),g(De,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function Ve(){const{addr:e}=await Fe();return t(C(e),y.Address)}const Me=e=>(f(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e});async function He(e){ke();const n=Z((await Fe({redir:!0})).services,"user-signature");f(n,"Current user must have authorized a signing service.");try{const t=await Ce({service:n,msg:Me(e)});return Array.isArray(t)?t.map(e=>Ie(e)):[Ie(t)]}catch(e){return e}}async function je(e,n){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Ae(e,n)}let ze=()=>({authenticate:Fe,unauthenticate:xe,authorization:Te,signUserMessage:He,verifyUserSignatures:je,subscribe:_e,snapshot:Ue,resolveArgument:Ve});ze.authenticate=Fe,ze.unauthenticate=xe,ze.authorization=Te,ze.signUserMessage=He,ze.verifyUserSignatures=je,ze.subscribe=_e,ze.snapshot=Ue,ze.resolveArgument=Ve;const We=async e=>r([a(e)]).then(s),Be=e=>e.status>=4,Ke=e=>e.status>=3,Ye=e=>e.status>=2,Je={[w]:async e=>{const n=await We(e.self());Be(n)||setTimeout(()=>e.sendSelf("POLL"),2500),e.merge(n)},[m]:(e,n)=>{e.subscribe(n.from),e.send(n.from,S,e.all())},[E]:(e,n)=>{e.unsubscribe(n.from)},[b]:async(e,n)=>{n.reply(e.all())},POLL:async e=>{const n=await We(e.self());var t,r;Be(n)||setTimeout(()=>e.sendSelf("POLL"),2500),t=e.all(),r=n,JSON.stringify(t)!==JSON.stringify(r)&&e.broadcast(S,n),e.merge(n)}},$e=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},qe=e=>h(Je,$e(e));function Ge(e){function n(n){return R($e(e),qe,n)}function t(e){return function(t={}){const r=t.suppress||!1;return new Promise((t,a)=>{const s=n(n=>{n.statusCode&&!r?(a(n.errorMessage),s()):e(n)&&(t(n),s())})})}}return{snapshot:function(){return v(e,qe)},subscribe:n,onceFinalized:t(Ye),onceExecuted:t(Ke),onceSealed:t(Be)}}async function Xe(n={}){var t;try{await async function(n){f(F(n),"mutate(opts) -- opts is required"),f(x(n),"mutate(opts) -- opts must be an object"),f(F(n.cadence),"mutate({ cadence }) -- cadence is required"),f(T(n.cadence),"mutate({ cadence }) -- cadence must be a string"),f(await e.config.get("accessNode.api"),'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')}(n);const r=await e.config().get("fcl.authz",ze().authorization);return t=e.send([e.transaction(n.cadence),e.args(V(n.args||[])),n.limit&&U(n.limit)&&e.limit(n.limit),e.proposer(n.proposer||n.authz||r),e.payer(n.payer||n.authz||r),e.authorizations(n.authorizations||[n.authz||r])]).then(e.decode),t}catch(e){throw e}}Ge.isUnknown=e=>e.status>=0,Ge.isPending=e=>e.status>=1,Ge.isFinalized=Ye,Ge.isExecuted=Ke,Ge.isSealed=Be,Ge.isExpired=e=>5===e.status;const Ze=async(e=[],t={})=>{const r=await n.first(["sdk.resolve"],t.resolve||o);return Array.isArray(e)&&(e=await i(c(),e)),JSON.stringify(d(await r(e)),null,2)},Qe=async e=>setTimeout(()=>e.sendSelf("TICK"),await n().get("fcl.eventPollRate",1e4)),en={TICK:async e=>{if(!e.hasSubs())return;let n=e.get("hwm");if(null==n)e.put("hwm",await l()),e.put("tick",await Qe(e));else{let t=await l();e.put("hwm",t);const a=await r([u(e.self(),n.height,t.height-1)]).then(s);for(let n of a)e.broadcast("UPDATED",n.data);e.put("tick",await Qe(e))}},[m]:async(e,n)=>{e.hasSubs()||e.put("tick",await Qe(e)),e.subscribe(n.from)},[E]:(e,n)=>{e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))}},nn=e=>h(en,e);function tn(e){return{subscribe:n=>R(e,nn,n)}}async function rn(e=[]){const t=await n.get("discovery.authn.endpoint");f(Boolean(t),'"discovery.authn.endpoint" in config must be defined.');const r=await n.get("discovery.authn.include",[]),a=new URL(t);return fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:L,include:r})}).then(e=>e.json()).then(n=>[...e,...n])}function an(e=[]){return[...window.fcl_extensions||[],...e]}const sn={[w]:async e=>{"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;");const n=await(({type:e})=>((...e)=>n=>e.reduce((e,n)=>e.then(n),Promise.resolve(n)))(rn,an,n=>function(e=[],n){return e.filter(e=>e.type===n)}(n,e))([]))({type:"authn"});e.put("results",n)},[m]:(e,n)=>{e.subscribe(n.from),e.send(n.from,"UPDATED",H({},e.all()))},[E]:(e,n)=>e.unsubscribe(n.from),SNAPSHOT:async(e,n)=>n.reply(H({},e.all()))},on=()=>h(sn,"authn"),cn={authn:{subscribe:e=>R("authn",on,e),snapshot:()=>v("authn",on)}},dn=(e,n=(()=>{}))=>{const t=t=>{const{data:r}=t;"object"==typeof r&&null!=typeof r&&r.type===e&&n((e=>{var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e})(r))};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},ln=(e,n={})=>{window.location!==window.parent.location?window.parent.postMessage(H({},n,{type:e}),"*"):window.opener.postMessage(H({},n,{type:e}),"*")},un=(e,n)=>Buffer.from(e.padEnd(2*n,0),"hex");var pn={__proto__:null,sendMsgToFCL:ln,ready:(e,n={})=>{dn("FCL:VIEW:READY:RESPONSE",e),ln("FCL:VIEW:READY")},close:()=>{ln("FCL:VIEW:CLOSE")},approve:e=>{ln("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:e=>{ln("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:e=>{ln("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:dn,encodeMessageFromSignable:p,CompositeSignature:function(e,n,t){this.f_type=K.f_type,this.f_vsn=K.f_vsn,this.addr=C(e),this.keyId=Number(n),this.signature=t},encodeMessageForProvableAuthnSigning:(e,n,t="")=>{f(e,"Encode Message From Provable Authn Error: address must be defined"),f(n,"Encode Message From Provable Authn Error: timestamp must be defined");const r=un(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),a=un(Buffer.from(t).toString("hex"),32).toString("hex");return r+(t?I([a,C(e),n]).toString("hex"):I([C(e),n]).toString("hex"))},encodeMessageForProvableAuthnVerifying:(e,n,t="")=>{f(e,"Encode Message From Provable Authn Error: address must be defined"),f(n,"Encode Message From Provable Authn Error: timestamp must be defined");const r=t?(a=Buffer.from(t).toString("hex"),Buffer.from(a.padEnd(64,0),"hex")).toString("hex"):null;var a;return t?I([r,C(e),n]).toString("hex"):I([C(e),n]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}};const fn=(e={})=>ze().authenticate(e),yn=()=>ze().unauthenticate(),hn=(e={})=>(ze().unauthenticate(),ze().authenticate(e)),gn=(e={})=>ze().authenticate(e),mn=(e={})=>ze().authenticate(e),En=ze().authorization,wn=y;export{L as VERSION,pn as WalletUtils,fn as authenticate,En as authz,ze as currentUser,cn as discovery,tn as events,mn as logIn,Xe as mutate,M as query,hn as reauthenticate,Ze as serialize,gn as signUp,wn as t,Ge as tx,yn as unauthenticate,Ae as verifyUserSignatures}; | ||
import*as e from"@onflow/sdk";import{config as t,arg as n,send as r,getTransactionStatus as a,decode as s,resolve as o,pipe as i,interaction as c,createSignableVoucher as d,latestBlock as l,getEvents as u,encodeMessageFromSignable as p}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,block,build,config,createSignableVoucher,decode,getAccount,getBlock,getBlockByHeight,getBlockById,getBlockHeader,getCollection,getEvents,getEventsAtBlockHeightRange,getEventsAtBlockIds,getLatestBlock,getTransaction,getTransactionStatus,invariant,isBad,isOk,latestBlock,limit,param,params,payer,ping,pipe,proposer,ref,script,send,transaction,validator,voucherIntercept,voucherToTxId,why}from"@onflow/sdk";import{invariant as f}from"@onflow/util-invariant";import*as y from"@onflow/types";import{spawn as m,send as E,SUBSCRIBE as h,UNSUBSCRIBE as g,INIT as w,subscriber as R,snapshoter as v,UPDATED as S,SNAPSHOT as b}from"@onflow/util-actor";import{withPrefix as C,sansPrefix as I}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as P from"@onflow/rlp";import{encode as A}from"@onflow/rlp";import{uid as N}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";const D="0.0.79-alpha.4",L={can:!("undefined"==typeof window),get:async e=>JSON.parse(sessionStorage.getItem(e)),put:async(e,t)=>sessionStorage.setItem(e,JSON.stringify(t))};async function O(e){return Object.fromEntries(Object.entries(await t().where(e)).map(([t,n])=>[t.replace(e,""),n]))}t({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":L});const F=e=>t=>typeof t===e,T=e=>null!=e,k=F("object"),_=F("string"),x=F("function"),U=F("number");function M(t){return x(t)?t(e.arg,y):[]}async function V(t={}){return await async function(t){f(T(t.cadence),"query({ cadence }) -- cadence is required"),f(_(t.cadence),"query({ cadence }) -- cadence must be a string"),f(await e.config.get("accessNode.api"),'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')}(t),e.send([e.script(t.cadence),e.args(M(t.args||[])),t.limit&&"number"==typeof t.limit&&e.limit(t.limit)]).then(e.decode)}function z(){return z=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},z.apply(this,arguments)}const j={f_type:"Service",f_vsn:"1.0.0"},W={f_type:"Identity",f_vsn:"1.0.0"},B={f_type:"USER",f_vsn:"1.0.0"},Y={f_type:"PollingResponse",f_vsn:"1.0.0"},H={f_type:"CompositeSignature",f_vsn:"1.0.0"};function J(e){return null==e?null:"1.0.0"===e.f_vsn?e:z({old:e},j,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function $(e){return null==e?null:"1.0.0"===e.f_vsn?e:z({},j,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function q(e){return null==e?null:(null==e.method&&(e=z({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:z({},j,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}const G={"back-channel-rpc":$,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:z({},j,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:z({},W,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:z({},j,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:z({},W,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:z({},j,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:C(e.addr),name:e.name,icon:e.icon}})},frame:J,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":q,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("FCL Normalizer Error: Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function K(e){return P.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}async function X(e){var t=function(e=[],t=[]){return[...e,...t]}((e=function(e){return e.addr=e.addr?C(e.addr):null,e.paddr=e.paddr?C(e.paddr):null,e}(e)).services||[],await async function(e,t){if(null==e||null==t)return[];const n=new URL(e);n.searchParams.append("code",t);const r=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json());if(Array.isArray(r))return r;const a=[];if(Array.isArray(r.authorizations))for(let e of r.authorizations)a.push(z({type:"authz",keyId:r.keyId},e));return null!=r.provider&&a.push(z({type:"authn",id:"wallet-provider#authn"},r.provider)),a}(e.hks,e.code)).map(t=>function(e,t){try{return G[e.type](e,t)}catch(t){return console.error(`Unrecognized FCL Service Type [${e.type}]`,e,t),e}}(t,e));const n=function(e,t){return t.find(e=>"authn"===e.type)}(0,t);return z({},B,{addr:C(e.addr),cid:K(n),loggedIn:!0,services:t,expiresAt:e.expires})}function Z(e=[],t){return e.find(e=>e.type===t)}function Q(e){const t=new URL(e.endpoint);if(t.searchParams.append("l6n",window.location.origin),null!=e.params)for(let[n,r]of Object.entries(e.params||{}))t.searchParams.append(n,r);return t}function ee(e,t={}){const n=t.method||"POST",r="GET"===n?void 0:JSON.stringify(t.data||e.data||{});return fetch(Q(e),{method:n,headers:z({},e.headers||{},t.headers||{},{"Content-Type":"application/json"}),body:r}).then(e=>e.json())}function te(e){var t,n;return null==e?null:"1.0.0"===e.f_vsn?e:z({},Y,{status:null!=(t=e.status)?t:"APPROVED",reason:null!=(n=e.reason)?n:null,data:e.compositeSignature||e.data||z({},e)||{},updates:$(e.authorizationUpdates),local:J((e.local||[])[0])})}const ne={"HTTP/GET":"GET","HTTP/POST":"POST"},re=e=>(f(ne[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),ne[e.method]);async function ae(e,t=(()=>!0)){if(f(e,"Missing Polling Service",{service:e}),!t())throw new Error("Externally Halted");const n=await ee(e,{method:re(e)}).then(te);switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error(`Declined: ${n.reason||"No reason supplied."}`);default:return await new Promise(e=>setTimeout(e,500)),ae(n.updates,t)}}const se="FCL_IFRAME";function oe(e){f(!document.getElementById(se),"Attempt at triggering multiple Frames",{src:e});const t=document.createElement("iframe");return t.src=e,t.id=se,t.allow="usb *; hid *",t.frameBorder="0",t.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(t),[t.contentWindow,()=>{document.getElementById(se)&&document.getElementById(se).remove()}]}let ie=null,ce=null;function de(e){var t,n;return null==ie||null!=(t=ie)&&t.closed?(n=window,ie=n.open(e,"FCL_POP",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top=${n.top.outerHeight/2+n.top.screenY-385}, left=${n.top.outerWidth/2+n.top.screenX-320}`)):ce!==e?(ie.location.replace(e),ie.focus()):ie.focus(),ce=e,[ie,()=>{ie&&!ie.closed&&ie.close(),ie=null}]}let le=null,ue=null;function pe(e){var t;return null==le||null!=(t=le)&&t.closed?le=window.open(e,"_blank"):ue!==e?(le.location.replace(e),le.focus()):le.focus(),ue=e,[le,()=>{le&&!le.closed&&le.close(),le=null}]}const fe={"VIEW/IFRAME":oe,"VIEW/POP":de,"VIEW/TAB":pe};async function ye(e,t,n,r){const a=await ee(e,{data:z({fclVersion:D,service:{params:e.params,data:e.data,type:e.type},config:r},t)}).then(te);if("APPROVED"===a.status)return a.data;if("DECLINED"===a.status)throw new Error(`Declined: ${a.reason||"No reason supplied."}`);if("REDIRECT"===a.status)return a;if("PENDING"===a.status){var s=!0;const[e,t]=await async function(e,t={}){try{return fe[e.method](Q(e),t)}catch(n){throw console.error("execLocal({service, opts = {}})",n,{service:e,opts:t}),n}}(q(a.local)),n=()=>{try{t(),s=!1}catch(e){console.error("Frame Close Error",e)}};return ae(a.updates,()=>s).then(e=>(n(),e)).catch(e=>{throw console.error(e),n(),e})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:a}),new Error("Auto Decline: Invalid Response")}const me=e=>"string"==typeof e&&e.toLowerCase(),Ee=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),he=(e,t)=>console.warn("DEPRECATION NOTICE",`Received ${e}, please use ${t} for this and future versions of FCL`),ge=({close:e,send:t,onReady:n,onResponse:r,onMessage:a})=>s=>{try{if("object"!=typeof s.data)return;if(Ee.has(s.data.type))return;me(s.data.type)===me("FCL:VIEW:CLOSE")&&e(),me(s.data.type)===me("FCL:VIEW:READY")&&n(s,{send:t,close:e}),me(s.data.type)===me("FCL:VIEW:RESPONSE")&&r(s,{send:t,close:e}),a(s,{send:t,close:e}),me(s.data.type)===me("FCL:FRAME:READY")&&(he(s.data.type,"FCL:VIEW:READY"),n(s,{send:t,close:e})),me(s.data.type)===me("FCL:FRAME:RESPONSE")&&(he(s.data.type,"FCL:VIEW:RESPONSE"),r(s,{send:t,close:e})),me(s.data.type)===me("FCL:FRAME:CLOSE")&&(he(s.data.type,"FCL:VIEW:CLOSE"),e()),me(s.data.type)===me("FCL::CHALLENGE::RESPONSE")&&(he(s.data.type,"FCL:VIEW:RESPONSE"),r(s,{send:t,close:e})),me(s.data.type)===me("FCL::AUTHZ_READY")&&(he(s.data.type,"FCL:VIEW:READY"),n(s,{send:t,close:e})),me(s.data.type)===me("FCL::CHALLENGE::CANCEL")&&(he(s.data.type,"FCL:VIEW:CLOSE"),e()),me(s.data.type)===me("FCL::CANCEL")&&(he(s.data.type,"FCL:VIEW:CLOSE"),e())}catch(t){console.error("Frame Callback Error",t),e()}},we=()=>{},Re=()=>{},ve=()=>{},Se=()=>{},be={"HTTP/RPC":ye,"HTTP/POST":ye,"IFRAME/RPC":function(e,t,n,r){return new Promise((a,s)=>{const o=N(),i=n.includeOlderJsonRpcCall;!function(e,t={}){if(null==e)return{send:we,close:we};const n=t.onClose||we;window.addEventListener("message",ge({close:s,send:o,onReady:t.onReady||we,onResponse:t.onResponse||we,onMessage:t.onMessage||we}));const[r,a]=oe(Q(e));return{send:o,close:s};function s(){try{window.removeEventListener("message",ge),a(),n()}catch(e){console.error("Frame Close Error",e)}}function o(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Frame Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({type:"FCL:VIEW:READY:RESPONSE",fclVersion:D,body:t,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:D,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),i&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const n=te(e.data);switch(n.status){case"APPROVED":a(n.data),t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage(e,{close:t}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==o)return;const n=te(e.data.result);switch(n.status){case"APPROVED":a(n.data),t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"POP/RPC":function(e,t,n,r){return new Promise((a,s)=>{const o=N(),{redir:i,includeOlderJsonRpcCall:c}=n;!function(e,t={}){if(null==e)return{send:Re,close:Re};const n=t.onClose||Re;window.addEventListener("message",ge({close:o,send:i,onReady:t.onReady||Re,onResponse:t.onResponse||Re,onMessage:t.onMessage||Re}));const[r,a]=de(Q(e)),s=setInterval(function(){r&&r.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",ge),clearInterval(s),a(),n()}catch(e){console.error("Popup Close Error",e)}}function i(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Popup Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({fclVersion:D,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:D,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params]})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const n=te(e.data);switch(n.status){case"APPROVED":a(n.data),!i&&t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage(e,{close:t}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==o)return;const n=te(e.data.result);switch(n.status){case"APPROVED":a(n.data),!i&&t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"TAB/RPC":function(e,t,n,r){return new Promise((a,s)=>{const o=N(),{redir:i,includeOlderJsonRpcCall:c}=n;!function(e,t={}){if(null==e)return{send:ve,close:ve};const n=t.onClose||ve;window.addEventListener("message",ge({close:o,send:i,onReady:t.onReady||ve,onResponse:t.onResponse||ve,onMessage:t.onMessage||ve}));const[r,a]=pe(Q(e)),s=setInterval(function(){r&&r.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",ge),clearInterval(s),a(),n()}catch(e){console.error("Tab Close Error",e)}}function i(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Tab Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({fclVersion:D,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:D,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params]})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const n=te(e.data);switch(n.status){case"APPROVED":a(n.data),!i&&t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage(e,{close:t}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==o)return;const n=te(e.data.result);switch(n.status){case"APPROVED":a(n.data),!i&&t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"EXT/RPC":function(e,t,n,r){return new Promise((n,a)=>{!async function(e,t={}){var n;if(null==e)return{send:Se,close:Se};const{endpoint:r}=e,a=t.onClose||Se;window.addEventListener("message",ge({close:function(){try{window.removeEventListener("message",ge),a()}catch(e){console.error("Extension Close Error",e)}},send:function(e){try{var t;null==(t=window[r])||t.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(t){console.error("Extension Send Error",e,t)}},onReady:t.onReady||Se,onResponse:t.onResponse||Se,onMessage:t.onMessage||Se})),await(null==(n=window[r])?void 0:n.flow.enable())}(e,{async onReady(n,{send:a}){try{a({fclVersion:D,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const r=te(e.data);switch(r.status){case"APPROVED":n(r.data),t();break;case"DECLINED":a(`Declined: ${r.reason||"No reason supplied"}`),t();break;case"REDIRECT":n(r),t();break;default:a("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose(){a("Declined: Externally Halted")}})})}};async function Ce({service:e,msg:t={},opts:n={},config:r={}}){t.extensions=window.fcl_extensions||[],t.data=e.data;const a=z({},r,{services:await O(/^service\./),app:await O(/^app\.detail\./)});try{const r=await be[e.method](e,t,n,a);return"REDIRECT"===r.status?(f(e.type===r.data.type,"Cannot shift recursive service type in execService"),await Ce({service:r.data,msg:t,opts:n,config:a})):r}catch(a){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",a,{service:e,msg:t,opts:n,config:r}),a}}async function Ie(e,n){((e,t)=>{f(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),f(Array.isArray(t)&&t.every((e,t,n)=>"CompositeSignature"===e.f_type),"Must include an Array of CompositeSignatures to verify"),f(t.map(e=>e.addr).every((e,t,n)=>e===n[0]),"User signatures to be verified must be from a single account address")})(e,n);const r=n[0].addr;let a=[],s=[];for(const e of n)a.push(e.signature),s.push(e.keyId);return await V({cadence:await(async()=>`\n import FCLCrypto from ${"testnet"===await t.get("env")?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284"}\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyUserSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n `)(),args:(t,n)=>[t(r,n.Address),t(e,n.String),t(s,n.Array([n.Int])),t(a,n.Array([n.String]))]})}function Pe(e){return null==e?null:"1.0.0"===e.f_vsn?e:z({},H,{addr:I(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}const Ae="CURRENT_USER",Ne="CURRENT_USER/UPDATED",De='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Le={[w]:async e=>{"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(De));const n=await t.first(["fcl.storage","fcl.storage.default"]);if(n.can){const t=await(async e=>{const t=JSON.parse(De),n=await e.get(Ae);return null!=n&&t.f_vsn!==n.f_vsn?(e.removeItem(Ae),t):n||t})(n);(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(t)&&e.merge(t)}},[h]:(e,t)=>{e.subscribe(t.from),e.send(t.from,Ne,z({},e.all()))},[g]:(e,t)=>{e.unsubscribe(t.from)},SNAPSHOT:async(e,t)=>{t.reply(z({},e.all()))},SET_CURRENT_USER:async(e,n,r)=>{e.merge(r);const a=await t.first(["fcl.storage","fcl.storage.default"]);a.can&&a.put(Ae,e.all()),e.broadcast(Ne,z({},e.all()))},DEL_CURRENT_USER:async(e,n)=>{e.merge(JSON.parse(De));const r=await t.first(["fcl.storage","fcl.storage.default"]);r.can&&r.put(Ae,e.all()),e.broadcast(Ne,z({},e.all()))}},Oe=()=>m(Le,Ae);async function Fe({service:e,redir:n=!1}={}){return new Promise(async(r,a)=>{Oe();const s={redir:n},o=await xe(),i=await async function(){const e=await t.first(["discovery.wallet","challenge.handshake"]),n=await t.get("discovery.authn.include",[]);return{type:"authn",endpoint:e,method:await t.first(["discovery.wallet.method","discovery.wallet.method.default"]),discoveryAuthnInclude:n}}(),c=Z(o.services,"authn-refresh");let d;try{d=await async function(){const e=await t.get("fcl.accountProof.resolver"),n=null!=e?e:await e();if(null!=n)return f("string"==typeof n.appIdentifier,"appIdentifier must be a string"),f(/^[0-9a-f]+$/i.test(n.nonce),"Nonce must be a hex string"),n}()}catch(e){return console.error(`Error During Authentication: Could not resolve account proof data.\n ${e}`),a(e)}if(f(e||i.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n '),o.loggedIn){if(!c)return r(o);try{const e=await Ce({service:c,msg:d,opts:s});E(Ae,"SET_CURRENT_USER",await X(e))}catch(e){console.error("Error: Could not refresh authentication.",e)}finally{return r(await xe())}}try{const t=await Ce({service:z({},e||i,{method:(null==i?void 0:i.method)||e.method||"IFRAME/RPC"}),msg:d,opts:s,config:{discoveryAuthnInclude:i.discoveryAuthnInclude}});E(Ae,"SET_CURRENT_USER",await X(t))}catch(e){console.error("Error while authenticating",e)}finally{r(await xe())}})}function Te(){Oe(),E(Ae,"DEL_CURRENT_USER")}async function ke(e){return Oe(),z({},e,{tempId:"CURRENT_USER",async resolve(e,t){const n=await Fe({redir:!0}),r=Z(n.services,"authz"),a=Z(n.services,"pre-authz");if(a)return function(e){const t=(e=>({f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}))(e),n=[];null!=t.proposer&&n.push(["PROPOSER",t.proposer]);for(let e of t.payer||[])n.push(["PAYER",e]);for(let e of t.authorization||[])n.push(["AUTHORIZER",e]);return n.map(([e,t])=>({tempId:[t.identity.address,t.identity.keyId].join("|"),addr:t.identity.address,keyId:t.identity.keyId,signingFunction:e=>Ce({service:t,msg:e}),role:{proposer:"PROPOSER"===e,payer:"PAYER"===e,authorizer:"AUTHORIZER"===e}}))}(await Ce({service:a,msg:t}));if(r)return z({},e,{tempId:"CURRENT_USER",resolve:null,addr:I(r.identity.address),keyId:r.identity.keyId,sequenceNum:null,signature:null,signingFunction:async e=>Pe(await Ce({service:r,msg:e,opts:{includeOlderJsonRpcCall:!0}}))});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}})}function _e(e){Oe();const t="@EXIT",n=m(async n=>{for(n.send(Ae,h);;){const r=await n.receive();if(r.tag===t)return void n.send(Ae,g);e(r.data)}});return()=>E(n,t)}function xe(){return Oe(),E(Ae,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function Ue(){const{addr:e}=await Fe();return n(C(e),y.Address)}const Me=e=>(f(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e});async function Ve(e){Oe();const t=Z((await Fe({redir:!0})).services,"user-signature");f(t,"Current user must have authorized a signing service.");try{const n=await Ce({service:t,msg:Me(e)});return Array.isArray(n)?n.map(e=>Pe(e)):[Pe(n)]}catch(e){return e}}async function ze(e,t){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Ie(e,t)}let je=()=>({authenticate:Fe,unauthenticate:Te,authorization:ke,signUserMessage:Ve,verifyUserSignatures:ze,subscribe:_e,snapshot:xe,resolveArgument:Ue});je.authenticate=Fe,je.unauthenticate=Te,je.authorization=ke,je.signUserMessage=Ve,je.verifyUserSignatures=ze,je.subscribe=_e,je.snapshot=xe,je.resolveArgument=Ue;const We=async e=>r([a(e)]).then(s),Be=e=>e.status>=4,Ye=e=>e.status>=3,He=e=>e.status>=2,Je={[w]:async e=>{const t=await We(e.self());Be(t)||setTimeout(()=>e.sendSelf("POLL"),2500),e.merge(t)},[h]:(e,t)=>{e.subscribe(t.from),e.send(t.from,S,e.all())},[g]:(e,t)=>{e.unsubscribe(t.from)},[b]:async(e,t)=>{t.reply(e.all())},POLL:async e=>{const t=await We(e.self());var n,r;Be(t)||setTimeout(()=>e.sendSelf("POLL"),2500),n=e.all(),r=t,JSON.stringify(n)!==JSON.stringify(r)&&e.broadcast(S,t),e.merge(t)}},$e=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},qe=e=>m(Je,$e(e));function Ge(e){function t(t){return R($e(e),qe,t)}function n(e){return function(n={}){const r=n.suppress||!1;return new Promise((n,a)=>{const s=t(t=>{t.statusCode&&!r?(a(t.errorMessage),s()):e(t)&&(n(t),s())})})}}return{snapshot:function(){return v(e,qe)},subscribe:t,onceFinalized:n(He),onceExecuted:n(Ye),onceSealed:n(Be)}}async function Ke(t={}){var n;try{await async function(t){f(T(t),"mutate(opts) -- opts is required"),f(k(t),"mutate(opts) -- opts must be an object"),f(T(t.cadence),"mutate({ cadence }) -- cadence is required"),f(_(t.cadence),"mutate({ cadence }) -- cadence must be a string"),f(await e.config.get("accessNode.api"),'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')}(t);const r=await e.config().get("fcl.authz",je().authorization);return n=e.send([e.transaction(t.cadence),e.args(M(t.args||[])),t.limit&&U(t.limit)&&e.limit(t.limit),e.proposer(t.proposer||t.authz||r),e.payer(t.payer||t.authz||r),e.authorizations(t.authorizations||[t.authz||r])]).then(e.decode),n}catch(e){throw e}}Ge.isUnknown=e=>e.status>=0,Ge.isPending=e=>e.status>=1,Ge.isFinalized=He,Ge.isExecuted=Ye,Ge.isSealed=Be,Ge.isExpired=e=>5===e.status;const Xe=async(e=[],n={})=>{const r=await t.first(["sdk.resolve"],n.resolve||o);return Array.isArray(e)&&(e=await i(c(),e)),JSON.stringify(d(await r(e)),null,2)},Ze=async e=>setTimeout(()=>e.sendSelf("TICK"),await t().get("fcl.eventPollRate",1e4)),Qe={TICK:async e=>{if(!e.hasSubs())return;let t=e.get("hwm");if(null==t)e.put("hwm",await l()),e.put("tick",await Ze(e));else{let n=await l();e.put("hwm",n);const a=await r([u(e.self(),t.height,n.height-1)]).then(s);for(let t of a)e.broadcast("UPDATED",t.data);e.put("tick",await Ze(e))}},[h]:async(e,t)=>{e.hasSubs()||e.put("tick",await Ze(e)),e.subscribe(t.from)},[g]:(e,t)=>{e.unsubscribe(t.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))}},et=e=>m(Qe,e);function tt(e){return{subscribe:t=>R(e,et,t)}}async function nt(e=[]){const n=await t.get("discovery.authn.endpoint");f(Boolean(n),'"discovery.authn.endpoint" in config must be defined.');const r=await t.get("discovery.authn.include",[]),a=new URL(n);return fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:D,include:r})}).then(e=>e.json()).then(t=>[...e,...t])}function rt(e=[]){return[...window.fcl_extensions||[],...e]}const at={[w]:async e=>{"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;");const t=await(({type:e})=>((...e)=>t=>e.reduce((e,t)=>e.then(t),Promise.resolve(t)))(nt,rt,t=>function(e=[],t){return e.filter(e=>e.type===t)}(t,e))([]))({type:"authn"});e.put("results",t)},[h]:(e,t)=>{e.subscribe(t.from),e.send(t.from,"UPDATED",z({},e.all()))},[g]:(e,t)=>e.unsubscribe(t.from),SNAPSHOT:async(e,t)=>t.reply(z({},e.all()))},st=()=>m(at,"authn"),ot={authn:{subscribe:e=>R("authn",st,e),snapshot:()=>v("authn",st)}},it=(e,t=(()=>{}))=>{const n=n=>{const{data:r}=n;"object"==typeof r&&null!=typeof r&&r.type===e&&t((e=>{var t;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(t=e.body)||delete t.interaction,e})(r))};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)},ct=(e,t={})=>{window.location!==window.parent.location?window.parent.postMessage(z({},t,{type:e}),"*"):window.opener.postMessage(z({},t,{type:e}),"*")},dt=e=>Buffer.from(e.padStart(16,0),"hex"),lt=e=>Buffer.from(e,"hex"),ut=({address:e,nonce:t,appIdentifier:n},r=!0)=>{f(e,"Encode Message For Provable Authn Error: address must be defined"),f(t,"Encode Message For Provable Authn Error: nonce must be defined"),f(n,"Encode Message For Provable Authn Error: appIdentifier must be defined"),f(t.length>=64,"Encode Message For Provable Authn Error: nonce must be minimum of 32 bytes");const a=(s=Buffer.from("FLOW-V0.0-user").toString("hex"),Buffer.from(s.padEnd(64,0),"hex"));var s;return r?Buffer.concat([a,A([n,dt(I(e)),lt(t)])]).toString("hex"):A([n,dt(I(e)),lt(t)]).toString("hex")};var pt={__proto__:null,sendMsgToFCL:ct,ready:(e,t={})=>{it("FCL:VIEW:READY:RESPONSE",e),ct("FCL:VIEW:READY")},close:()=>{ct("FCL:VIEW:CLOSE")},approve:e=>{ct("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:e=>{ct("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:e=>{ct("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:it,encodeMessageFromSignable:p,CompositeSignature:function(e,t,n){this.f_type=H.f_type,this.f_vsn=H.f_vsn,this.addr=C(e),this.keyId=Number(t),this.signature=n},encodeAccountProof:ut,injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},ft={__proto__:null,verifyAccountProof:async function(e,{address:n,nonce:r,signatures:a}){((e,t,n,r)=>{f("string"==typeof e,"appIdentifier must be a string"),f(/^[0-9a-f]+$/i.test(n),"Nonce must be a hex string"),f(Array.isArray(r)&&r.every((e,t,n)=>"CompositeSignature"===e.f_type),"Must include an Array of CompositeSignatures to verify"),f(r.map(e=>e.addr).every((e,t,n)=>e===n[0]),"User signatures to be verified must be from a single account address")})(e,0,r,a);const s=ut({address:n,nonce:r,appIdentifier:e},!1);let o=[],i=[];for(const e of a)o.push(e.signature),i.push(e.keyId);return await V({cadence:await(async()=>`\n import FCLCrypto from ${"testnet"===await t.get("env")?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284"}\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyAccountProofSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n `)(),args:(e,t)=>[e(n,t.Address),e(s,t.String),e(i,t.Array([t.Int])),e(o,t.Array([t.String]))]})}};const yt=(e={})=>je().authenticate(e),mt=()=>je().unauthenticate(),Et=(e={})=>(je().unauthenticate(),je().authenticate(e)),ht=(e={})=>je().authenticate(e),gt=(e={})=>je().authenticate(e),wt=je().authorization,Rt=y;export{ft as AppUtils,D as VERSION,pt as WalletUtils,yt as authenticate,wt as authz,je as currentUser,ot as discovery,tt as events,gt as logIn,Ke as mutate,V as query,Et as reauthenticate,Xe as serialize,ht as signUp,Rt as t,Ge as tx,mt as unauthenticate,Ie as verifyUserSignatures}; | ||
//# sourceMappingURL=fcl.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import*as e from"@onflow/sdk";import{config as n,arg as r,send as t,getTransactionStatus as o,decode as i,resolve as s,createSignableVoucher as a,pipe as c,interaction as u,latestBlock as l,getEvents as d,encodeMessageFromSignable as f}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,block,build,config,createSignableVoucher,decode,getAccount,getBlock,getBlockByHeight,getBlockById,getBlockHeader,getCollection,getEvents,getEventsAtBlockHeightRange,getEventsAtBlockIds,getLatestBlock,getTransaction,getTransactionStatus,invariant,isBad,isOk,latestBlock,limit,param,params,payer,ping,pipe,proposer,ref,script,send,transaction,validator,voucherIntercept,voucherToTxId,why}from"@onflow/sdk";import{invariant as p}from"@onflow/util-invariant";import*as h from"@onflow/types";import{INIT as v,SUBSCRIBE as m,UNSUBSCRIBE as y,spawn as g,send as E,UPDATED as P,SNAPSHOT as w,subscriber as R,snapshoter as S}from"@onflow/util-actor";import{withPrefix as b,sansPrefix as A}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as C from"@onflow/rlp";import{encode as I}from"@onflow/rlp";import{uid as D}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";var L="0.0.79-alpha.3",N=function(e){try{return Promise.resolve(n().where(e)).then(function(n){return Object.fromEntries(Object.entries(n).map(function(n){var r=n[1];return[n[0].replace(e,""),r]}))})}catch(e){return Promise.reject(e)}},O={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};n({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":O});var k=function(e){return function(n){return typeof n===e}},j=function(e){return null!=e},F=k("object"),x=k("string"),T=k("function"),_=k("number");function M(n){return T(n)?n(e.arg,h):[]}var V=function(n){return void 0===n&&(n={}),Promise.resolve(function(n){try{return p(j(n.cadence),"query({ cadence }) -- cadence is required"),p(x(n.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){p(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(n)).then(function(){return e.send([e.script(n.cadence),e.args(M(n.args||[])),n.limit&&"number"==typeof n.limit&&e.limit(n.limit)]).then(e.decode)})};function U(){return U=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},U.apply(this,arguments)}function H(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function z(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return H(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?H(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var W={f_type:"Service",f_vsn:"1.0.0"},B={f_type:"Identity",f_vsn:"1.0.0"},K={f_type:"USER",f_vsn:"1.0.0"},Y={f_type:"PollingResponse",f_vsn:"1.0.0"},J={f_type:"CompositeSignature",f_vsn:"1.0.0"};function q(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({old:e},W,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function G(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},W,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function X(e){return null==e?null:(null==e.method&&(e=U({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:U({},W,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var Z={"back-channel-rpc":G,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},W,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:U({},B,{address:b(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},W,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:U({},B,{address:b(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},W,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:b(e.addr),name:e.name,icon:e.icon}})},frame:q,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":X,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function $(e){return C.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var Q=function(e){try{var n=(e=function(e){return e.addr=e.addr?b(e.addr):null,e.paddr=e.paddr?b(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var r=new URL(e);return r.searchParams.append("code",n),Promise.resolve(fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var r,t=z(e.authorizations);!(r=t()).done;)n.push(U({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&n.push(U({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(r){var t,o,i=(t=n,o=r,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o)).map(function(n){return function(e,n){try{return Z[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,i);return U({},K,{addr:b(e.addr),cid:$(s),loggedIn:!0,services:i,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function ee(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function ne(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var r=0,t=Object.entries(e.params||{});r<t.length;r++){var o=t[r];n.searchParams.append(o[0],o[1])}return n}function re(e,n){void 0===n&&(n={});var r=n.method||"POST",t="GET"===r?void 0:JSON.stringify(n.data||e.data||{});return fetch(ne(e),{method:r,headers:U({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function te(e){var n,r;return null==e?null:"1.0.0"===e.f_vsn?e:U({},Y,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(r=e.reason)?r:null,data:e.compositeSignature||e.data||U({},e)||{},updates:G(e.authorizationUpdates),local:q((e.local||[])[0])})}var oe=function e(n,r){void 0===r&&(r=function(){return!0});try{if(p(n,"Missing Polling Service",{service:n}),!r())throw new Error("Externally Halted");return Promise.resolve(re(n,{method:se(n)}).then(te)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,r)})}})}catch(e){return Promise.reject(e)}},ie={"HTTP/GET":"GET","HTTP/POST":"POST"},se=function(e){return p(ie[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),ie[e.method]},ae="FCL_IFRAME";function ce(e){p(!document.getElementById(ae),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=ae,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,function(){document.getElementById(ae)&&document.getElementById(ae).remove()}]}var ue=null,le=null;function de(e){var n,r;return null==ue||null!=(n=ue)&&n.closed?(r=window,ue=r.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(r.top.outerHeight/2+r.top.screenY-385)+", left="+(r.top.outerWidth/2+r.top.screenX-320))):le!==e?(ue.location.replace(e),ue.focus()):ue.focus(),le=e,[ue,function(){ue&&!ue.closed&&ue.close(),ue=null}]}var fe=null,pe=null;function he(e){var n;return null==fe||null!=(n=fe)&&n.closed?fe=window.open(e,"_blank"):pe!==e?(fe.location.replace(e),fe.focus()):fe.focus(),pe=e,[fe,function(){fe&&!fe.closed&&fe.close(),fe=null}]}var ve,me={"VIEW/IFRAME":ce,"VIEW/POP":de,"VIEW/TAB":he},ye=function(e,n,r,t){try{return Promise.resolve(re(e,{data:U({fclVersion:L,service:{params:e.params,data:e.data,type:e.type},config:t},n)}).then(te)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var r=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(me[e.method](ne(e),n))}catch(r){throw console.error("execLocal({service, opts = {}})",r,{service:e,opts:n}),r}}catch(e){return Promise.reject(e)}}(X(n.local))).then(function(e){var t=e[1],o=function(){try{t(),r=!1}catch(e){console.error("Frame Close Error",e)}};return oe(n.updates,function(){return r}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})}catch(e){return Promise.reject(e)}},ge=function(e){return"string"==typeof e&&e.toLowerCase()},Ee=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),Pe=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},we=function(e){var n=e.close,r=e.send,t=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(Ee.has(e.data.type))return;ge(e.data.type)===ge("FCL:VIEW:CLOSE")&&n(),ge(e.data.type)===ge("FCL:VIEW:READY")&&t(e,{send:r,close:n}),ge(e.data.type)===ge("FCL:VIEW:RESPONSE")&&o(e,{send:r,close:n}),i(e,{send:r,close:n}),ge(e.data.type)===ge("FCL:FRAME:READY")&&(Pe(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),ge(e.data.type)===ge("FCL:FRAME:RESPONSE")&&(Pe(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),ge(e.data.type)===ge("FCL:FRAME:CLOSE")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),n()),ge(e.data.type)===ge("FCL::CHALLENGE::RESPONSE")&&(Pe(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),ge(e.data.type)===ge("FCL::AUTHZ_READY")&&(Pe(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),ge(e.data.type)===ge("FCL::CHALLENGE::CANCEL")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),n()),ge(e.data.type)===ge("FCL::CANCEL")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),n())}catch(e){console.error("Frame Callback Error",e),n()}}},Re=function(){},Se=function(){},be=function(){},Ae=function(){},Ce=function e(n){var r=n.service,t=n.msg,o=void 0===t?{}:t,i=n.opts,s=void 0===i?{}:i,a=n.config,c=void 0===a?{}:a;try{return Promise.resolve(N(/^service\./)).then(function(n){return Promise.resolve(N(/^app\.detail\./)).then(function(t){var i=U({},c,{services:n,app:t});return function(n,t){try{var a=Promise.resolve(Ie[r.method](r,o,s,i)).then(function(n){return"REDIRECT"===n.status?(p(r.type===n.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:n.data,msg:o,opts:s,config:i}))):n})}catch(e){return t(e)}return a&&a.then?a.then(void 0,t):a}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:r,msg:o,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},Ie={"HTTP/RPC":ye,"HTTP/POST":ye,"IFRAME/RPC":function(e,n,r,t){return new Promise(function(o,i){var s,a=D(),c=r.includeOlderJsonRpcCall;n.data=null!=(s=e.data)?s:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:Re,close:Re};var r=n.onClose||Re;window.addEventListener("message",we({close:s,send:a,onReady:n.onReady||Re,onResponse:n.onResponse||Re,onMessage:n.onMessage||Re}));var t=ce(ne(e)),o=t[0],i=t[1];return{send:a,close:s};function s(){try{window.removeEventListener("message",we),i(),r()}catch(e){console.error("Frame Close Error",e)}}function a(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:L,body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,r,t){return new Promise(function(o,i){var s=D(),a=r.redir,c=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:Se,close:Se};var r=n.onClose||Se;window.addEventListener("message",we({close:a,send:c,onReady:n.onReady||Se,onResponse:n.onResponse||Se,onMessage:n.onMessage||Se}));var t=de(ne(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:c,close:a};function a(){try{window.removeEventListener("message",we),clearInterval(s),i(),r()}catch(e){console.error("Popup Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,r,t){return new Promise(function(o,i){var s=D(),a=r.redir,c=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:be,close:be};var r=n.onClose||be;window.addEventListener("message",we({close:a,send:c,onReady:n.onReady||be,onResponse:n.onResponse||be,onMessage:n.onMessage||be}));var t=he(ne(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:c,close:a};function a(){try{window.removeEventListener("message",we),clearInterval(s),i(),r()}catch(e){console.error("Tab Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,r,t){return new Promise(function(r,o){!function(e,n){void 0===n&&(n={});try{var r,t=function(){try{window.removeEventListener("message",we),s()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:Ae,close:Ae});var i=e.endpoint,s=n.onClose||Ae;window.addEventListener("message",we({close:t,send:o,onReady:n.onReady||Ae,onResponse:n.onResponse||Ae,onMessage:n.onMessage||Ae})),Promise.resolve(null==(r=window[i])?void 0:r.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var i=te(e.data);switch(i.status){case"APPROVED":r(i.data),t();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),t();break;case"REDIRECT":r(i),t();break;default:o("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},De=function(e,n){try{Le(e,n);var r=n[0].addr,t=[],o=[];return n.map(function(e){t.push(e.signature),o.push(e.keyId)}),Promise.resolve(V({cadence:Ne,args:function(n,i){return[n(r,i.Address),n(e,i.String),n(o,i.Array([i.Int])),n(t,i.Array([i.String]))]}}))}catch(e){return Promise.reject(e)}},Le=function(e,n){return p(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),p(Array.isArray(n)&&n.every(function(e,n,r){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),p(n.map(function(e){return e.addr}).every(function(e,n,r){return e===r[0]}),"User signatures to be verified must be from a single account address"),!0},Ne='\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\n\n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_secp256k1 : SignatureAlgorithm.ECDSA_P256\n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i]\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n';function Oe(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},J,{addr:A(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function ke(e,n,r){if(!e.s){if(r instanceof Fe){if(!r.s)return void(r.o=ke.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(ke.bind(null,e,n),ke.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var je=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(De(e,n))}catch(e){return Promise.reject(e)}},Fe=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{ke(t,1,i(this.v))}catch(e){ke(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?ke(t,1,n?n(o):o):r?ke(t,1,r(o)):ke(t,2,o)}catch(e){ke(t,2,e)}},t},e}();function xe(e){return e instanceof Fe&&1&e.s}var Te=function(e){try{return Je(),Promise.resolve(Ue({redir:!0})).then(function(n){var r=ee(n.services,"user-signature");return p(r,"Current user must have authorized a signing service."),_e(function(){return Promise.resolve(Ce({service:r,msg:$e(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return Oe(e)}):[Oe(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function _e(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}var Me=function(){return Promise.resolve(Ue()).then(function(e){return r(b(e.addr),h.Address)})},Ve=function(e){try{return Je(),Promise.resolve(U({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Ue({redir:!0})).then(function(r){var t;function o(n){if(t)return n;if(i)return U({},e,{tempId:"CURRENT_USER",resolve:null,addr:A(i.identity.address),keyId:i.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(Ce({service:i,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(Oe)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var i=ee(r.services,"authz"),s=ee(r.services,"pre-authz"),a=function(){if(s)return Promise.resolve(Ce({service:s,msg:n})).then(function(e){var n=function(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),r=[];null!=n.proposer&&r.push(["PROPOSER",n.proposer]);for(var t,o=z(n.payer||[]);!(t=o()).done;)r.push(["PAYER",t.value]);for(var i,s=z(n.authorization||[]);!(i=s()).done;)r.push(["AUTHORIZER",i.value]);return r.map(function(e){var n=e[0],r=e[1];return{tempId:[r.identity.address,r.identity.keyId].join("|"),addr:r.identity.address,keyId:r.identity.keyId,signingFunction:function(e){return Ce({service:r,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return t=1,n})}();return a&&a.then?a.then(o):o(a)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Ue=function(e){var r=void 0===e?{}:e,t=r.service,o=r.redir,i=void 0!==o&&o;try{return Promise.resolve(new Promise(function(e,r){try{return Je(),Promise.resolve(Xe()).then(function(r){return Promise.resolve(He()).then(function(o){var s={redir:i};return Promise.resolve(function(){try{return Promise.resolve(n.first(["discovery.wallet","challenge.handshake"])).then(function(e){return Promise.resolve(n.get("discovery.authn.include",[])).then(function(r){return Promise.resolve(n.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(n){return{type:"authn",endpoint:e,method:n,discoveryAuthnInclude:r}})})})}catch(e){return Promise.reject(e)}}()).then(function(a){var c=ee(r.services,"authn-refresh");return Promise.resolve(n.get("fcl.warning.suppress.redir")).then(function(n){var u;function l(n){if(u)return n;var r=function(e,n){try{var r=_e(function(){return Promise.resolve(Ce({service:U({},t||a,{method:(null==a?void 0:a.method)||t.method||"IFRAME/RPC"}),msg:o,opts:s,config:{discoveryAuthnInclude:a.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(Q(e)).then(function(e){E(ze,Be,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return r&&r.then?r.then(n.bind(null,!1),n.bind(null,!0)):n(!1,r)}(0,function(n,r){return Promise.resolve(Xe()).then(function(t){if(e(t),n)throw r;return r})});return r&&r.then?r.then(function(){}):void 0}i&&!n&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config"),p(t||a.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');var d=function(){if(r.loggedIn){if(c)return function(e,n){try{var r=_e(function(){return Promise.resolve(Ce({service:c,msg:o,opts:s})).then(function(e){return Promise.resolve(Q(e)).then(function(e){E(ze,Be,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return r&&r.then?r.then(n,n):n()}(0,function(){return Promise.resolve(Xe()).then(function(n){var r=e(n);return u=1,r})});var n=e(r);return u=1,n}}();return d&&d.then?d.then(l):l(d)})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},He=function(){try{var e=Date.now();return Promise.resolve(n.get("fcl.appDomainTag")).then(function(n){return{timestamp:e,appDomainTag:n,extensions:window.fcl_extensions||[]}})}catch(e){return Promise.reject(e)}},ze="CURRENT_USER",We="CURRENT_USER/UPDATED",Be="SET_CURRENT_USER",Ke='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Ye=((ve={})[v]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(Ke)),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){var r=function(){if(n.can)return Promise.resolve(function(e){try{var n=JSON.parse(Ke);return Promise.resolve(e.get(ze)).then(function(r){return null!=r&&n.f_vsn!==r.f_vsn?(e.removeItem(ze),n):r||n})}catch(e){return Promise.reject(e)}}(n)).then(function(n){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(n)&&e.merge(n)})}();if(r&&r.then)return r.then(function(){})})}catch(e){return Promise.reject(e)}},ve[m]=function(e,n){e.subscribe(n.from),e.send(n.from,We,U({},e.all()))},ve[y]=function(e,n){e.unsubscribe(n.from)},ve.SNAPSHOT=function(e,n){try{return n.reply(U({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},ve[Be]=function(e,r,t){try{return e.merge(t),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(ze,e.all()),e.broadcast(We,U({},e.all()))})}catch(e){return Promise.reject(e)}},ve.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(Ke)),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(ze,e.all()),e.broadcast(We,U({},e.all()))})}catch(e){return Promise.reject(e)}},ve),Je=function(){return g(Ye,ze)};function qe(){Je(),E(ze,"DEL_CURRENT_USER")}function Ge(e){Je();var n="@EXIT",r=g(function(r){try{var t;return r.send(ze,m),Promise.resolve(function(e,n,r){for(var t;;){var o=e();if(xe(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=r();if(i&&i.then){if(!xe(i)){t=1;break}i=i.s}}var s=new Fe,a=ke.bind(null,s,2);return(0===t?o.then(u):1===t?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(u).then(void 0,a):u(o):ke(s,1,i)})).then(void 0,a),s;function c(n){i=n;do{if(!(o=e())||xe(o)&&!o.v)return void ke(s,1,i);if(o.then)return void o.then(u).then(void 0,a);xe(i=r())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,a)}function u(e){e?(i=r())&&i.then?i.then(c).then(void 0,a):c(i):ke(s,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(o){if(o.tag===n)return r.send(ze,y),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return E(r,n)}}function Xe(){return Je(),E(ze,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Ze,$e=function(e){return p(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Qe=function(){return{authenticate:Ue,unauthenticate:qe,authorization:Ve,signUserMessage:Te,verifyUserSignatures:je,subscribe:Ge,snapshot:Xe,resolveArgument:Me}};Qe.authenticate=Ue,Qe.unauthenticate=qe,Qe.authorization=Ve,Qe.signUserMessage=Te,Qe.verifyUserSignatures=je,Qe.subscribe=Ge,Qe.snapshot=Xe,Qe.resolveArgument=Me;var en=function(e){try{return Promise.resolve(t([o(e)]).then(i))}catch(e){return Promise.reject(e)}},nn=function(e){return e.status>=4},rn=function(e){return e.status>=3},tn=function(e){return e.status>=2},on=((Ze={})[v]=function(e){try{return Promise.resolve(en(e.self())).then(function(n){nn(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Ze[m]=function(e,n){e.subscribe(n.from),e.send(n.from,P,e.all())},Ze[y]=function(e,n){e.unsubscribe(n.from)},Ze[w]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Ze.POLL=function(e){try{return Promise.resolve(en(e.self())).then(function(n){var r,t;nn(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),r=e.all(),t=n,JSON.stringify(r)!==JSON.stringify(t)&&e.broadcast(P,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Ze),sn=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},an=function(e){return g(on,sn(e))};function cn(e){function n(n){return R(sn(e),an,n)}function r(e){return function(r){void 0===r&&(r={});var t=r.suppress||!1;return new Promise(function(r,o){var i=n(function(n){n.statusCode&&!t?(o(n.errorMessage),i()):e(n)&&(r(n),i())})})}}return{snapshot:function(){return S(e,an)},subscribe:n,onceFinalized:r(tn),onceExecuted:r(rn),onceSealed:r(nn)}}cn.isUnknown=function(e){return e.status>=0},cn.isPending=function(e){return e.status>=1},cn.isFinalized=tn,cn.isExecuted=rn,cn.isSealed=nn,cn.isExpired=function(e){return 5===e.status};var un,ln=function(n){void 0===n&&(n={});try{return Promise.resolve(function(r,t){try{var o=Promise.resolve(function(n){try{return p(j(n),"mutate(opts) -- opts is required"),p(F(n),"mutate(opts) -- opts must be an object"),p(j(n.cadence),"mutate({ cadence }) -- cadence is required"),p(x(n.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){p(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(n)).then(function(){return Promise.resolve(e.config().get("fcl.authz",Qe().authorization)).then(function(r){return e.send([e.transaction(n.cadence),e.args(M(n.args||[])),n.limit&&_(n.limit)&&e.limit(n.limit),e.proposer(n.proposer||n.authz||r),e.payer(n.payer||n.authz||r),e.authorizations(n.authorizations||[n.authz||r])]).then(e.decode)})})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},dn=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{return Promise.resolve(n.first(["sdk.resolve"],r.resolve||s)).then(function(n){function r(){return Promise.resolve(n(e)).then(function(e){return JSON.stringify(a(e),null,2)})}var t=function(){if(Array.isArray(e))return Promise.resolve(c(u(),e)).then(function(n){e=n})}();return t&&t.then?t.then(r):r()})}catch(e){return Promise.reject(e)}},fn=function(e){try{var r=setTimeout;return Promise.resolve(n().get("fcl.eventPollRate",1e4)).then(function(n){return r(function(){return e.sendSelf("TICK")},n)})}catch(e){return Promise.reject(e)}},pn=((un={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var n=e.get("hwm"),r=function(){if(null==n){var r=e.put;return Promise.resolve(l()).then(function(n){r.call(e,"hwm",n);var t=e.put;return Promise.resolve(fn(e)).then(function(n){t.call(e,"tick",n)})})}return Promise.resolve(l()).then(function(r){return e.put("hwm",r),Promise.resolve(t([d(e.self(),n.height,r.height-1)]).then(i)).then(function(n){for(var r,t=z(n);!(r=t()).done;)e.broadcast("UPDATED",r.value.data);var o=e.put;return Promise.resolve(fn(e)).then(function(n){o.call(e,"tick",n)})})})}();return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},un[m]=function(e,n){try{var r=function(){e.subscribe(n.from)},t=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(fn(e)).then(function(r){n.call(e,"tick",r)})}}();return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},un[y]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},un),hn=function(e){return g(pn,e)};function vn(e){return{subscribe:function(n){return R(e,hn,n)}}}var mn=function(e){void 0===e&&(e=[]);try{return Promise.resolve(n.get("discovery.authn.endpoint")).then(function(r){return p(Boolean(r),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(n.get("discovery.authn.include",[])).then(function(n){var t=new URL(r);return fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:L,include:n})}).then(function(e){return e.json()}).then(function(n){return[].concat(e,n)})})})}catch(e){return Promise.reject(e)}};function yn(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var gn,En=((gn={})[v]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:"authn"},r=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(mn,yn,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,r)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,r},gn[m]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",U({},e.all()))},gn[y]=function(e,n){return e.unsubscribe(n.from)},gn.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(U({},e.all())))}catch(e){return Promise.reject(e)}},gn),Pn=function(){return g(En,"authn")},wn={authn:{subscribe:function(e){return R("authn",Pn,e)},snapshot:function(){return S("authn",Pn)}}},Rn=function(e,n){void 0===n&&(n=function(){});var r=function(r){var t=r.data;"object"==typeof t&&null!=typeof t&&t.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(t))};return window.addEventListener("message",r),function(){return window.removeEventListener("message",r)}},Sn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(U({},n,{type:e}),"*"):window.opener.postMessage(U({},n,{type:e}),"*")},bn=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},An={__proto__:null,sendMsgToFCL:Sn,ready:function(e,n){Rn("FCL:VIEW:READY:RESPONSE",e),Sn("FCL:VIEW:READY")},close:function(){Sn("FCL:VIEW:CLOSE")},approve:function(e){Sn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){Sn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){Sn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:Rn,encodeMessageFromSignable:f,CompositeSignature:function(e,n,r){this.f_type=J.f_type,this.f_vsn=J.f_vsn,this.addr=b(e),this.keyId=Number(n),this.signature=r},encodeMessageForProvableAuthnSigning:function(e,n,r){void 0===r&&(r=""),p(e,"Encode Message From Provable Authn Error: address must be defined"),p(n,"Encode Message From Provable Authn Error: timestamp must be defined");var t=bn(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),o=bn(Buffer.from(r).toString("hex"),32).toString("hex");return t+(r?I([o,b(e),n]).toString("hex"):I([b(e),n]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,n,r){void 0===r&&(r=""),p(e,"Encode Message From Provable Authn Error: address must be defined"),p(n,"Encode Message From Provable Authn Error: timestamp must be defined");var t,o=r?(t=Buffer.from(r).toString("hex"),Buffer.from(t.padEnd(64,0),"hex")).toString("hex"):null;return r?I([o,b(e),n]).toString("hex"):I([b(e),n]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},Cn=function(e){return void 0===e&&(e={}),Qe().authenticate(e)},In=function(){return Qe().unauthenticate()},Dn=function(e){return void 0===e&&(e={}),Qe().unauthenticate(),Qe().authenticate(e)},Ln=function(e){return void 0===e&&(e={}),Qe().authenticate(e)},Nn=function(e){return void 0===e&&(e={}),Qe().authenticate(e)},On=Qe().authorization,kn=h;export{L as VERSION,An as WalletUtils,Cn as authenticate,On as authz,Qe as currentUser,wn as discovery,vn as events,Nn as logIn,ln as mutate,V as query,Dn as reauthenticate,dn as serialize,Ln as signUp,kn as t,cn as tx,In as unauthenticate,De as verifyUserSignatures}; | ||
import*as e from"@onflow/sdk";import{config as r,arg as n,send as t,getTransactionStatus as o,decode as i,resolve as s,createSignableVoucher as a,pipe as c,interaction as u,latestBlock as d,getEvents as l,encodeMessageFromSignable as f}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,block,build,config,createSignableVoucher,decode,getAccount,getBlock,getBlockByHeight,getBlockById,getBlockHeader,getCollection,getEvents,getEventsAtBlockHeightRange,getEventsAtBlockIds,getLatestBlock,getTransaction,getTransactionStatus,invariant,isBad,isOk,latestBlock,limit,param,params,payer,ping,pipe,proposer,ref,script,send,transaction,validator,voucherIntercept,voucherToTxId,why}from"@onflow/sdk";import{invariant as p}from"@onflow/util-invariant";import*as v from"@onflow/types";import{INIT as h,SUBSCRIBE as m,UNSUBSCRIBE as y,spawn as g,send as E,UPDATED as P,SNAPSHOT as R,subscriber as w,snapshoter as b}from"@onflow/util-actor";import{withPrefix as S,sansPrefix as C}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as I from"@onflow/rlp";import{encode as A}from"@onflow/rlp";import{uid as D}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";var N="0.0.79-alpha.4",L=function(e){try{return Promise.resolve(r().where(e)).then(function(r){return Object.fromEntries(Object.entries(r).map(function(r){var n=r[1];return[r[0].replace(e,""),n]}))})}catch(e){return Promise.reject(e)}},O={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,r){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(r)))}catch(e){return Promise.reject(e)}}};r({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":O});var F=function(e){return function(r){return typeof r===e}},j=function(e){return null!=e},k=F("object"),T=F("string"),x=F("function"),_=F("number");function M(r){return x(r)?r(e.arg,v):[]}var V=function(r){return void 0===r&&(r={}),Promise.resolve(function(r){try{return p(j(r.cadence),"query({ cadence }) -- cadence is required"),p(T(r.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){p(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(r)).then(function(){return e.send([e.script(r.cadence),e.args(M(r.args||[])),r.limit&&"number"==typeof r.limit&&e.limit(r.limit)]).then(e.decode)})};function U(){return U=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},U.apply(this,arguments)}function z(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function W(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return z(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?z(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var B={f_type:"Service",f_vsn:"1.0.0"},Y={f_type:"Identity",f_vsn:"1.0.0"},H={f_type:"USER",f_vsn:"1.0.0"},J={f_type:"PollingResponse",f_vsn:"1.0.0"},q={f_type:"CompositeSignature",f_vsn:"1.0.0"};function G(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({old:e},B,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function $(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},B,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function K(e){return null==e?null:(null==e.method&&(e=U({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:U({},B,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var X={"back-channel-rpc":$,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},B,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:U({},Y,{address:S(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},B,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:U({},Y,{address:S(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},B,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:S(e.addr),name:e.name,icon:e.icon}})},frame:G,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":K,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("FCL Normalizer Error: Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function Z(e){return I.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var Q=function(e){try{var r=(e=function(e){return e.addr=e.addr?S(e.addr):null,e.paddr=e.paddr?S(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,r){try{if(null==e||null==r)return Promise.resolve([]);var n=new URL(e);return n.searchParams.append("code",r),Promise.resolve(fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var r=[];if(Array.isArray(e.authorizations))for(var n,t=W(e.authorizations);!(n=t()).done;)r.push(U({type:"authz",keyId:e.keyId},n.value));return null!=e.provider&&r.push(U({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(n){var t,o,i=(t=r,o=n,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o)).map(function(r){return function(e,r){try{return X[e.type](e,r)}catch(r){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,r),e}}(r,e)}),s=function(e,r){return r.find(function(e){return"authn"===e.type})}(0,i);return U({},H,{addr:S(e.addr),cid:Z(s),loggedIn:!0,services:i,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function ee(e,r){return void 0===e&&(e=[]),e.find(function(e){return e.type===r})}function re(e){var r=new URL(e.endpoint);if(r.searchParams.append("l6n",window.location.origin),null!=e.params)for(var n=0,t=Object.entries(e.params||{});n<t.length;n++){var o=t[n];r.searchParams.append(o[0],o[1])}return r}function ne(e,r){void 0===r&&(r={});var n=r.method||"POST",t="GET"===n?void 0:JSON.stringify(r.data||e.data||{});return fetch(re(e),{method:n,headers:U({},e.headers||{},r.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function te(e){var r,n;return null==e?null:"1.0.0"===e.f_vsn?e:U({},J,{status:null!=(r=e.status)?r:"APPROVED",reason:null!=(n=e.reason)?n:null,data:e.compositeSignature||e.data||U({},e)||{},updates:$(e.authorizationUpdates),local:G((e.local||[])[0])})}var oe=function e(r,n){void 0===n&&(n=function(){return!0});try{if(p(r,"Missing Polling Service",{service:r}),!n())throw new Error("Externally Halted");return Promise.resolve(ne(r,{method:se(r)}).then(te)).then(function(r){switch(r.status){case"APPROVED":return r.data;case"DECLINED":throw new Error("Declined: "+(r.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(r.updates,n)})}})}catch(e){return Promise.reject(e)}},ie={"HTTP/GET":"GET","HTTP/POST":"POST"},se=function(e){return p(ie[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),ie[e.method]},ae="FCL_IFRAME";function ce(e){p(!document.getElementById(ae),"Attempt at triggering multiple Frames",{src:e});var r=document.createElement("iframe");return r.src=e,r.id=ae,r.allow="usb *; hid *",r.frameBorder="0",r.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(r),[r.contentWindow,function(){document.getElementById(ae)&&document.getElementById(ae).remove()}]}var ue=null,de=null;function le(e){var r,n;return null==ue||null!=(r=ue)&&r.closed?(n=window,ue=n.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(n.top.outerHeight/2+n.top.screenY-385)+", left="+(n.top.outerWidth/2+n.top.screenX-320))):de!==e?(ue.location.replace(e),ue.focus()):ue.focus(),de=e,[ue,function(){ue&&!ue.closed&&ue.close(),ue=null}]}var fe=null,pe=null;function ve(e){var r;return null==fe||null!=(r=fe)&&r.closed?fe=window.open(e,"_blank"):pe!==e?(fe.location.replace(e),fe.focus()):fe.focus(),pe=e,[fe,function(){fe&&!fe.closed&&fe.close(),fe=null}]}var he,me={"VIEW/IFRAME":ce,"VIEW/POP":le,"VIEW/TAB":ve},ye=function(e,r,n,t){try{return Promise.resolve(ne(e,{data:U({fclVersion:N,service:{params:e.params,data:e.data,type:e.type},config:t},r)}).then(te)).then(function(r){if("APPROVED"===r.status)return r.data;if("DECLINED"===r.status)throw new Error("Declined: "+(r.reason||"No reason supplied."));if("REDIRECT"===r.status)return r;if("PENDING"===r.status){var n=!0;return Promise.resolve(function(e,r){void 0===r&&(r={});try{try{return Promise.resolve(me[e.method](re(e),r))}catch(n){throw console.error("execLocal({service, opts = {}})",n,{service:e,opts:r}),n}}catch(e){return Promise.reject(e)}}(K(r.local))).then(function(e){var t=e[1],o=function(){try{t(),n=!1}catch(e){console.error("Frame Close Error",e)}};return oe(r.updates,function(){return n}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:r}),new Error("Auto Decline: Invalid Response")})}catch(e){return Promise.reject(e)}},ge=function(e){return"string"==typeof e&&e.toLowerCase()},Ee=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),Pe=function(e,r){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+r+" for this and future versions of FCL")},Re=function(e){var r=e.close,n=e.send,t=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(Ee.has(e.data.type))return;ge(e.data.type)===ge("FCL:VIEW:CLOSE")&&r(),ge(e.data.type)===ge("FCL:VIEW:READY")&&t(e,{send:n,close:r}),ge(e.data.type)===ge("FCL:VIEW:RESPONSE")&&o(e,{send:n,close:r}),i(e,{send:n,close:r}),ge(e.data.type)===ge("FCL:FRAME:READY")&&(Pe(e.data.type,"FCL:VIEW:READY"),t(e,{send:n,close:r})),ge(e.data.type)===ge("FCL:FRAME:RESPONSE")&&(Pe(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:n,close:r})),ge(e.data.type)===ge("FCL:FRAME:CLOSE")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),r()),ge(e.data.type)===ge("FCL::CHALLENGE::RESPONSE")&&(Pe(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:n,close:r})),ge(e.data.type)===ge("FCL::AUTHZ_READY")&&(Pe(e.data.type,"FCL:VIEW:READY"),t(e,{send:n,close:r})),ge(e.data.type)===ge("FCL::CHALLENGE::CANCEL")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),r()),ge(e.data.type)===ge("FCL::CANCEL")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),r())}catch(e){console.error("Frame Callback Error",e),r()}}},we=function(){},be=function(){},Se=function(){},Ce=function(){},Ie=function e(r){var n=r.service,t=r.msg,o=void 0===t?{}:t,i=r.opts,s=void 0===i?{}:i,a=r.config,c=void 0===a?{}:a;try{return o.extensions=window.fcl_extensions||[],o.data=n.data,Promise.resolve(L(/^service\./)).then(function(r){return Promise.resolve(L(/^app\.detail\./)).then(function(t){var i=U({},c,{services:r,app:t});return function(r,t){try{var a=Promise.resolve(Ae[n.method](n,o,s,i)).then(function(r){return"REDIRECT"===r.status?(p(n.type===r.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:r.data,msg:o,opts:s,config:i}))):r})}catch(e){return t(e)}return a&&a.then?a.then(void 0,t):a}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:n,msg:o,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},Ae={"HTTP/RPC":ye,"HTTP/POST":ye,"IFRAME/RPC":function(e,r,n,t){return new Promise(function(o,i){var s=D(),a=n.includeOlderJsonRpcCall;!function(e,r){if(void 0===r&&(r={}),null==e)return{send:we,close:we};var n=r.onClose||we;window.addEventListener("message",Re({close:s,send:a,onReady:r.onReady||we,onResponse:r.onResponse||we,onMessage:r.onMessage||we}));var t=ce(re(e)),o=t[0],i=t[1];return{send:a,close:s};function s(){try{window.removeEventListener("message",Re),i(),n()}catch(e){console.error("Frame Close Error",e)}}function a(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(r){console.error("Frame Send Error",e,r)}}}(e,{onReady:function(n,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:N,body:r,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),a&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[r,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,r,n,t){return new Promise(function(o,i){var s=D(),a=n.redir,c=n.includeOlderJsonRpcCall;!function(e,r){if(void 0===r&&(r={}),null==e)return{send:be,close:be};var n=r.onClose||be;window.addEventListener("message",Re({close:a,send:c,onReady:r.onReady||be,onResponse:r.onResponse||be,onMessage:r.onMessage||be}));var t=le(re(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:c,close:a};function a(){try{window.removeEventListener("message",Re),clearInterval(s),i(),n()}catch(e){console.error("Popup Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(r){console.error("Popup Send Error",e,r)}}}(e,{onReady:function(n,o){var i=o.send;try{try{i({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[r,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),!a&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),!a&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,r,n,t){return new Promise(function(o,i){var s=D(),a=n.redir,c=n.includeOlderJsonRpcCall;!function(e,r){if(void 0===r&&(r={}),null==e)return{send:Se,close:Se};var n=r.onClose||Se;window.addEventListener("message",Re({close:a,send:c,onReady:r.onReady||Se,onResponse:r.onResponse||Se,onMessage:r.onMessage||Se}));var t=ve(re(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:c,close:a};function a(){try{window.removeEventListener("message",Re),clearInterval(s),i(),n()}catch(e){console.error("Tab Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(r){console.error("Tab Send Error",e,r)}}}(e,{onReady:function(n,o){var i=o.send;try{try{i({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[r,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),!a&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),!a&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,r,n,t){return new Promise(function(n,o){!function(e,r){void 0===r&&(r={});try{var n,t=function(){try{window.removeEventListener("message",Re),s()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var r;null==(r=window[i])||r.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(r){console.error("Extension Send Error",e,r)}};if(null==e)return Promise.resolve({send:Ce,close:Ce});var i=e.endpoint,s=r.onClose||Ce;window.addEventListener("message",Re({close:t,send:o,onReady:r.onReady||Ce,onResponse:r.onResponse||Ce,onMessage:r.onMessage||Ce})),Promise.resolve(null==(n=window[i])?void 0:n.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(n,o){var i=o.send;try{try{i({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var t=r.close;try{if("object"!=typeof e.data)return;var i=te(e.data);switch(i.status){case"APPROVED":n(i.data),t();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),t();break;case"REDIRECT":n(i),t();break;default:o("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},De=function(e,n){try{Ne(e,n);for(var t,o=n[0].addr,i=[],s=[],a=W(n);!(t=a()).done;){var c=t.value;i.push(c.signature),s.push(c.keyId)}return Promise.resolve(function(){try{return Promise.resolve(r.get("env")).then(function(e){return"\n import FCLCrypto from "+("testnet"===e?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284")+"\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyUserSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n "})}catch(e){return Promise.reject(e)}}()).then(function(r){return Promise.resolve(V({cadence:r,args:function(r,n){return[r(o,n.Address),r(e,n.String),r(s,n.Array([n.Int])),r(i,n.Array([n.String]))]}}))})}catch(e){return Promise.reject(e)}},Ne=function(e,r){return p(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),p(Array.isArray(r)&&r.every(function(e,r,n){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),p(r.map(function(e){return e.addr}).every(function(e,r,n){return e===n[0]}),"User signatures to be verified must be from a single account address"),!0};function Le(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},q,{addr:C(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function Oe(e,r,n){if(!e.s){if(n instanceof je){if(!n.s)return void(n.o=Oe.bind(null,e,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(Oe.bind(null,e,r),Oe.bind(null,e,2));e.s=r,e.v=n;var t=e.o;t&&t(e)}}var Fe=function(e,r){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(De(e,r))}catch(e){return Promise.reject(e)}},je=function(){function e(){}return e.prototype.then=function(r,n){var t=new e,o=this.s;if(o){var i=1&o?r:n;if(i){try{Oe(t,1,i(this.v))}catch(e){Oe(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Oe(t,1,r?r(o):o):n?Oe(t,1,n(o)):Oe(t,2,o)}catch(e){Oe(t,2,e)}},t},e}();function ke(e){return e instanceof je&&1&e.s}var Te=function(e){try{return Je(),Promise.resolve(Ve({redir:!0})).then(function(r){var n=ee(r.services,"user-signature");return p(n,"Current user must have authorized a signing service."),xe(function(){return Promise.resolve(Ie({service:n,msg:Xe(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return Le(e)}):[Le(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function xe(e,r){try{var n=e()}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}var _e=function(){return Promise.resolve(Ve()).then(function(e){return n(S(e.addr),v.Address)})},Me=function(e){try{return Je(),Promise.resolve(U({},e,{tempId:"CURRENT_USER",resolve:function(e,r){try{return Promise.resolve(Ve({redir:!0})).then(function(n){var t;function o(r){if(t)return r;if(i)return U({},e,{tempId:"CURRENT_USER",resolve:null,addr:C(i.identity.address),keyId:i.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(Ie({service:i,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(Le)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var i=ee(n.services,"authz"),s=ee(n.services,"pre-authz"),a=function(){if(s)return Promise.resolve(Ie({service:s,msg:r})).then(function(e){var r=function(e){var r=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),n=[];null!=r.proposer&&n.push(["PROPOSER",r.proposer]);for(var t,o=W(r.payer||[]);!(t=o()).done;)n.push(["PAYER",t.value]);for(var i,s=W(r.authorization||[]);!(i=s()).done;)n.push(["AUTHORIZER",i.value]);return n.map(function(e){var r=e[0],n=e[1];return{tempId:[n.identity.address,n.identity.keyId].join("|"),addr:n.identity.address,keyId:n.identity.keyId,signingFunction:function(e){return Ie({service:n,msg:e})},role:{proposer:"PROPOSER"===r,payer:"PAYER"===r,authorizer:"AUTHORIZER"===r}}})}(e);return t=1,r})}();return a&&a.then?a.then(o):o(a)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Ve=function(e){var n=void 0===e?{}:e,t=n.service,o=n.redir,i=void 0!==o&&o;try{return Promise.resolve(new Promise(function(e,n){try{Je();var o={redir:i};return Promise.resolve($e()).then(function(i){return Promise.resolve(function(){try{return Promise.resolve(r.first(["discovery.wallet","challenge.handshake"])).then(function(e){return Promise.resolve(r.get("discovery.authn.include",[])).then(function(n){return Promise.resolve(r.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(r){return{type:"authn",endpoint:e,method:r,discoveryAuthnInclude:n}})})})}catch(e){return Promise.reject(e)}}()).then(function(r){var s;function a(n){var a;if(s)return n;function d(n){if(a)return n;var i=function(e,n){try{var i=xe(function(){return Promise.resolve(Ie({service:U({},t||r,{method:(null==r?void 0:r.method)||t.method||"IFRAME/RPC"}),msg:c,opts:o,config:{discoveryAuthnInclude:r.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(Q(e)).then(function(e){E(ze,Be,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return i&&i.then?i.then(n.bind(null,!1),n.bind(null,!0)):n(!1,i)}(0,function(r,n){return Promise.resolve($e()).then(function(t){if(e(t),r)throw n;return n})});return i&&i.then?i.then(function(){}):void 0}p(t||r.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');var l=function(){if(i.loggedIn){if(u)return function(e,r){try{var n=xe(function(){return Promise.resolve(Ie({service:u,msg:c,opts:o})).then(function(e){return Promise.resolve(Q(e)).then(function(e){E(ze,Be,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return r()}return n&&n.then?n.then(r,r):r()}(0,function(){return Promise.resolve($e()).then(function(r){var n=e(r);return a=1,n})});var r=e(i);return a=1,r}}();return l&&l.then?l.then(d):d(l)}var c,u=ee(i.services,"authn-refresh"),d=xe(function(){return Promise.resolve(Ue()).then(function(e){c=e})},function(e){console.error("Error During Authentication: Could not resolve account proof data.\n "+e);var r=n(e);return s=1,r});return d&&d.then?d.then(a):a(d)})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Ue=function(){try{return Promise.resolve(r.get("fcl.accountProof.resolver")).then(function(e){function r(e){if(null!=e)return p("string"==typeof e.appIdentifier,"appIdentifier must be a string"),p(/^[0-9a-f]+$/i.test(e.nonce),"Nonce must be a hex string"),e}return e?Promise.resolve(e()).then(r):r(e)})}catch(e){return Promise.reject(e)}},ze="CURRENT_USER",We="CURRENT_USER/UPDATED",Be="SET_CURRENT_USER",Ye='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',He=((he={})[h]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(Ye)),Promise.resolve(r.first(["fcl.storage","fcl.storage.default"])).then(function(r){var n=function(){if(r.can)return Promise.resolve(function(e){try{var r=JSON.parse(Ye);return Promise.resolve(e.get(ze)).then(function(n){return null!=n&&r.f_vsn!==n.f_vsn?(e.removeItem(ze),r):n||r})}catch(e){return Promise.reject(e)}}(r)).then(function(r){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(r)&&e.merge(r)})}();if(n&&n.then)return n.then(function(){})})}catch(e){return Promise.reject(e)}},he[m]=function(e,r){e.subscribe(r.from),e.send(r.from,We,U({},e.all()))},he[y]=function(e,r){e.unsubscribe(r.from)},he.SNAPSHOT=function(e,r){try{return r.reply(U({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},he[Be]=function(e,n,t){try{return e.merge(t),Promise.resolve(r.first(["fcl.storage","fcl.storage.default"])).then(function(r){r.can&&r.put(ze,e.all()),e.broadcast(We,U({},e.all()))})}catch(e){return Promise.reject(e)}},he.DEL_CURRENT_USER=function(e,n){try{return e.merge(JSON.parse(Ye)),Promise.resolve(r.first(["fcl.storage","fcl.storage.default"])).then(function(r){r.can&&r.put(ze,e.all()),e.broadcast(We,U({},e.all()))})}catch(e){return Promise.reject(e)}},he),Je=function(){return g(He,ze)};function qe(){Je(),E(ze,"DEL_CURRENT_USER")}function Ge(e){Je();var r="@EXIT",n=g(function(n){try{var t;return n.send(ze,m),Promise.resolve(function(e,r,n){for(var t;;){var o=e();if(ke(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=n();if(i&&i.then){if(!ke(i)){t=1;break}i=i.s}}var s=new je,a=Oe.bind(null,s,2);return(0===t?o.then(u):1===t?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(u).then(void 0,a):u(o):Oe(s,1,i)})).then(void 0,a),s;function c(r){i=r;do{if(!(o=e())||ke(o)&&!o.v)return void Oe(s,1,i);if(o.then)return void o.then(u).then(void 0,a);ke(i=n())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,a)}function u(e){e?(i=n())&&i.then?i.then(c).then(void 0,a):c(i):Oe(s,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(n.receive()).then(function(o){if(o.tag===r)return n.send(ze,y),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return E(n,r)}}function $e(){return Je(),E(ze,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Ke,Xe=function(e){return p(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Ze=function(){return{authenticate:Ve,unauthenticate:qe,authorization:Me,signUserMessage:Te,verifyUserSignatures:Fe,subscribe:Ge,snapshot:$e,resolveArgument:_e}};Ze.authenticate=Ve,Ze.unauthenticate=qe,Ze.authorization=Me,Ze.signUserMessage=Te,Ze.verifyUserSignatures=Fe,Ze.subscribe=Ge,Ze.snapshot=$e,Ze.resolveArgument=_e;var Qe=function(e){try{return Promise.resolve(t([o(e)]).then(i))}catch(e){return Promise.reject(e)}},er=function(e){return e.status>=4},rr=function(e){return e.status>=3},nr=function(e){return e.status>=2},tr=((Ke={})[h]=function(e){try{return Promise.resolve(Qe(e.self())).then(function(r){er(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},Ke[m]=function(e,r){e.subscribe(r.from),e.send(r.from,P,e.all())},Ke[y]=function(e,r){e.unsubscribe(r.from)},Ke[R]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Ke.POLL=function(e){try{return Promise.resolve(Qe(e.self())).then(function(r){var n,t;er(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),n=e.all(),t=r,JSON.stringify(n)!==JSON.stringify(t)&&e.broadcast(P,r),e.merge(r)})}catch(e){return Promise.reject(e)}},Ke),or=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},ir=function(e){return g(tr,or(e))};function sr(e){function r(r){return w(or(e),ir,r)}function n(e){return function(n){void 0===n&&(n={});var t=n.suppress||!1;return new Promise(function(n,o){var i=r(function(r){r.statusCode&&!t?(o(r.errorMessage),i()):e(r)&&(n(r),i())})})}}return{snapshot:function(){return b(e,ir)},subscribe:r,onceFinalized:n(nr),onceExecuted:n(rr),onceSealed:n(er)}}sr.isUnknown=function(e){return e.status>=0},sr.isPending=function(e){return e.status>=1},sr.isFinalized=nr,sr.isExecuted=rr,sr.isSealed=er,sr.isExpired=function(e){return 5===e.status};var ar,cr=function(r){void 0===r&&(r={});try{return Promise.resolve(function(n,t){try{var o=Promise.resolve(function(r){try{return p(j(r),"mutate(opts) -- opts is required"),p(k(r),"mutate(opts) -- opts must be an object"),p(j(r.cadence),"mutate({ cadence }) -- cadence is required"),p(T(r.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){p(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(r)).then(function(){return Promise.resolve(e.config().get("fcl.authz",Ze().authorization)).then(function(n){return e.send([e.transaction(r.cadence),e.args(M(r.args||[])),r.limit&&_(r.limit)&&e.limit(r.limit),e.proposer(r.proposer||r.authz||n),e.payer(r.payer||r.authz||n),e.authorizations(r.authorizations||[r.authz||n])]).then(e.decode)})})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},ur=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(r.first(["sdk.resolve"],n.resolve||s)).then(function(r){function n(){return Promise.resolve(r(e)).then(function(e){return JSON.stringify(a(e),null,2)})}var t=function(){if(Array.isArray(e))return Promise.resolve(c(u(),e)).then(function(r){e=r})}();return t&&t.then?t.then(n):n()})}catch(e){return Promise.reject(e)}},dr=function(e){try{var n=setTimeout;return Promise.resolve(r().get("fcl.eventPollRate",1e4)).then(function(r){return n(function(){return e.sendSelf("TICK")},r)})}catch(e){return Promise.reject(e)}},lr=((ar={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var r=e.get("hwm"),n=function(){if(null==r){var n=e.put;return Promise.resolve(d()).then(function(r){n.call(e,"hwm",r);var t=e.put;return Promise.resolve(dr(e)).then(function(r){t.call(e,"tick",r)})})}return Promise.resolve(d()).then(function(n){return e.put("hwm",n),Promise.resolve(t([l(e.self(),r.height,n.height-1)]).then(i)).then(function(r){for(var n,t=W(r);!(n=t()).done;)e.broadcast("UPDATED",n.value.data);var o=e.put;return Promise.resolve(dr(e)).then(function(r){o.call(e,"tick",r)})})})}();return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},ar[m]=function(e,r){try{var n=function(){e.subscribe(r.from)},t=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(dr(e)).then(function(n){r.call(e,"tick",n)})}}();return Promise.resolve(t&&t.then?t.then(n):n())}catch(e){return Promise.reject(e)}},ar[y]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},ar),fr=function(e){return g(lr,e)};function pr(e){return{subscribe:function(r){return w(e,fr,r)}}}var vr=function(e){void 0===e&&(e=[]);try{return Promise.resolve(r.get("discovery.authn.endpoint")).then(function(n){return p(Boolean(n),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(r.get("discovery.authn.include",[])).then(function(r){var t=new URL(n);return fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:N,include:r})}).then(function(e){return e.json()}).then(function(r){return[].concat(e,r)})})})}catch(e){return Promise.reject(e)}};function hr(e){void 0===e&&(e=[]);var r=window.fcl_extensions||[];return[].concat(r,e)}var mr,yr=((mr={})[h]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((r={type:"authn"},n=r.type,function(){var e=arguments;return function(r){return[].slice.call(e).reduce(function(e,r){return e.then(r)},Promise.resolve(r))}}(vr,hr,function(e){return function(e,r){return void 0===e&&(e=[]),e.filter(function(e){return e.type===r})}(e,n)})([]))).then(function(r){e.put("results",r)})}catch(e){return Promise.reject(e)}var r,n},mr[m]=function(e,r){e.subscribe(r.from),e.send(r.from,"UPDATED",U({},e.all()))},mr[y]=function(e,r){return e.unsubscribe(r.from)},mr.SNAPSHOT=function(e,r){try{return Promise.resolve(r.reply(U({},e.all())))}catch(e){return Promise.reject(e)}},mr),gr=function(){return g(yr,"authn")},Er={authn:{subscribe:function(e){return w("authn",gr,e)},snapshot:function(){return b("authn",gr)}}},Pr=function(e,r){void 0===r&&(r=function(){});var n=function(n){var t=n.data;"object"==typeof t&&null!=typeof t&&t.type===e&&r(function(e){var r;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(r=e.body)||delete r.interaction,e}(t))};return window.addEventListener("message",n),function(){return window.removeEventListener("message",n)}},Rr=function(e,r){void 0===r&&(r={}),window.location!==window.parent.location?window.parent.postMessage(U({},r,{type:e}),"*"):window.opener.postMessage(U({},r,{type:e}),"*")},wr=function(e){return Buffer.from(e.padStart(16,0),"hex")},br=function(e){return Buffer.from(e,"hex")},Sr=function(e,r){var n=e.address,t=e.nonce,o=e.appIdentifier;void 0===r&&(r=!0),p(n,"Encode Message For Provable Authn Error: address must be defined"),p(t,"Encode Message For Provable Authn Error: nonce must be defined"),p(o,"Encode Message For Provable Authn Error: appIdentifier must be defined"),p(t.length>=64,"Encode Message For Provable Authn Error: nonce must be minimum of 32 bytes");var i,s=(i=Buffer.from("FLOW-V0.0-user").toString("hex"),Buffer.from(i.padEnd(64,0),"hex"));return r?Buffer.concat([s,A([o,wr(C(n)),br(t)])]).toString("hex"):A([o,wr(C(n)),br(t)]).toString("hex")},Cr={__proto__:null,sendMsgToFCL:Rr,ready:function(e,r){Pr("FCL:VIEW:READY:RESPONSE",e),Rr("FCL:VIEW:READY")},close:function(){Rr("FCL:VIEW:CLOSE")},approve:function(e){Rr("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){Rr("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){Rr("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:Pr,encodeMessageFromSignable:f,CompositeSignature:function(e,r,n){this.f_type=q.f_type,this.f_vsn=q.f_vsn,this.addr=S(e),this.keyId=Number(r),this.signature=n},encodeAccountProof:Sr,injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},Ir={__proto__:null,verifyAccountProof:function(e,n){var t=n.address,o=n.nonce,i=n.signatures;try{!function(e,r,n,t){p("string"==typeof e,"appIdentifier must be a string"),p(/^[0-9a-f]+$/i.test(n),"Nonce must be a hex string"),p(Array.isArray(t)&&t.every(function(e,r,n){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),p(t.map(function(e){return e.addr}).every(function(e,r,n){return e===n[0]}),"User signatures to be verified must be from a single account address")}(e,0,o,i);for(var s,a=Sr({address:t,nonce:o,appIdentifier:e},!1),c=[],u=[],d=W(i);!(s=d()).done;){var l=s.value;c.push(l.signature),u.push(l.keyId)}return Promise.resolve(function(){try{return Promise.resolve(r.get("env")).then(function(e){return"\n import FCLCrypto from "+("testnet"===e?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284")+"\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyAccountProofSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n "})}catch(e){return Promise.reject(e)}}()).then(function(e){return Promise.resolve(V({cadence:e,args:function(e,r){return[e(t,r.Address),e(a,r.String),e(u,r.Array([r.Int])),e(c,r.Array([r.String]))]}}))})}catch(e){return Promise.reject(e)}}},Ar=function(e){return void 0===e&&(e={}),Ze().authenticate(e)},Dr=function(){return Ze().unauthenticate()},Nr=function(e){return void 0===e&&(e={}),Ze().unauthenticate(),Ze().authenticate(e)},Lr=function(e){return void 0===e&&(e={}),Ze().authenticate(e)},Or=function(e){return void 0===e&&(e={}),Ze().authenticate(e)},Fr=Ze().authorization,jr=v;export{Ir as AppUtils,N as VERSION,Cr as WalletUtils,Ar as authenticate,Fr as authz,Ze as currentUser,Er as discovery,pr as events,Or as logIn,cr as mutate,V as query,Nr as reauthenticate,ur as serialize,Lr as signUp,jr as t,sr as tx,Dr as unauthenticate,De as verifyUserSignatures}; | ||
//# sourceMappingURL=fcl.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/sdk"),require("@onflow/util-invariant"),require("@onflow/types"),require("@onflow/util-actor"),require("@onflow/util-address"),require("@onflow/rlp"),require("@onflow/util-uid"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/sdk","@onflow/util-invariant","@onflow/types","@onflow/util-actor","@onflow/util-address","@onflow/rlp","@onflow/util-uid","@onflow/util-template"],n):n((e||self).fcl={},e.sdk,e.utilInvariant,e.t$1,e.utilActor,e.utilAddress,e.rlp,e.utilUid,e.utilTemplate)}(this,function(e,n,t,r,o,i,a,s,u){function c(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}}),n.default=e,n}var l=c(n),d=c(r),f=c(a),p="0.0.79-alpha.3",h=function(e){try{return Promise.resolve(n.config().where(e)).then(function(n){return Object.fromEntries(Object.entries(n).map(function(n){var t=n[1];return[n[0].replace(e,""),t]}))})}catch(e){return Promise.reject(e)}},v={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};n.config({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":v});var m=function(e){return function(n){return typeof n===e}},y=function(e){return null!=e},g=m("object"),P=m("string"),b=m("function"),E=m("number");function w(e){return b(e)?e(l.arg,d):[]}var R=function(e){return void 0===e&&(e={}),Promise.resolve(function(e){try{return t.invariant(y(e.cadence),"query({ cadence }) -- cadence is required"),t.invariant(P(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(l.config.get("accessNode.api")).then(function(e){t.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return l.send([l.script(e.cadence),l.args(w(e.args||[])),e.limit&&"number"==typeof e.limit&&l.limit(e.limit)]).then(l.decode)})};function S(){return S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},S.apply(this,arguments)}function I(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function A(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return I(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?I(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var C={f_type:"Service",f_vsn:"1.0.0"},O={f_type:"Identity",f_vsn:"1.0.0"},j={f_type:"USER",f_vsn:"1.0.0"},D={f_type:"PollingResponse",f_vsn:"1.0.0"},N={f_type:"CompositeSignature",f_vsn:"1.0.0"};function k(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({old:e},C,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function x(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function T(e){return null==e?null:(null==e.method&&(e=S({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:S({},C,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var L={"back-channel-rpc":x,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},O,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},O,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},C,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:i.withPrefix(e.addr),name:e.name,icon:e.icon}})},frame:k,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":T,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function F(e){return f.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var _=function(e){try{var n=(e=function(e){return e.addr=e.addr?i.withPrefix(e.addr):null,e.paddr=e.paddr?i.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",n),Promise.resolve(fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var t,r=A(e.authorizations);!(t=r()).done;)n.push(S({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&n.push(S({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(t){var r,o,a=(r=n,o=t,void 0===r&&(r=[]),void 0===o&&(o=[]),[].concat(r,o)).map(function(n){return function(e,n){try{return L[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,a);return S({},j,{addr:i.withPrefix(e.addr),cid:F(s),loggedIn:!0,services:a,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function U(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function B(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var t=0,r=Object.entries(e.params||{});t<r.length;t++){var o=r[t];n.searchParams.append(o[0],o[1])}return n}function M(e,n){void 0===n&&(n={});var t=n.method||"POST",r="GET"===t?void 0:JSON.stringify(n.data||e.data||{});return fetch(B(e),{method:t,headers:S({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:r}).then(function(e){return e.json()})}function V(e){var n,t;return null==e?null:"1.0.0"===e.f_vsn?e:S({},D,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(t=e.reason)?t:null,data:e.compositeSignature||e.data||S({},e)||{},updates:x(e.authorizationUpdates),local:k((e.local||[])[0])})}var H=function e(n,r){void 0===r&&(r=function(){return!0});try{if(t.invariant(n,"Missing Polling Service",{service:n}),!r())throw new Error("Externally Halted");return Promise.resolve(M(n,{method:W(n)}).then(V)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,r)})}})}catch(e){return Promise.reject(e)}},z={"HTTP/GET":"GET","HTTP/POST":"POST"},W=function(e){return t.invariant(z[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),z[e.method]},K="FCL_IFRAME";function q(e){t.invariant(!document.getElementById(K),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=K,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,function(){document.getElementById(K)&&document.getElementById(K).remove()}]}var Y=null,J=null;function G(e){var n,t;return null==Y||null!=(n=Y)&&n.closed?(t=window,Y=t.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(t.top.outerHeight/2+t.top.screenY-385)+", left="+(t.top.outerWidth/2+t.top.screenX-320))):J!==e?(Y.location.replace(e),Y.focus()):Y.focus(),J=e,[Y,function(){Y&&!Y.closed&&Y.close(),Y=null}]}var $=null,X=null;function Z(e){var n;return null==$||null!=(n=$)&&n.closed?$=window.open(e,"_blank"):X!==e?($.location.replace(e),$.focus()):$.focus(),X=e,[$,function(){$&&!$.closed&&$.close(),$=null}]}var Q,ee={"VIEW/IFRAME":q,"VIEW/POP":G,"VIEW/TAB":Z},ne=function(e,n,t,r){try{return Promise.resolve(M(e,{data:S({fclVersion:p,service:{params:e.params,data:e.data,type:e.type},config:r},n)}).then(V)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var t=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(ee[e.method](B(e),n))}catch(t){throw console.error("execLocal({service, opts = {}})",t,{service:e,opts:n}),t}}catch(e){return Promise.reject(e)}}(T(n.local))).then(function(e){var r=e[1],o=function(){try{r(),t=!1}catch(e){console.error("Frame Close Error",e)}};return H(n.updates,function(){return t}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})}catch(e){return Promise.reject(e)}},te="FCL:VIEW:CLOSE",re="FCL:VIEW:READY",oe="FCL:VIEW:RESPONSE",ie=function(e){return"string"==typeof e&&e.toLowerCase()},ae=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),se=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},ue=function(e){var n=e.close,t=e.send,r=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(ae.has(e.data.type))return;ie(e.data.type)===ie(te)&&n(),ie(e.data.type)===ie(re)&&r(e,{send:t,close:n}),ie(e.data.type)===ie(oe)&&o(e,{send:t,close:n}),i(e,{send:t,close:n}),ie(e.data.type)===ie("FCL:FRAME:READY")&&(se(e.data.type,re),r(e,{send:t,close:n})),ie(e.data.type)===ie("FCL:FRAME:RESPONSE")&&(se(e.data.type,oe),o(e,{send:t,close:n})),ie(e.data.type)===ie("FCL:FRAME:CLOSE")&&(se(e.data.type,te),n()),ie(e.data.type)===ie("FCL::CHALLENGE::RESPONSE")&&(se(e.data.type,oe),o(e,{send:t,close:n})),ie(e.data.type)===ie("FCL::AUTHZ_READY")&&(se(e.data.type,re),r(e,{send:t,close:n})),ie(e.data.type)===ie("FCL::CHALLENGE::CANCEL")&&(se(e.data.type,te),n()),ie(e.data.type)===ie("FCL::CANCEL")&&(se(e.data.type,te),n())}catch(e){console.error("Frame Callback Error",e),n()}}},ce=function(){},le=function(){},de=function(){},fe=function(){},pe=function e(n){var r=n.service,o=n.msg,i=void 0===o?{}:o,a=n.opts,s=void 0===a?{}:a,u=n.config,c=void 0===u?{}:u;try{return Promise.resolve(h(/^service\./)).then(function(n){return Promise.resolve(h(/^app\.detail\./)).then(function(o){var a=S({},c,{services:n,app:o});return function(n,o){try{var u=Promise.resolve(he[r.method](r,i,s,a)).then(function(n){return"REDIRECT"===n.status?(t.invariant(r.type===n.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:n.data,msg:i,opts:s,config:a}))):n})}catch(e){return o(e)}return u&&u.then?u.then(void 0,o):u}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:r,msg:i,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},he={"HTTP/RPC":ne,"HTTP/POST":ne,"IFRAME/RPC":function(e,n,t,r){return new Promise(function(o,i){var a,u=s.uid(),c=t.includeOlderJsonRpcCall;n.data=null!=(a=e.data)?a:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ce,close:ce};var t=n.onClose||ce;window.addEventListener("message",ue({close:a,send:s,onReady:n.onReady||ce,onResponse:n.onResponse||ce,onMessage:n.onMessage||ce}));var r=q(B(e)),o=r[0],i=r[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",ue),i(),t()}catch(e){console.error("Frame Close Error",e)}}function s(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:p,body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:u,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==u)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,t,r){return new Promise(function(o,i){var a=s.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:le,close:le};var t=n.onClose||le;window.addEventListener("message",ue({close:s,send:u,onReady:n.onReady||le,onResponse:n.onResponse||le,onMessage:n.onMessage||le}));var r=G(B(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",ue),clearInterval(a),i(),t()}catch(e){console.error("Popup Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,t,r){return new Promise(function(o,i){var a=s.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:de,close:de};var t=n.onClose||de;window.addEventListener("message",ue({close:s,send:u,onReady:n.onReady||de,onResponse:n.onResponse||de,onMessage:n.onMessage||de}));var r=Z(B(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",ue),clearInterval(a),i(),t()}catch(e){console.error("Tab Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,t,r){return new Promise(function(t,o){!function(e,n){void 0===n&&(n={});try{var t,r=function(){try{window.removeEventListener("message",ue),a()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:fe,close:fe});var i=e.endpoint,a=n.onClose||fe;window.addEventListener("message",ue({close:r,send:o,onReady:n.onReady||fe,onResponse:n.onResponse||fe,onMessage:n.onMessage||fe})),Promise.resolve(null==(t=window[i])?void 0:t.flow.enable()).then(function(){return{send:o,close:r}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=V(e.data);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},ve=function(e,n){try{me(e,n);var t=n[0].addr,r=[],o=[];return n.map(function(e){r.push(e.signature),o.push(e.keyId)}),Promise.resolve(R({cadence:ye,args:function(n,i){return[n(t,i.Address),n(e,i.String),n(o,i.Array([i.Int])),n(r,i.Array([i.String]))]}}))}catch(e){return Promise.reject(e)}},me=function(e,n){return t.invariant(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),t.invariant(Array.isArray(n)&&n.every(function(e,n,t){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),t.invariant(n.map(function(e){return e.addr}).every(function(e,n,t){return e===t[0]}),"User signatures to be verified must be from a single account address"),!0},ye='\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\n\n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_secp256k1 : SignatureAlgorithm.ECDSA_P256\n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i]\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n';function ge(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},N,{addr:i.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function Pe(e,n,t){if(!e.s){if(t instanceof Ee){if(!t.s)return void(t.o=Pe.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(Pe.bind(null,e,n),Pe.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var be=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(ve(e,n))}catch(e){return Promise.reject(e)}},Ee=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{Pe(r,1,i(this.v))}catch(e){Pe(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Pe(r,1,n?n(o):o):t?Pe(r,1,t(o)):Pe(r,2,o)}catch(e){Pe(r,2,e)}},r},e}();function we(e){return e instanceof Ee&&1&e.s}var Re=function(e){try{return Te(),Promise.resolve(Ce({redir:!0})).then(function(n){var r=U(n.services,"user-signature");return t.invariant(r,"Current user must have authorized a signing service."),Se(function(){return Promise.resolve(pe({service:r,msg:Be(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return ge(e)}):[ge(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function Se(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var Ie=function(){return Promise.resolve(Ce()).then(function(e){return n.arg(i.withPrefix(e.addr),d.Address)})},Ae=function(e){try{return Te(),Promise.resolve(S({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Ce({redir:!0})).then(function(t){var r;function o(n){if(r)return n;if(a)return S({},e,{tempId:"CURRENT_USER",resolve:null,addr:i.sansPrefix(a.identity.address),keyId:a.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(pe({service:a,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(ge)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var a=U(t.services,"authz"),s=U(t.services,"pre-authz"),u=function(){if(s)return Promise.resolve(pe({service:s,msg:n})).then(function(e){var n=function(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),t=[];null!=n.proposer&&t.push(["PROPOSER",n.proposer]);for(var r,o=A(n.payer||[]);!(r=o()).done;)t.push(["PAYER",r.value]);for(var i,a=A(n.authorization||[]);!(i=a()).done;)t.push(["AUTHORIZER",i.value]);return t.map(function(e){var n=e[0],t=e[1];return{tempId:[t.identity.address,t.identity.keyId].join("|"),addr:t.identity.address,keyId:t.identity.keyId,signingFunction:function(e){return pe({service:t,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return r=1,n})}();return u&&u.then?u.then(o):o(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Ce=function(e){var r=void 0===e?{}:e,i=r.service,a=r.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(e,r){try{return Te(),Promise.resolve(_e()).then(function(r){return Promise.resolve(Oe()).then(function(a){var u={redir:s};return Promise.resolve(function(){try{return Promise.resolve(n.config.first(["discovery.wallet","challenge.handshake"])).then(function(e){return Promise.resolve(n.config.get("discovery.authn.include",[])).then(function(t){return Promise.resolve(n.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(n){return{type:"authn",endpoint:e,method:n,discoveryAuthnInclude:t}})})})}catch(e){return Promise.reject(e)}}()).then(function(c){var l=U(r.services,"authn-refresh");return Promise.resolve(n.config.get("fcl.warning.suppress.redir")).then(function(n){var d;function f(n){if(d)return n;var t=function(e,n){try{var t=Se(function(){return Promise.resolve(pe({service:S({},i||c,{method:(null==c?void 0:c.method)||i.method||"IFRAME/RPC"}),msg:a,opts:u,config:{discoveryAuthnInclude:c.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(_(e)).then(function(e){o.send(je,Ne,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return t&&t.then?t.then(n.bind(null,!1),n.bind(null,!0)):n(!1,t)}(0,function(n,t){return Promise.resolve(_e()).then(function(r){if(e(r),n)throw t;return t})});return t&&t.then?t.then(function(){}):void 0}s&&!n&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config"),t.invariant(i||c.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');var p=function(){if(r.loggedIn){if(l)return function(e,n){try{var t=Se(function(){return Promise.resolve(pe({service:l,msg:a,opts:u})).then(function(e){return Promise.resolve(_(e)).then(function(e){o.send(je,Ne,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(0,function(){return Promise.resolve(_e()).then(function(n){var t=e(n);return d=1,t})});var n=e(r);return d=1,n}}();return p&&p.then?p.then(f):f(p)})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Oe=function(){try{var e=Date.now();return Promise.resolve(n.config.get("fcl.appDomainTag")).then(function(n){return{timestamp:e,appDomainTag:n,extensions:window.fcl_extensions||[]}})}catch(e){return Promise.reject(e)}},je="CURRENT_USER",De="CURRENT_USER/UPDATED",Ne="SET_CURRENT_USER",ke='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',xe=((Q={})[o.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(ke)),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){var t=function(){if(n.can)return Promise.resolve(function(e){try{var n=JSON.parse(ke);return Promise.resolve(e.get(je)).then(function(t){return null!=t&&n.f_vsn!==t.f_vsn?(e.removeItem(je),n):t||n})}catch(e){return Promise.reject(e)}}(n)).then(function(n){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(n)&&e.merge(n)})}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}},Q[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,De,S({},e.all()))},Q[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Q.SNAPSHOT=function(e,n){try{return n.reply(S({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},Q[Ne]=function(e,t,r){try{return e.merge(r),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(je,e.all()),e.broadcast(De,S({},e.all()))})}catch(e){return Promise.reject(e)}},Q.DEL_CURRENT_USER=function(e,t){try{return e.merge(JSON.parse(ke)),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(je,e.all()),e.broadcast(De,S({},e.all()))})}catch(e){return Promise.reject(e)}},Q),Te=function(){return o.spawn(xe,je)};function Le(){Te(),o.send(je,"DEL_CURRENT_USER")}function Fe(e){Te();var n="@EXIT",t=o.spawn(function(t){try{var r;return t.send(je,o.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(we(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!we(i)){r=1;break}i=i.s}}var a=new Ee,s=Pe.bind(null,a,2);return(0===r?o.then(c):1===r?i.then(u):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):Pe(a,1,i)})).then(void 0,s),a;function u(n){i=n;do{if(!(o=e())||we(o)&&!o.v)return void Pe(a,1,i);if(o.then)return void o.then(c).then(void 0,s);we(i=t())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,s)}function c(e){e?(i=t())&&i.then?i.then(u).then(void 0,s):u(i):Pe(a,1,i)}}(function(){return!r&&1},0,function(){return Promise.resolve(t.receive()).then(function(i){if(i.tag===n)return t.send(je,o.UNSUBSCRIBE),void(r=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return o.send(t,n)}}function _e(){return Te(),o.send(je,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Ue,Be=function(e){return t.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Me=function(){return{authenticate:Ce,unauthenticate:Le,authorization:Ae,signUserMessage:Re,verifyUserSignatures:be,subscribe:Fe,snapshot:_e,resolveArgument:Ie}};Me.authenticate=Ce,Me.unauthenticate=Le,Me.authorization=Ae,Me.signUserMessage=Re,Me.verifyUserSignatures=be,Me.subscribe=Fe,Me.snapshot=_e,Me.resolveArgument=Ie;var Ve="POLL",He=function(e){try{return Promise.resolve(n.send([n.getTransactionStatus(e)]).then(n.decode))}catch(e){return Promise.reject(e)}},ze=function(e){return e.status>=4},We=function(e){return e.status>=3},Ke=function(e){return e.status>=2},qe=((Ue={})[o.INIT]=function(e){try{return Promise.resolve(He(e.self())).then(function(n){ze(n)||setTimeout(function(){return e.sendSelf(Ve)},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Ue[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,o.UPDATED,e.all())},Ue[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Ue[o.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Ue.POLL=function(e){try{return Promise.resolve(He(e.self())).then(function(n){var t,r;ze(n)||setTimeout(function(){return e.sendSelf(Ve)},2500),t=e.all(),r=n,JSON.stringify(t)!==JSON.stringify(r)&&e.broadcast(o.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Ue),Ye=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},Je=function(e){return o.spawn(qe,Ye(e))};function Ge(e){function n(n){return o.subscriber(Ye(e),Je,n)}function t(e){return function(t){void 0===t&&(t={});var r=t.suppress||!1;return new Promise(function(t,o){var i=n(function(n){n.statusCode&&!r?(o(n.errorMessage),i()):e(n)&&(t(n),i())})})}}return{snapshot:function(){return o.snapshoter(e,Je)},subscribe:n,onceFinalized:t(Ke),onceExecuted:t(We),onceSealed:t(ze)}}Ge.isUnknown=function(e){return e.status>=0},Ge.isPending=function(e){return e.status>=1},Ge.isFinalized=Ke,Ge.isExecuted=We,Ge.isSealed=ze,Ge.isExpired=function(e){return 5===e.status};var $e,Xe=function(e){try{var t=setTimeout;return Promise.resolve(n.config().get("fcl.eventPollRate",1e4)).then(function(n){return t(function(){return e.sendSelf("TICK")},n)})}catch(e){return Promise.reject(e)}},Ze=(($e={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var t=e.get("hwm"),r=function(){if(null==t){var r=e.put;return Promise.resolve(n.latestBlock()).then(function(n){r.call(e,"hwm",n);var t=e.put;return Promise.resolve(Xe(e)).then(function(n){t.call(e,"tick",n)})})}return Promise.resolve(n.latestBlock()).then(function(r){return e.put("hwm",r),Promise.resolve(n.send([n.getEvents(e.self(),t.height,r.height-1)]).then(n.decode)).then(function(n){for(var t,r=A(n);!(t=r()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(Xe(e)).then(function(n){o.call(e,"tick",n)})})})}();return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},$e[o.SUBSCRIBE]=function(e,n){try{var t=function(){e.subscribe(n.from)},r=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(Xe(e)).then(function(t){n.call(e,"tick",t)})}}();return Promise.resolve(r&&r.then?r.then(t):t())}catch(e){return Promise.reject(e)}},$e[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},$e),Qe=function(e){return o.spawn(Ze,e)},en=function(e){void 0===e&&(e=[]);try{return Promise.resolve(n.config.get("discovery.authn.endpoint")).then(function(r){return t.invariant(Boolean(r),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(n.config.get("discovery.authn.include",[])).then(function(n){var t=new URL(r);return fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:p,include:n})}).then(function(e){return e.json()}).then(function(n){return[].concat(e,n)})})})}catch(e){return Promise.reject(e)}};function nn(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var tn,rn="authn",on=((tn={})[o.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:rn},t=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(en,nn,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,t)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,t},tn[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",S({},e.all()))},tn[o.UNSUBSCRIBE]=function(e,n){return e.unsubscribe(n.from)},tn.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(S({},e.all())))}catch(e){return Promise.reject(e)}},tn),an=function(){return o.spawn(on,rn)},sn={authn:{subscribe:function(e){return o.subscriber(rn,an,e)},snapshot:function(){return o.snapshoter(rn,an)}}},un=function(e,n){void 0===n&&(n=function(){});var t=function(t){var r=t.data;"object"==typeof r&&null!=typeof r&&r.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(r))};return window.addEventListener("message",t),function(){return window.removeEventListener("message",t)}},cn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(S({},n,{type:e}),"*"):window.opener.postMessage(S({},n,{type:e}),"*")},ln=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},dn={__proto__:null,sendMsgToFCL:cn,ready:function(e,n){un("FCL:VIEW:READY:RESPONSE",e),cn("FCL:VIEW:READY")},close:function(){cn("FCL:VIEW:CLOSE")},approve:function(e){cn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){cn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){cn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:un,encodeMessageFromSignable:n.encodeMessageFromSignable,CompositeSignature:function(e,n,t){this.f_type=N.f_type,this.f_vsn=N.f_vsn,this.addr=i.withPrefix(e),this.keyId=Number(n),this.signature=t},encodeMessageForProvableAuthnSigning:function(e,n,r){void 0===r&&(r=""),t.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),t.invariant(n,"Encode Message From Provable Authn Error: timestamp must be defined");var o=ln(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),s=ln(Buffer.from(r).toString("hex"),32).toString("hex");return o+(r?a.encode([s,i.withPrefix(e),n]).toString("hex"):a.encode([i.withPrefix(e),n]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,n,r){void 0===r&&(r=""),t.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),t.invariant(n,"Encode Message From Provable Authn Error: timestamp must be defined");var o,s=r?(o=Buffer.from(r).toString("hex"),Buffer.from(o.padEnd(64,0),"hex")).toString("hex"):null;return r?a.encode([s,i.withPrefix(e),n]).toString("hex"):a.encode([i.withPrefix(e),n]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},fn=Me().authorization,pn=d;Object.defineProperty(e,"TestUtils",{enumerable:!0,get:function(){return n.TestUtils}}),Object.defineProperty(e,"account",{enumerable:!0,get:function(){return n.account}}),Object.defineProperty(e,"arg",{enumerable:!0,get:function(){return n.arg}}),Object.defineProperty(e,"args",{enumerable:!0,get:function(){return n.args}}),Object.defineProperty(e,"atBlockHeight",{enumerable:!0,get:function(){return n.atBlockHeight}}),Object.defineProperty(e,"atBlockId",{enumerable:!0,get:function(){return n.atBlockId}}),Object.defineProperty(e,"authorization",{enumerable:!0,get:function(){return n.authorization}}),Object.defineProperty(e,"authorizations",{enumerable:!0,get:function(){return n.authorizations}}),Object.defineProperty(e,"block",{enumerable:!0,get:function(){return n.block}}),Object.defineProperty(e,"build",{enumerable:!0,get:function(){return n.build}}),Object.defineProperty(e,"config",{enumerable:!0,get:function(){return n.config}}),Object.defineProperty(e,"createSignableVoucher",{enumerable:!0,get:function(){return n.createSignableVoucher}}),Object.defineProperty(e,"decode",{enumerable:!0,get:function(){return n.decode}}),Object.defineProperty(e,"getAccount",{enumerable:!0,get:function(){return n.getAccount}}),Object.defineProperty(e,"getBlock",{enumerable:!0,get:function(){return n.getBlock}}),Object.defineProperty(e,"getBlockByHeight",{enumerable:!0,get:function(){return n.getBlockByHeight}}),Object.defineProperty(e,"getBlockById",{enumerable:!0,get:function(){return n.getBlockById}}),Object.defineProperty(e,"getBlockHeader",{enumerable:!0,get:function(){return n.getBlockHeader}}),Object.defineProperty(e,"getCollection",{enumerable:!0,get:function(){return n.getCollection}}),Object.defineProperty(e,"getEvents",{enumerable:!0,get:function(){return n.getEvents}}),Object.defineProperty(e,"getEventsAtBlockHeightRange",{enumerable:!0,get:function(){return n.getEventsAtBlockHeightRange}}),Object.defineProperty(e,"getEventsAtBlockIds",{enumerable:!0,get:function(){return n.getEventsAtBlockIds}}),Object.defineProperty(e,"getLatestBlock",{enumerable:!0,get:function(){return n.getLatestBlock}}),Object.defineProperty(e,"getTransaction",{enumerable:!0,get:function(){return n.getTransaction}}),Object.defineProperty(e,"getTransactionStatus",{enumerable:!0,get:function(){return n.getTransactionStatus}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n.invariant}}),Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return n.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return n.isOk}}),Object.defineProperty(e,"latestBlock",{enumerable:!0,get:function(){return n.latestBlock}}),Object.defineProperty(e,"limit",{enumerable:!0,get:function(){return n.limit}}),Object.defineProperty(e,"param",{enumerable:!0,get:function(){return n.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return n.params}}),Object.defineProperty(e,"payer",{enumerable:!0,get:function(){return n.payer}}),Object.defineProperty(e,"ping",{enumerable:!0,get:function(){return n.ping}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return n.pipe}}),Object.defineProperty(e,"proposer",{enumerable:!0,get:function(){return n.proposer}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return n.ref}}),Object.defineProperty(e,"script",{enumerable:!0,get:function(){return n.script}}),Object.defineProperty(e,"send",{enumerable:!0,get:function(){return n.send}}),Object.defineProperty(e,"transaction",{enumerable:!0,get:function(){return n.transaction}}),Object.defineProperty(e,"validator",{enumerable:!0,get:function(){return n.validator}}),Object.defineProperty(e,"voucherIntercept",{enumerable:!0,get:function(){return n.voucherIntercept}}),Object.defineProperty(e,"voucherToTxId",{enumerable:!0,get:function(){return n.voucherToTxId}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return n.why}}),Object.defineProperty(e,"display",{enumerable:!0,get:function(){return i.display}}),Object.defineProperty(e,"sansPrefix",{enumerable:!0,get:function(){return i.sansPrefix}}),Object.defineProperty(e,"withPrefix",{enumerable:!0,get:function(){return i.withPrefix}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return u.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return u.template}}),e.VERSION=p,e.WalletUtils=dn,e.authenticate=function(e){return void 0===e&&(e={}),Me().authenticate(e)},e.authz=fn,e.currentUser=Me,e.discovery=sn,e.events=function(e){return{subscribe:function(n){return o.subscriber(e,Qe,n)}}},e.logIn=function(e){return void 0===e&&(e={}),Me().authenticate(e)},e.mutate=function(e){void 0===e&&(e={});try{return Promise.resolve(function(n,r){try{var o=Promise.resolve(function(e){try{return t.invariant(y(e),"mutate(opts) -- opts is required"),t.invariant(g(e),"mutate(opts) -- opts must be an object"),t.invariant(y(e.cadence),"mutate({ cadence }) -- cadence is required"),t.invariant(P(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(l.config.get("accessNode.api")).then(function(e){t.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return Promise.resolve(l.config().get("fcl.authz",Me().authorization)).then(function(n){return l.send([l.transaction(e.cadence),l.args(w(e.args||[])),e.limit&&E(e.limit)&&l.limit(e.limit),l.proposer(e.proposer||e.authz||n),l.payer(e.payer||e.authz||n),l.authorizations(e.authorizations||[e.authz||n])]).then(l.decode)})})}catch(e){return r(e)}return o&&o.then?o.then(void 0,r):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},e.query=R,e.reauthenticate=function(e){return void 0===e&&(e={}),Me().unauthenticate(),Me().authenticate(e)},e.serialize=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});try{return Promise.resolve(n.config.first(["sdk.resolve"],t.resolve||n.resolve)).then(function(t){function r(){return Promise.resolve(t(e)).then(function(e){return JSON.stringify(n.createSignableVoucher(e),null,2)})}var o=function(){if(Array.isArray(e))return Promise.resolve(n.pipe(n.interaction(),e)).then(function(n){e=n})}();return o&&o.then?o.then(r):r()})}catch(e){return Promise.reject(e)}},e.signUp=function(e){return void 0===e&&(e={}),Me().authenticate(e)},e.t=pn,e.tx=Ge,e.unauthenticate=function(){return Me().unauthenticate()},e.verifyUserSignatures=ve}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/sdk"),require("@onflow/util-invariant"),require("@onflow/types"),require("@onflow/util-actor"),require("@onflow/util-address"),require("@onflow/rlp"),require("@onflow/util-uid"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/sdk","@onflow/util-invariant","@onflow/types","@onflow/util-actor","@onflow/util-address","@onflow/rlp","@onflow/util-uid","@onflow/util-template"],n):n((e||self).fcl={},e.sdk,e.utilInvariant,e.t$1,e.utilActor,e.utilAddress,e.rlp,e.utilUid,e.utilTemplate)}(this,function(e,n,r,t,o,i,a,s,u){function c(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),n.default=e,n}var d=c(n),f=c(t),l=c(a),p="0.0.79-alpha.4",v=function(e){try{return Promise.resolve(n.config().where(e)).then(function(n){return Object.fromEntries(Object.entries(n).map(function(n){var r=n[1];return[n[0].replace(e,""),r]}))})}catch(e){return Promise.reject(e)}},h={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};n.config({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":h});var m=function(e){return function(n){return typeof n===e}},y=function(e){return null!=e},g=m("object"),P=m("string"),b=m("function"),E=m("number");function R(e){return b(e)?e(d.arg,f):[]}var w=function(e){return void 0===e&&(e={}),Promise.resolve(function(e){try{return r.invariant(y(e.cadence),"query({ cadence }) -- cadence is required"),r.invariant(P(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(d.config.get("accessNode.api")).then(function(e){r.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return d.send([d.script(e.cadence),d.args(R(e.args||[])),e.limit&&"number"==typeof e.limit&&d.limit(e.limit)]).then(d.decode)})};function S(){return S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},S.apply(this,arguments)}function I(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function C(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return I(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var O={f_type:"Service",f_vsn:"1.0.0"},j={f_type:"Identity",f_vsn:"1.0.0"},A={f_type:"USER",f_vsn:"1.0.0"},N={f_type:"PollingResponse",f_vsn:"1.0.0"},D={f_type:"CompositeSignature",f_vsn:"1.0.0"};function k(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({old:e},O,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function T(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},O,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function L(e){return null==e?null:(null==e.method&&(e=S({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:S({},O,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var x={"back-channel-rpc":T,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},O,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},j,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},O,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},j,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},O,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:i.withPrefix(e.addr),name:e.name,icon:e.icon}})},frame:k,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":L,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("FCL Normalizer Error: Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function F(e){return l.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var _=function(e){try{var n=(e=function(e){return e.addr=e.addr?i.withPrefix(e.addr):null,e.paddr=e.paddr?i.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var r=new URL(e);return r.searchParams.append("code",n),Promise.resolve(fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var r,t=C(e.authorizations);!(r=t()).done;)n.push(S({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&n.push(S({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(r){var t,o,a=(t=n,o=r,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o)).map(function(n){return function(e,n){try{return x[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,a);return S({},A,{addr:i.withPrefix(e.addr),cid:F(s),loggedIn:!0,services:a,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function U(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function B(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var r=0,t=Object.entries(e.params||{});r<t.length;r++){var o=t[r];n.searchParams.append(o[0],o[1])}return n}function M(e,n){void 0===n&&(n={});var r=n.method||"POST",t="GET"===r?void 0:JSON.stringify(n.data||e.data||{});return fetch(B(e),{method:r,headers:S({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function V(e){var n,r;return null==e?null:"1.0.0"===e.f_vsn?e:S({},N,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(r=e.reason)?r:null,data:e.compositeSignature||e.data||S({},e)||{},updates:T(e.authorizationUpdates),local:k((e.local||[])[0])})}var z=function e(n,t){void 0===t&&(t=function(){return!0});try{if(r.invariant(n,"Missing Polling Service",{service:n}),!t())throw new Error("Externally Halted");return Promise.resolve(M(n,{method:W(n)}).then(V)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,t)})}})}catch(e){return Promise.reject(e)}},H={"HTTP/GET":"GET","HTTP/POST":"POST"},W=function(e){return r.invariant(H[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),H[e.method]},J="FCL_IFRAME";function Y(e){r.invariant(!document.getElementById(J),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=J,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100%;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,function(){document.getElementById(J)&&document.getElementById(J).remove()}]}var q=null,G=null;function $(e){var n,r;return null==q||null!=(n=q)&&n.closed?(r=window,q=r.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(r.top.outerHeight/2+r.top.screenY-385)+", left="+(r.top.outerWidth/2+r.top.screenX-320))):G!==e?(q.location.replace(e),q.focus()):q.focus(),G=e,[q,function(){q&&!q.closed&&q.close(),q=null}]}var K=null,X=null;function Z(e){var n;return null==K||null!=(n=K)&&n.closed?K=window.open(e,"_blank"):X!==e?(K.location.replace(e),K.focus()):K.focus(),X=e,[K,function(){K&&!K.closed&&K.close(),K=null}]}var Q,ee={"VIEW/IFRAME":Y,"VIEW/POP":$,"VIEW/TAB":Z},ne=function(e,n,r,t){try{return Promise.resolve(M(e,{data:S({fclVersion:p,service:{params:e.params,data:e.data,type:e.type},config:t},n)}).then(V)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var r=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(ee[e.method](B(e),n))}catch(r){throw console.error("execLocal({service, opts = {}})",r,{service:e,opts:n}),r}}catch(e){return Promise.reject(e)}}(L(n.local))).then(function(e){var t=e[1],o=function(){try{t(),r=!1}catch(e){console.error("Frame Close Error",e)}};return z(n.updates,function(){return r}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})}catch(e){return Promise.reject(e)}},re="FCL:VIEW:CLOSE",te="FCL:VIEW:READY",oe="FCL:VIEW:RESPONSE",ie=function(e){return"string"==typeof e&&e.toLowerCase()},ae=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),se=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},ue=function(e){var n=e.close,r=e.send,t=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(ae.has(e.data.type))return;ie(e.data.type)===ie(re)&&n(),ie(e.data.type)===ie(te)&&t(e,{send:r,close:n}),ie(e.data.type)===ie(oe)&&o(e,{send:r,close:n}),i(e,{send:r,close:n}),ie(e.data.type)===ie("FCL:FRAME:READY")&&(se(e.data.type,te),t(e,{send:r,close:n})),ie(e.data.type)===ie("FCL:FRAME:RESPONSE")&&(se(e.data.type,oe),o(e,{send:r,close:n})),ie(e.data.type)===ie("FCL:FRAME:CLOSE")&&(se(e.data.type,re),n()),ie(e.data.type)===ie("FCL::CHALLENGE::RESPONSE")&&(se(e.data.type,oe),o(e,{send:r,close:n})),ie(e.data.type)===ie("FCL::AUTHZ_READY")&&(se(e.data.type,te),t(e,{send:r,close:n})),ie(e.data.type)===ie("FCL::CHALLENGE::CANCEL")&&(se(e.data.type,re),n()),ie(e.data.type)===ie("FCL::CANCEL")&&(se(e.data.type,re),n())}catch(e){console.error("Frame Callback Error",e),n()}}},ce=function(){},de=function(){},fe=function(){},le=function(){},pe=function e(n){var t=n.service,o=n.msg,i=void 0===o?{}:o,a=n.opts,s=void 0===a?{}:a,u=n.config,c=void 0===u?{}:u;try{return i.extensions=window.fcl_extensions||[],i.data=t.data,Promise.resolve(v(/^service\./)).then(function(n){return Promise.resolve(v(/^app\.detail\./)).then(function(o){var a=S({},c,{services:n,app:o});return function(n,o){try{var u=Promise.resolve(ve[t.method](t,i,s,a)).then(function(n){return"REDIRECT"===n.status?(r.invariant(t.type===n.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:n.data,msg:i,opts:s,config:a}))):n})}catch(e){return o(e)}return u&&u.then?u.then(void 0,o):u}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:t,msg:i,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},ve={"HTTP/RPC":ne,"HTTP/POST":ne,"IFRAME/RPC":function(e,n,r,t){return new Promise(function(o,i){var a=s.uid(),u=r.includeOlderJsonRpcCall;!function(e,n){if(void 0===n&&(n={}),null==e)return{send:ce,close:ce};var r=n.onClose||ce;window.addEventListener("message",ue({close:a,send:s,onReady:n.onReady||ce,onResponse:n.onResponse||ce,onMessage:n.onMessage||ce}));var t=Y(B(e)),o=t[0],i=t[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",ue),i(),r()}catch(e){console.error("Frame Close Error",e)}}function s(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:p,body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=V(e.data);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var t=V(e.data.result);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,r,t){return new Promise(function(o,i){var a=s.uid(),u=r.redir,c=r.includeOlderJsonRpcCall;!function(e,n){if(void 0===n&&(n={}),null==e)return{send:de,close:de};var r=n.onClose||de;window.addEventListener("message",ue({close:s,send:u,onReady:n.onReady||de,onResponse:n.onResponse||de,onMessage:n.onMessage||de}));var t=$(B(e)),o=t[0],i=t[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",ue),clearInterval(a),i(),r()}catch(e){console.error("Popup Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=V(e.data);switch(t.status){case"APPROVED":o(t.data),!u&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var t=V(e.data.result);switch(t.status){case"APPROVED":o(t.data),!u&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,r,t){return new Promise(function(o,i){var a=s.uid(),u=r.redir,c=r.includeOlderJsonRpcCall;!function(e,n){if(void 0===n&&(n={}),null==e)return{send:fe,close:fe};var r=n.onClose||fe;window.addEventListener("message",ue({close:s,send:u,onReady:n.onReady||fe,onResponse:n.onResponse||fe,onMessage:n.onMessage||fe}));var t=Z(B(e)),o=t[0],i=t[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",ue),clearInterval(a),i(),r()}catch(e){console.error("Tab Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=V(e.data);switch(t.status){case"APPROVED":o(t.data),!u&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var t=V(e.data.result);switch(t.status){case"APPROVED":o(t.data),!u&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,r,t){return new Promise(function(r,o){!function(e,n){void 0===n&&(n={});try{var r,t=function(){try{window.removeEventListener("message",ue),a()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:le,close:le});var i=e.endpoint,a=n.onClose||le;window.addEventListener("message",ue({close:t,send:o,onReady:n.onReady||le,onResponse:n.onResponse||le,onMessage:n.onMessage||le})),Promise.resolve(null==(r=window[i])?void 0:r.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var i=V(e.data);switch(i.status){case"APPROVED":r(i.data),t();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),t();break;case"REDIRECT":r(i),t();break;default:o("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},he=function(e,r){try{me(e,r);for(var t,o=r[0].addr,i=[],a=[],s=C(r);!(t=s()).done;){var u=t.value;i.push(u.signature),a.push(u.keyId)}return Promise.resolve(function(){try{return Promise.resolve(n.config.get("env")).then(function(e){return"\n import FCLCrypto from "+("testnet"===e?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284")+"\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyUserSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n "})}catch(e){return Promise.reject(e)}}()).then(function(n){return Promise.resolve(w({cadence:n,args:function(n,r){return[n(o,r.Address),n(e,r.String),n(a,r.Array([r.Int])),n(i,r.Array([r.String]))]}}))})}catch(e){return Promise.reject(e)}},me=function(e,n){return r.invariant(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),r.invariant(Array.isArray(n)&&n.every(function(e,n,r){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),r.invariant(n.map(function(e){return e.addr}).every(function(e,n,r){return e===r[0]}),"User signatures to be verified must be from a single account address"),!0};function ye(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},D,{addr:i.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function ge(e,n,r){if(!e.s){if(r instanceof be){if(!r.s)return void(r.o=ge.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(ge.bind(null,e,n),ge.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var Pe=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(he(e,n))}catch(e){return Promise.reject(e)}},be=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{ge(t,1,i(this.v))}catch(e){ge(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?ge(t,1,n?n(o):o):r?ge(t,1,r(o)):ge(t,2,o)}catch(e){ge(t,2,e)}},t},e}();function Ee(e){return e instanceof be&&1&e.s}var Re=function(e){try{return Te(),Promise.resolve(Ce({redir:!0})).then(function(n){var t=U(n.services,"user-signature");return r.invariant(t,"Current user must have authorized a signing service."),we(function(){return Promise.resolve(pe({service:t,msg:Ue(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return ye(e)}):[ye(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function we(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}var Se=function(){return Promise.resolve(Ce()).then(function(e){return n.arg(i.withPrefix(e.addr),f.Address)})},Ie=function(e){try{return Te(),Promise.resolve(S({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Ce({redir:!0})).then(function(r){var t;function o(n){if(t)return n;if(a)return S({},e,{tempId:"CURRENT_USER",resolve:null,addr:i.sansPrefix(a.identity.address),keyId:a.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(pe({service:a,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(ye)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var a=U(r.services,"authz"),s=U(r.services,"pre-authz"),u=function(){if(s)return Promise.resolve(pe({service:s,msg:n})).then(function(e){var n=function(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),r=[];null!=n.proposer&&r.push(["PROPOSER",n.proposer]);for(var t,o=C(n.payer||[]);!(t=o()).done;)r.push(["PAYER",t.value]);for(var i,a=C(n.authorization||[]);!(i=a()).done;)r.push(["AUTHORIZER",i.value]);return r.map(function(e){var n=e[0],r=e[1];return{tempId:[r.identity.address,r.identity.keyId].join("|"),addr:r.identity.address,keyId:r.identity.keyId,signingFunction:function(e){return pe({service:r,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return t=1,n})}();return u&&u.then?u.then(o):o(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Ce=function(e){var t=void 0===e?{}:e,i=t.service,a=t.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(e,t){try{Te();var a={redir:s};return Promise.resolve(Fe()).then(function(s){return Promise.resolve(function(){try{return Promise.resolve(n.config.first(["discovery.wallet","challenge.handshake"])).then(function(e){return Promise.resolve(n.config.get("discovery.authn.include",[])).then(function(r){return Promise.resolve(n.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(n){return{type:"authn",endpoint:e,method:n,discoveryAuthnInclude:r}})})})}catch(e){return Promise.reject(e)}}()).then(function(n){var u;function c(t){var c;if(u)return t;function l(r){if(c)return r;var t=function(e,r){try{var t=we(function(){return Promise.resolve(pe({service:S({},i||n,{method:(null==n?void 0:n.method)||i.method||"IFRAME/RPC"}),msg:d,opts:a,config:{discoveryAuthnInclude:n.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(_(e)).then(function(e){o.send(je,Ne,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return r(!0,e)}return t&&t.then?t.then(r.bind(null,!1),r.bind(null,!0)):r(!1,t)}(0,function(n,r){return Promise.resolve(Fe()).then(function(t){if(e(t),n)throw r;return r})});return t&&t.then?t.then(function(){}):void 0}r.invariant(i||n.endpoint,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');var p=function(){if(s.loggedIn){if(f)return function(e,n){try{var r=we(function(){return Promise.resolve(pe({service:f,msg:d,opts:a})).then(function(e){return Promise.resolve(_(e)).then(function(e){o.send(je,Ne,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return r&&r.then?r.then(n,n):n()}(0,function(){return Promise.resolve(Fe()).then(function(n){var r=e(n);return c=1,r})});var n=e(s);return c=1,n}}();return p&&p.then?p.then(l):l(p)}var d,f=U(s.services,"authn-refresh"),l=we(function(){return Promise.resolve(Oe()).then(function(e){d=e})},function(e){console.error("Error During Authentication: Could not resolve account proof data.\n "+e);var n=t(e);return u=1,n});return l&&l.then?l.then(c):c(l)})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Oe=function(){try{return Promise.resolve(n.config.get("fcl.accountProof.resolver")).then(function(e){function n(e){if(null!=e)return r.invariant("string"==typeof e.appIdentifier,"appIdentifier must be a string"),r.invariant(/^[0-9a-f]+$/i.test(e.nonce),"Nonce must be a hex string"),e}return e?Promise.resolve(e()).then(n):n(e)})}catch(e){return Promise.reject(e)}},je="CURRENT_USER",Ae="CURRENT_USER/UPDATED",Ne="SET_CURRENT_USER",De='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',ke=((Q={})[o.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(De)),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){var r=function(){if(n.can)return Promise.resolve(function(e){try{var n=JSON.parse(De);return Promise.resolve(e.get(je)).then(function(r){return null!=r&&n.f_vsn!==r.f_vsn?(e.removeItem(je),n):r||n})}catch(e){return Promise.reject(e)}}(n)).then(function(n){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(n)&&e.merge(n)})}();if(r&&r.then)return r.then(function(){})})}catch(e){return Promise.reject(e)}},Q[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,Ae,S({},e.all()))},Q[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Q.SNAPSHOT=function(e,n){try{return n.reply(S({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},Q[Ne]=function(e,r,t){try{return e.merge(t),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(je,e.all()),e.broadcast(Ae,S({},e.all()))})}catch(e){return Promise.reject(e)}},Q.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(De)),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(je,e.all()),e.broadcast(Ae,S({},e.all()))})}catch(e){return Promise.reject(e)}},Q),Te=function(){return o.spawn(ke,je)};function Le(){Te(),o.send(je,"DEL_CURRENT_USER")}function xe(e){Te();var n="@EXIT",r=o.spawn(function(r){try{var t;return r.send(je,o.SUBSCRIBE),Promise.resolve(function(e,n,r){for(var t;;){var o=e();if(Ee(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=r();if(i&&i.then){if(!Ee(i)){t=1;break}i=i.s}}var a=new be,s=ge.bind(null,a,2);return(0===t?o.then(c):1===t?i.then(u):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):ge(a,1,i)})).then(void 0,s),a;function u(n){i=n;do{if(!(o=e())||Ee(o)&&!o.v)return void ge(a,1,i);if(o.then)return void o.then(c).then(void 0,s);Ee(i=r())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,s)}function c(e){e?(i=r())&&i.then?i.then(u).then(void 0,s):u(i):ge(a,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(i){if(i.tag===n)return r.send(je,o.UNSUBSCRIBE),void(t=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return o.send(r,n)}}function Fe(){return Te(),o.send(je,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var _e,Ue=function(e){return r.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Be=function(){return{authenticate:Ce,unauthenticate:Le,authorization:Ie,signUserMessage:Re,verifyUserSignatures:Pe,subscribe:xe,snapshot:Fe,resolveArgument:Se}};Be.authenticate=Ce,Be.unauthenticate=Le,Be.authorization=Ie,Be.signUserMessage=Re,Be.verifyUserSignatures=Pe,Be.subscribe=xe,Be.snapshot=Fe,Be.resolveArgument=Se;var Me="POLL",Ve=function(e){try{return Promise.resolve(n.send([n.getTransactionStatus(e)]).then(n.decode))}catch(e){return Promise.reject(e)}},ze=function(e){return e.status>=4},He=function(e){return e.status>=3},We=function(e){return e.status>=2},Je=((_e={})[o.INIT]=function(e){try{return Promise.resolve(Ve(e.self())).then(function(n){ze(n)||setTimeout(function(){return e.sendSelf(Me)},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},_e[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,o.UPDATED,e.all())},_e[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},_e[o.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},_e.POLL=function(e){try{return Promise.resolve(Ve(e.self())).then(function(n){var r,t;ze(n)||setTimeout(function(){return e.sendSelf(Me)},2500),r=e.all(),t=n,JSON.stringify(r)!==JSON.stringify(t)&&e.broadcast(o.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},_e),Ye=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},qe=function(e){return o.spawn(Je,Ye(e))};function Ge(e){function n(n){return o.subscriber(Ye(e),qe,n)}function r(e){return function(r){void 0===r&&(r={});var t=r.suppress||!1;return new Promise(function(r,o){var i=n(function(n){n.statusCode&&!t?(o(n.errorMessage),i()):e(n)&&(r(n),i())})})}}return{snapshot:function(){return o.snapshoter(e,qe)},subscribe:n,onceFinalized:r(We),onceExecuted:r(He),onceSealed:r(ze)}}Ge.isUnknown=function(e){return e.status>=0},Ge.isPending=function(e){return e.status>=1},Ge.isFinalized=We,Ge.isExecuted=He,Ge.isSealed=ze,Ge.isExpired=function(e){return 5===e.status};var $e,Ke=function(e){try{var r=setTimeout;return Promise.resolve(n.config().get("fcl.eventPollRate",1e4)).then(function(n){return r(function(){return e.sendSelf("TICK")},n)})}catch(e){return Promise.reject(e)}},Xe=(($e={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var r=e.get("hwm"),t=function(){if(null==r){var t=e.put;return Promise.resolve(n.latestBlock()).then(function(n){t.call(e,"hwm",n);var r=e.put;return Promise.resolve(Ke(e)).then(function(n){r.call(e,"tick",n)})})}return Promise.resolve(n.latestBlock()).then(function(t){return e.put("hwm",t),Promise.resolve(n.send([n.getEvents(e.self(),r.height,t.height-1)]).then(n.decode)).then(function(n){for(var r,t=C(n);!(r=t()).done;)e.broadcast("UPDATED",r.value.data);var o=e.put;return Promise.resolve(Ke(e)).then(function(n){o.call(e,"tick",n)})})})}();return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},$e[o.SUBSCRIBE]=function(e,n){try{var r=function(){e.subscribe(n.from)},t=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(Ke(e)).then(function(r){n.call(e,"tick",r)})}}();return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},$e[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},$e),Ze=function(e){return o.spawn(Xe,e)},Qe=function(e){void 0===e&&(e=[]);try{return Promise.resolve(n.config.get("discovery.authn.endpoint")).then(function(t){return r.invariant(Boolean(t),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(n.config.get("discovery.authn.include",[])).then(function(n){var r=new URL(t);return fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:p,include:n})}).then(function(e){return e.json()}).then(function(n){return[].concat(e,n)})})})}catch(e){return Promise.reject(e)}};function en(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var nn,rn="authn",tn=((nn={})[o.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:rn},r=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(Qe,en,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,r)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,r},nn[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",S({},e.all()))},nn[o.UNSUBSCRIBE]=function(e,n){return e.unsubscribe(n.from)},nn.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(S({},e.all())))}catch(e){return Promise.reject(e)}},nn),on=function(){return o.spawn(tn,rn)},an={authn:{subscribe:function(e){return o.subscriber(rn,on,e)},snapshot:function(){return o.snapshoter(rn,on)}}},sn=function(e,n){void 0===n&&(n=function(){});var r=function(r){var t=r.data;"object"==typeof t&&null!=typeof t&&t.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(t))};return window.addEventListener("message",r),function(){return window.removeEventListener("message",r)}},un=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(S({},n,{type:e}),"*"):window.opener.postMessage(S({},n,{type:e}),"*")},cn=function(e){return Buffer.from(e.padStart(16,0),"hex")},dn=function(e){return Buffer.from(e,"hex")},fn=function(e,n){var t=e.address,o=e.nonce,s=e.appIdentifier;void 0===n&&(n=!0),r.invariant(t,"Encode Message For Provable Authn Error: address must be defined"),r.invariant(o,"Encode Message For Provable Authn Error: nonce must be defined"),r.invariant(s,"Encode Message For Provable Authn Error: appIdentifier must be defined"),r.invariant(o.length>=64,"Encode Message For Provable Authn Error: nonce must be minimum of 32 bytes");var u,c=(u=Buffer.from("FLOW-V0.0-user").toString("hex"),Buffer.from(u.padEnd(64,0),"hex"));return n?Buffer.concat([c,a.encode([s,cn(i.sansPrefix(t)),dn(o)])]).toString("hex"):a.encode([s,cn(i.sansPrefix(t)),dn(o)]).toString("hex")},ln={__proto__:null,sendMsgToFCL:un,ready:function(e,n){sn("FCL:VIEW:READY:RESPONSE",e),un("FCL:VIEW:READY")},close:function(){un("FCL:VIEW:CLOSE")},approve:function(e){un("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){un("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){un("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:sn,encodeMessageFromSignable:n.encodeMessageFromSignable,CompositeSignature:function(e,n,r){this.f_type=D.f_type,this.f_vsn=D.f_vsn,this.addr=i.withPrefix(e),this.keyId=Number(n),this.signature=r},encodeAccountProof:fn,injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},pn={__proto__:null,verifyAccountProof:function(e,t){var o=t.address,i=t.nonce,a=t.signatures;try{!function(e,n,t,o){r.invariant("string"==typeof e,"appIdentifier must be a string"),r.invariant(/^[0-9a-f]+$/i.test(t),"Nonce must be a hex string"),r.invariant(Array.isArray(o)&&o.every(function(e,n,r){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),r.invariant(o.map(function(e){return e.addr}).every(function(e,n,r){return e===r[0]}),"User signatures to be verified must be from a single account address")}(e,0,i,a);for(var s,u=fn({address:o,nonce:i,appIdentifier:e},!1),c=[],d=[],f=C(a);!(s=f()).done;){var l=s.value;c.push(l.signature),d.push(l.keyId)}return Promise.resolve(function(){try{return Promise.resolve(n.config.get("env")).then(function(e){return"\n import FCLCrypto from "+("testnet"===e?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284")+"\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyAccountProofSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n "})}catch(e){return Promise.reject(e)}}()).then(function(e){return Promise.resolve(w({cadence:e,args:function(e,n){return[e(o,n.Address),e(u,n.String),e(d,n.Array([n.Int])),e(c,n.Array([n.String]))]}}))})}catch(e){return Promise.reject(e)}}},vn=Be().authorization,hn=f;Object.defineProperty(e,"TestUtils",{enumerable:!0,get:function(){return n.TestUtils}}),Object.defineProperty(e,"account",{enumerable:!0,get:function(){return n.account}}),Object.defineProperty(e,"arg",{enumerable:!0,get:function(){return n.arg}}),Object.defineProperty(e,"args",{enumerable:!0,get:function(){return n.args}}),Object.defineProperty(e,"atBlockHeight",{enumerable:!0,get:function(){return n.atBlockHeight}}),Object.defineProperty(e,"atBlockId",{enumerable:!0,get:function(){return n.atBlockId}}),Object.defineProperty(e,"authorization",{enumerable:!0,get:function(){return n.authorization}}),Object.defineProperty(e,"authorizations",{enumerable:!0,get:function(){return n.authorizations}}),Object.defineProperty(e,"block",{enumerable:!0,get:function(){return n.block}}),Object.defineProperty(e,"build",{enumerable:!0,get:function(){return n.build}}),Object.defineProperty(e,"config",{enumerable:!0,get:function(){return n.config}}),Object.defineProperty(e,"createSignableVoucher",{enumerable:!0,get:function(){return n.createSignableVoucher}}),Object.defineProperty(e,"decode",{enumerable:!0,get:function(){return n.decode}}),Object.defineProperty(e,"getAccount",{enumerable:!0,get:function(){return n.getAccount}}),Object.defineProperty(e,"getBlock",{enumerable:!0,get:function(){return n.getBlock}}),Object.defineProperty(e,"getBlockByHeight",{enumerable:!0,get:function(){return n.getBlockByHeight}}),Object.defineProperty(e,"getBlockById",{enumerable:!0,get:function(){return n.getBlockById}}),Object.defineProperty(e,"getBlockHeader",{enumerable:!0,get:function(){return n.getBlockHeader}}),Object.defineProperty(e,"getCollection",{enumerable:!0,get:function(){return n.getCollection}}),Object.defineProperty(e,"getEvents",{enumerable:!0,get:function(){return n.getEvents}}),Object.defineProperty(e,"getEventsAtBlockHeightRange",{enumerable:!0,get:function(){return n.getEventsAtBlockHeightRange}}),Object.defineProperty(e,"getEventsAtBlockIds",{enumerable:!0,get:function(){return n.getEventsAtBlockIds}}),Object.defineProperty(e,"getLatestBlock",{enumerable:!0,get:function(){return n.getLatestBlock}}),Object.defineProperty(e,"getTransaction",{enumerable:!0,get:function(){return n.getTransaction}}),Object.defineProperty(e,"getTransactionStatus",{enumerable:!0,get:function(){return n.getTransactionStatus}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n.invariant}}),Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return n.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return n.isOk}}),Object.defineProperty(e,"latestBlock",{enumerable:!0,get:function(){return n.latestBlock}}),Object.defineProperty(e,"limit",{enumerable:!0,get:function(){return n.limit}}),Object.defineProperty(e,"param",{enumerable:!0,get:function(){return n.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return n.params}}),Object.defineProperty(e,"payer",{enumerable:!0,get:function(){return n.payer}}),Object.defineProperty(e,"ping",{enumerable:!0,get:function(){return n.ping}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return n.pipe}}),Object.defineProperty(e,"proposer",{enumerable:!0,get:function(){return n.proposer}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return n.ref}}),Object.defineProperty(e,"script",{enumerable:!0,get:function(){return n.script}}),Object.defineProperty(e,"send",{enumerable:!0,get:function(){return n.send}}),Object.defineProperty(e,"transaction",{enumerable:!0,get:function(){return n.transaction}}),Object.defineProperty(e,"validator",{enumerable:!0,get:function(){return n.validator}}),Object.defineProperty(e,"voucherIntercept",{enumerable:!0,get:function(){return n.voucherIntercept}}),Object.defineProperty(e,"voucherToTxId",{enumerable:!0,get:function(){return n.voucherToTxId}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return n.why}}),Object.defineProperty(e,"display",{enumerable:!0,get:function(){return i.display}}),Object.defineProperty(e,"sansPrefix",{enumerable:!0,get:function(){return i.sansPrefix}}),Object.defineProperty(e,"withPrefix",{enumerable:!0,get:function(){return i.withPrefix}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return u.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return u.template}}),e.AppUtils=pn,e.VERSION=p,e.WalletUtils=ln,e.authenticate=function(e){return void 0===e&&(e={}),Be().authenticate(e)},e.authz=vn,e.currentUser=Be,e.discovery=an,e.events=function(e){return{subscribe:function(n){return o.subscriber(e,Ze,n)}}},e.logIn=function(e){return void 0===e&&(e={}),Be().authenticate(e)},e.mutate=function(e){void 0===e&&(e={});try{return Promise.resolve(function(n,t){try{var o=Promise.resolve(function(e){try{return r.invariant(y(e),"mutate(opts) -- opts is required"),r.invariant(g(e),"mutate(opts) -- opts must be an object"),r.invariant(y(e.cadence),"mutate({ cadence }) -- cadence is required"),r.invariant(P(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(d.config.get("accessNode.api")).then(function(e){r.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return Promise.resolve(d.config().get("fcl.authz",Be().authorization)).then(function(n){return d.send([d.transaction(e.cadence),d.args(R(e.args||[])),e.limit&&E(e.limit)&&d.limit(e.limit),d.proposer(e.proposer||e.authz||n),d.payer(e.payer||e.authz||n),d.authorizations(e.authorizations||[e.authz||n])]).then(d.decode)})})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},e.query=w,e.reauthenticate=function(e){return void 0===e&&(e={}),Be().unauthenticate(),Be().authenticate(e)},e.serialize=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{return Promise.resolve(n.config.first(["sdk.resolve"],r.resolve||n.resolve)).then(function(r){function t(){return Promise.resolve(r(e)).then(function(e){return JSON.stringify(n.createSignableVoucher(e),null,2)})}var o=function(){if(Array.isArray(e))return Promise.resolve(n.pipe(n.interaction(),e)).then(function(n){e=n})}();return o&&o.then?o.then(t):t()})}catch(e){return Promise.reject(e)}},e.signUp=function(e){return void 0===e&&(e={}),Be().authenticate(e)},e.t=hn,e.tx=Ge,e.unauthenticate=function(){return Be().unauthenticate()},e.verifyUserSignatures=he}); | ||
//# sourceMappingURL=fcl.umd.js.map |
{ | ||
"name": "@onflow/fcl", | ||
"version": "0.0.79-alpha.3", | ||
"version": "0.0.79-alpha.4", | ||
"description": "Flow Client Library", | ||
@@ -45,3 +45,3 @@ "license": "Apache-2.0", | ||
"@onflow/rlp": "0.0.3", | ||
"@onflow/sdk": "^0.0.57-alpha.3", | ||
"@onflow/sdk": "^0.0.57-alpha.4", | ||
"@onflow/types": "0.0.6", | ||
@@ -54,3 +54,3 @@ "@onflow/util-actor": "0.0.2", | ||
}, | ||
"gitHead": "8b7f364ecbed509eeaf890d7af1cf42d680b9843" | ||
"gitHead": "f843a85843363f14235447dbd5a3fc8468d571da" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
2342862
0
625
Updated@onflow/sdk@^0.0.57-alpha.4