Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onflow/fcl

Package Overview
Dependencies
Maintainers
7
Versions
312
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/fcl - npm Package Compare versions

Comparing version 0.0.55-debug.14 to 0.0.55-debug.15

2

dist/fcl.js

@@ -1,2 +0,2 @@

var e=require("@onflow/config"),r=require("@onflow/sdk"),t=require("@onflow/util-actor"),n=require("@onflow/types");e.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var o,i,u=function(t){try{return Promise.resolve(e.config().get("accessNode.api")).then(function(e){return r.resolve(t,[r.resolveRefBlockId({node:e}),r.resolveParams,r.resolveArguments,r.resolveAccounts,r.resolveSignatures,r.resolveValidators])})}catch(e){return Promise.reject(e)}},s=function(t,n){void 0===t&&(t=[]),void 0===n&&(n={});try{var o=function(e){return n.node=e,Array.isArray(t)&&(t=r.build(t)),Promise.resolve(u(t)).then(function(e){return r.send(e,n)})},i=n.node;return Promise.resolve(i?o(i):Promise.resolve(e.config().get("accessNode.api")).then(o))}catch(e){return Promise.reject(e)}},c=function(t){try{return Promise.resolve(e.config().where(/^decoder\./)).then(function(e){var n=Object.fromEntries(Object.entries(e).map(function(e){var r=e[0],t=e[1];return[r="/"+r.replace(/^decoder\./,"")+"$/",t]}));return r.decodeResponse(t,n)})}catch(e){return Promise.reject(e)}},a=function(e){try{return Promise.resolve(s([r.getTransactionStatus(e)])).then(c)}catch(e){return Promise.reject(e)}},l=function(e){return e.status>=4},f=function(e){return e.status>=3},d=function(e){return e.status>=2},m=((o={})[t.INIT]=function(e){try{return Promise.resolve(a(e.self())).then(function(r){l(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},o[t.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,t.UPDATED,e.all())},o[t.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},o[t.SNAPSHOT]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},o.POLL=function(e){try{return Promise.resolve(a(e.self())).then(function(r){var n,o;l(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)}},o),h=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},v=function(e){return t.spawn(m,h(e))};function p(e){function r(r){return t.subscriber(h(e),v,r)}function n(e){return function(t){void 0===t&&(t={});var n=t.suppress||!1;return new Promise(function(t,o){var i=r(function(r){r.statusCode&&!n?(o(r.errorMessage),i()):e(r)&&(t(r),i())})})}}return{snapshot:function(){return t.snapshoter(e,v)},subscribe:r,onceFinalized:n(d),onceExecuted:n(f),onceSealed:n(l)}}function y(){return(y=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function P(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function g(e){var r=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,r){if(e){if("string"==typeof e)return P(e,void 0);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(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?P(e,void 0):void 0}}(e)))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.")}return(r=e[Symbol.iterator]()).next.bind(r)}p.isUnknown=function(e){return e.status>=0},p.isPending=function(e){return e.status>=1},p.isFinalized=d,p.isExecuted=f,p.isSealed=l,p.isExpired=function(e){return 5===e.status};var b=function(){try{return Promise.resolve(s([r.getLatestBlock()])).then(c)}catch(e){return Promise.reject(e)}},E=function(r){try{var t=setTimeout;return Promise.resolve(e.config().get("fcl.eventPollRate",1e4)).then(function(e){return t(function(){return r.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},S=((i={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var t=e.get("hwm"),n=function(){if(null==t){var n=e.put;return Promise.resolve(b()).then(function(r){n.call(e,"hwm",r);var t=e.put;return Promise.resolve(E(e)).then(function(r){t.call(e,"tick",r)})})}return Promise.resolve(b()).then(function(n){return e.put("hwm",n),Promise.resolve(s([r.getEvents(e.self(),t.height,n.height-1)])).then(function(r){return Promise.resolve(c(r)).then(function(r){for(var t,n=g(r);!(t=n()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(E(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)}},i[t.SUBSCRIBE]=function(e,r){try{var t=function(){e.subscribe(r.from)},n=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(E(e)).then(function(t){r.call(e,"tick",t)})}}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},i[t.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},i),j=function(e){return t.spawn(S,e)};function w(e){return null==e?null:e.replace(/^0x/,"")}var x="FCL_IFRAME_CHALLENGE";function O(e,r){void 0===r&&(r=!0);var t=new URL(e.endpoint);if(r)for(var n=0,o=Object.entries(e.params||{});n<o.length;n++){var i=o[n];t.searchParams.append(i[0],i[1])}return t}var I="FCL_IFRAME_AUTHZ";function T(e){if(!document.getElementById(I)){var r=O(e),t=document.createElement("iframe");return t.src=r.href,t.id=I,t.allow="usb",t.style.position="fixed",t.style.top="0px",t.style.right="0px",t.style.left="0px",t.style.bottom="0px",t.style.height="100vh",t.style.width="100vw",t.style.display="block",t.style.background="rgba(0,0,0,0.25)",t.frameBorder="0",t.style.boxSizing="border-box",t.style.border="1px solid white",document.body.append(t),[t,function(){document.getElementById(I)&&document.getElementById(I).remove()}]}}var A,R={"HTTP/GET":"GET","HTTP/POST":"POST"},N=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},k=function(e,r){return"Missing "+N(e,r)+" in Composite Signature."},B=function(e,r){return N(e,r)+" in Composit Signature did not match the requested "+e+"."},C="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",U=C.length,L={"HTTP/POST":function(e,r){try{var t=function(){},n=null;return Promise.resolve(function(e,r){try{var t=e()}catch(e){return r()}return t&&t.then?t.then(r,r):r()}(function(){return function(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(function(){return Promise.resolve(fetch(O(e),{method:"POST",headers:{"Content-Type":"application/json"},body:r?JSON.stringify(r):void 0}).then(function(e){return e.json()})).then(function(e){if(e.local&&e.local.length>0){var r=T(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(O(r),{method:R[r.method],headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(r){"APPROVED"===r.status?t(r.compositeSignature):"DECLINED"===r.status?n({status:r.status,reason:r.reason}):setTimeout(function(){t(e(r.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){n=e})})},function(e){throw t(),console.error(e),e})},function(){return t(),n}))}catch(e){return Promise.reject(e)}},"IFRAME/RPC":function(e,r){try{return Promise.resolve(new Promise(function(t,n){try{var o=function(){for(var e="",r=32;r--;)e+=C[Math.random()*U|0];return e}(),i=T(e)[0];console.log("AUTHZ IFRAME",i),setTimeout(function(){i.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")},500),window.addEventListener("message",function e(r){var i=r.data;try{if("object"!=typeof i)return Promise.resolve();if("2.0"!==i.jsonrpc)return Promise.resolve();if(i.id!==o)return Promise.resolve();var u=i.result;return"APPROVED"===u.status?(window.removeEventListener("message",e),t(u.compositeSignature)):"DECLINED"===u.status?(window.removeEventListener("message",e),n({status:u.status,reason:u.reason})):(window.removeEventListener("message",e),n({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"})),Promise.resolve()}catch(e){return Promise.reject(e)}})}catch(e){console.error("EXPECTING BOOM HERE",e),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function D(e,r,t){if(!e.s){if(t instanceof _){if(!t.s)return void(t.o=D.bind(null,e,r));1&r&&(r=t.s),t=t.v}if(t&&t.then)return void t.then(D.bind(null,e,r),D.bind(null,e,2));e.s=r,e.v=t;var n=e.o;n&&n(e)}}var z=function(e){try{return K(),Promise.resolve(M()).then(function(t){function n(){return y({},e,{addr:u.addr,keyId:u.keyId,sequenceNum:i,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(function(e,r){try{return Promise.resolve(L[e.method](e,r)).then(function(r){return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),console.log("Normalized Composite Signature From Wallet Provider",r),function(e,r){try{if(null==e.addr)throw new Error(k("addr","Address"));if(null==e.keyId)throw new Error(k("keyId"));if(null==e.signature)throw new Error(k("signature"));if(e.addr!==r.addr)throw new Error(B("addr","Address"));if(e.keyId!==r.keyId)throw new Error(B("keyId"))}catch(t){throw console.error(t,"\n\n",{"Composite Signature":e,"Authz Service":r}),new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+t.message)}}(r,e),r})}catch(e){return Promise.reject(e)}}(u,e))}catch(e){return Promise.reject(e)}},resolve:null,roles:e.roles})}var o,i,u=(void 0===(o=t.services)&&(o=[]),o.find(function(e){return"authz"===e.type})),c=function(){if(e.role.proposer)return Promise.resolve(function(){try{return K(),Promise.resolve(Y()).then(function(e){var t=e.addr;if(null==t)throw new Error("No Flow Address for Current User");return Promise.resolve(s([r.getAccount(t)])).then(function(e){return e.account})})}catch(e){return Promise.reject(e)}}()).then(function(e){var r=e.keys.find(function(e){return e.index===u.keyId});i=r.sequenceNumber})}();return c&&c.then?c.then(n):n()})}catch(e){return Promise.reject(e)}},_=function(){function e(){}return e.prototype.then=function(r,t){var n=new e,o=this.s;if(o){var i=1&o?r:t;if(i){try{D(n,1,i(this.v))}catch(e){D(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?D(n,1,r?r(o):o):t?D(n,1,t(o)):D(n,2,o)}catch(e){D(n,2,e)}},n},e}();function H(e){return e instanceof _&&1&e.s}var M=function(){try{return Promise.resolve(new Promise(function(r){try{return K(),Promise.resolve(Y()).then(function(n){return n.loggedIn?r(n):Promise.resolve(e.config().get("challenge.handshake")).then(function(e){var n=function(e){var r=e.handshake,t=e.l6n;if(!document.getElementById(x)){var n=new URL(r);n.searchParams.append("l6n",t);var o=document.createElement("iframe");return o.src=n.href,o.id=x,o.allow="usb",o.style.position="fixed",o.style.top="0px",o.style.right="0px",o.style.left="0px",o.style.bottom="0px",o.style.height="100vh",o.style.width="100vw",o.style.display="block",o.style.background="rgba(0,0,0,0.25)",o.frameBorder="0",o.style.boxSizing="border-box",o.style.border="1px solid white",document.body.append(o),function(){document.getElementById(x)&&document.getElementById(x).remove()}}}({handshake:e,l6n:window.location.origin});window.addEventListener("message",function e(o){var i=o.data;try{if(console.log("MESSAGE",i),i.type!==V)return Promise.resolve();n(),window.removeEventListener("message",e);var u="did:fcl:"+i.addr,s=i.addr,c=i.services||[];return Promise.resolve(function(e,r){try{if(null==e||null==r)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",r),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 r=[];if(Array.isArray(e.authorizations))for(var t,n=g(e.authorizations);!(t=n()).done;)r.push(y({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&r.push(y({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(i.hks,i.code)).then(function(e){var n,o,i={addr:s,cid:u,loggedIn:!0,services:(n=c,o=e,void 0===n&&(n=[]),void 0===o&&(o=[]),[].concat(n,o))};return t.send(F,G,i),Promise.resolve(Y()).then(function(e){r(e)})})}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},F="CURRENT_USER",J="CURRENT_USER/UPDATED",G="SET_CURRENT_USER",V="FCL::CHALLENGE::RESPONSE",q='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',W=function(e){try{return localStorage.setItem(F,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},X=((A={})[t.INIT]=function(e){try{var r=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(q),r=JSON.parse(localStorage.getItem(F));return null!=r&&e.VERSION!==r.VERSION?(localStorage.removeItem(F),Promise.resolve(e)):Promise.resolve(r||e)}catch(e){return Promise.reject(e)}}()).then(function(t){r.call(e,t)})}catch(e){return Promise.reject(e)}},A[t.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,J,e.all())},A[t.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},A.SNAPSHOT=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},A[G]=function(e,r,t){try{return e.merge(t),W(e.all()),e.broadcast(J,e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},A.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(q)),W(e.all()),e.broadcast(J,e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},A.GET_AS_PARAM=function(e,r,t){var o=t.key;try{return r.reply({key:o,value:e.get("addr",null),xform:n.Identity}),Promise.resolve()}catch(e){return Promise.reject(e)}},A),K=function(){return t.spawn(X,F)};function Z(){K(),t.send(F,"DEL_CURRENT_USER")}function $(e){return function(){try{return K(),Promise.resolve(M()).then(function(){return t.send(F,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})})}catch(e){return Promise.reject(e)}}}function Q(e){K();var r=t.spawn(function(r){try{var n;return r.send(F,t.SUBSCRIBE),Promise.resolve(function(e,r,t){for(var n;;){var o=e();if(H(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=t();if(i&&i.then){if(!H(i)){n=1;break}i=i.s}}var u=new _,s=D.bind(null,u,2);return(0===n?o.then(a):1===n?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,s):a(o):D(u,1,i)})).then(void 0,s),u;function c(r){i=r;do{if(!(o=e())||H(o)&&!o.v)return void D(u,1,i);if(o.then)return void o.then(a).then(void 0,s);H(i=t())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,s)}function a(e){e?(i=t())&&i.then?i.then(c).then(void 0,s):c(i):D(u,1,i)}}(function(){return!n&&1},0,function(){return Promise.resolve(r.receive()).then(function(o){if("@EXIT"===o.tag)return r.send(F,t.UNSUBSCRIBE),void(n=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return t.send(r,"@EXIT")}}function Y(){return K(),t.send(F,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var ee=function(){return{authenticate:M,unauthenticate:Z,authorization:z,param:$,subscribe:Q,snapshot:Y}};Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return e.config}}),Object.defineProperty(exports,"arg",{enumerable:!0,get:function(){return r.arg}}),Object.defineProperty(exports,"args",{enumerable:!0,get:function(){return r.args}}),Object.defineProperty(exports,"authorization",{enumerable:!0,get:function(){return r.authorization}}),Object.defineProperty(exports,"authorizations",{enumerable:!0,get:function(){return r.authorizations}}),Object.defineProperty(exports,"build",{enumerable:!0,get:function(){return r.build}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return r.cadence}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return r.cdc}}),Object.defineProperty(exports,"getAccount",{enumerable:!0,get:function(){return r.getAccount}}),Object.defineProperty(exports,"getBlockByHeight",{enumerable:!0,get:function(){return r.getBlockByHeight}}),Object.defineProperty(exports,"getBlockById",{enumerable:!0,get:function(){return r.getBlockById}}),Object.defineProperty(exports,"getEvents",{enumerable:!0,get:function(){return r.getEvents}}),Object.defineProperty(exports,"getLatestBlock",{enumerable:!0,get:function(){return r.getLatestBlock}}),Object.defineProperty(exports,"getTransactionStatus",{enumerable:!0,get:function(){return r.getTransactionStatus}}),Object.defineProperty(exports,"isBad",{enumerable:!0,get:function(){return r.isBad}}),Object.defineProperty(exports,"isOk",{enumerable:!0,get:function(){return r.isOk}}),Object.defineProperty(exports,"limit",{enumerable:!0,get:function(){return r.limit}}),Object.defineProperty(exports,"param",{enumerable:!0,get:function(){return r.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return r.params}}),Object.defineProperty(exports,"payer",{enumerable:!0,get:function(){return r.payer}}),Object.defineProperty(exports,"ping",{enumerable:!0,get:function(){return r.ping}}),Object.defineProperty(exports,"pipe",{enumerable:!0,get:function(){return r.pipe}}),Object.defineProperty(exports,"proposer",{enumerable:!0,get:function(){return r.proposer}}),Object.defineProperty(exports,"ref",{enumerable:!0,get:function(){return r.ref}}),Object.defineProperty(exports,"script",{enumerable:!0,get:function(){return r.script}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return r.transaction}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return r.why}}),exports.VERSION="0.0.55-debug.14",exports.authenticate=function(){return ee().authenticate()},exports.currentUser=ee,exports.decode=c,exports.events=function(e){return{subscribe:function(r){return t.subscriber(e,j,r)}}},exports.resolve=u,exports.sansPrefix=w,exports.send=s,exports.serialize=function(e){void 0===e&&(e=[]);try{var t=function(){return Promise.resolve(u(e)).then(JSON.stringify)},n=function(){if(Array.isArray(e))return Promise.resolve(r.build(e)).then(function(r){e=r})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},exports.tx=p,exports.unauthenticate=function(){return ee().unauthenticate()},exports.withPrefix=function(e){return null==e?null:"0x"+w(e)};
var e=require("@onflow/config"),r=require("@onflow/sdk"),t=require("@onflow/util-actor"),n=require("@onflow/types");e.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var o,i,u=function(t){try{return Promise.resolve(e.config().get("accessNode.api")).then(function(e){return r.resolve(t,[r.resolveRefBlockId({node:e}),r.resolveParams,r.resolveArguments,r.resolveAccounts,r.resolveSignatures,r.resolveValidators])})}catch(e){return Promise.reject(e)}},s=function(t,n){void 0===t&&(t=[]),void 0===n&&(n={});try{var o=function(e){return n.node=e,Array.isArray(t)&&(t=r.build(t)),Promise.resolve(u(t)).then(function(e){return r.send(e,n)})},i=n.node;return Promise.resolve(i?o(i):Promise.resolve(e.config().get("accessNode.api")).then(o))}catch(e){return Promise.reject(e)}},c=function(t){try{return Promise.resolve(e.config().where(/^decoder\./)).then(function(e){var n=Object.fromEntries(Object.entries(e).map(function(e){var r=e[0],t=e[1];return[r="/"+r.replace(/^decoder\./,"")+"$/",t]}));return r.decodeResponse(t,n)})}catch(e){return Promise.reject(e)}},a=function(e){try{return Promise.resolve(s([r.getTransactionStatus(e)])).then(c)}catch(e){return Promise.reject(e)}},l=function(e){return e.status>=4},f=function(e){return e.status>=3},d=function(e){return e.status>=2},m=((o={})[t.INIT]=function(e){try{return Promise.resolve(a(e.self())).then(function(r){l(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},o[t.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,t.UPDATED,e.all())},o[t.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},o[t.SNAPSHOT]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},o.POLL=function(e){try{return Promise.resolve(a(e.self())).then(function(r){var n,o;l(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)}},o),h=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},v=function(e){return t.spawn(m,h(e))};function p(e){function r(r){return t.subscriber(h(e),v,r)}function n(e){return function(t){void 0===t&&(t={});var n=t.suppress||!1;return new Promise(function(t,o){var i=r(function(r){r.statusCode&&!n?(o(r.errorMessage),i()):e(r)&&(t(r),i())})})}}return{snapshot:function(){return t.snapshoter(e,v)},subscribe:r,onceFinalized:n(d),onceExecuted:n(f),onceSealed:n(l)}}function y(){return(y=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function P(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function g(e){var r=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,r){if(e){if("string"==typeof e)return P(e,void 0);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(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?P(e,void 0):void 0}}(e)))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.")}return(r=e[Symbol.iterator]()).next.bind(r)}p.isUnknown=function(e){return e.status>=0},p.isPending=function(e){return e.status>=1},p.isFinalized=d,p.isExecuted=f,p.isSealed=l,p.isExpired=function(e){return 5===e.status};var b=function(){try{return Promise.resolve(s([r.getLatestBlock()])).then(c)}catch(e){return Promise.reject(e)}},E=function(r){try{var t=setTimeout;return Promise.resolve(e.config().get("fcl.eventPollRate",1e4)).then(function(e){return t(function(){return r.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},S=((i={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var t=e.get("hwm"),n=function(){if(null==t){var n=e.put;return Promise.resolve(b()).then(function(r){n.call(e,"hwm",r);var t=e.put;return Promise.resolve(E(e)).then(function(r){t.call(e,"tick",r)})})}return Promise.resolve(b()).then(function(n){return e.put("hwm",n),Promise.resolve(s([r.getEvents(e.self(),t.height,n.height-1)])).then(function(r){return Promise.resolve(c(r)).then(function(r){for(var t,n=g(r);!(t=n()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(E(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)}},i[t.SUBSCRIBE]=function(e,r){try{var t=function(){e.subscribe(r.from)},n=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(E(e)).then(function(t){r.call(e,"tick",t)})}}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},i[t.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},i),j=function(e){return t.spawn(S,e)};function w(e){return null==e?null:e.replace(/^0x/,"")}var x="FCL_IFRAME_CHALLENGE";function O(e,r){void 0===r&&(r=!0);var t=new URL(e.endpoint);if(r)for(var n=0,o=Object.entries(e.params||{});n<o.length;n++){var i=o[n];t.searchParams.append(i[0],i[1])}return t}var I="FCL_IFRAME_AUTHZ";function T(e){if(!document.getElementById(I)){var r=O(e),t=document.createElement("iframe");return t.src=r.href,t.id=I,t.allow="usb",t.style.position="fixed",t.style.top="0px",t.style.right="0px",t.style.left="0px",t.style.bottom="0px",t.style.height="100vh",t.style.width="100vw",t.style.display="block",t.style.background="rgba(0,0,0,0.25)",t.frameBorder="0",t.style.boxSizing="border-box",t.style.border="1px solid white",document.body.append(t),[t,function(){document.getElementById(I)&&document.getElementById(I).remove()}]}}var A,R={"HTTP/GET":"GET","HTTP/POST":"POST"},N=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},k=function(e,r){return"Missing "+N(e,r)+" in Composite Signature."},B=function(e,r){return N(e,r)+" in Composit Signature did not match the requested "+e+"."},C="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",U=C.length,L={"HTTP/POST":function(e,r){try{var t=function(){},n=null;return Promise.resolve(function(e,r){try{var t=e()}catch(e){return r()}return t&&t.then?t.then(r,r):r()}(function(){return function(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(function(){return Promise.resolve(fetch(O(e),{method:"POST",headers:{"Content-Type":"application/json"},body:r?JSON.stringify(r):void 0}).then(function(e){return e.json()})).then(function(e){if(e.local&&e.local.length>0){var r=T(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(O(r),{method:R[r.method],headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(r){"APPROVED"===r.status?t(r.compositeSignature):"DECLINED"===r.status?n({status:r.status,reason:r.reason}):setTimeout(function(){t(e(r.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){n=e})})},function(e){throw t(),console.error(e),e})},function(){return t(),n}))}catch(e){return Promise.reject(e)}},"IFRAME/RPC":function(e,r){try{return Promise.resolve(new Promise(function(t,n){try{var o=function(){for(var e="",r=32;r--;)e+=C[Math.random()*U|0];return e}(),i=T(e),u=i[0],s=i[1];console.log("AUTHZ IFRAME",u),setTimeout(function(){u.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")},500),window.addEventListener("message",function e(r){var i=r.data;try{if("object"!=typeof i)return Promise.resolve();if("2.0"!==i.jsonrpc)return Promise.resolve();if(i.id!==o)return Promise.resolve();var u=i.result;return"APPROVED"===u.status?(window.removeEventListener("message",e),s(),t(u.compositeSignature)):"DECLINED"===u.status?(window.removeEventListener("message",e),s(),n({status:u.status,reason:u.reason})):(window.removeEventListener("message",e),s(),n({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"})),Promise.resolve()}catch(e){return Promise.reject(e)}})}catch(e){console.error("EXPECTING BOOM HERE",e),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function D(e,r,t){if(!e.s){if(t instanceof _){if(!t.s)return void(t.o=D.bind(null,e,r));1&r&&(r=t.s),t=t.v}if(t&&t.then)return void t.then(D.bind(null,e,r),D.bind(null,e,2));e.s=r,e.v=t;var n=e.o;n&&n(e)}}var z=function(e){try{return K(),Promise.resolve(M()).then(function(t){function n(){return y({},e,{addr:u.addr,keyId:u.keyId,sequenceNum:i,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(function(e,r){try{return Promise.resolve(L[e.method](e,r)).then(function(r){return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),console.log("Normalized Composite Signature From Wallet Provider",r),function(e,r){try{if(null==e.addr)throw new Error(k("addr","Address"));if(null==e.keyId)throw new Error(k("keyId"));if(null==e.signature)throw new Error(k("signature"));if(e.addr!==r.addr)throw new Error(B("addr","Address"));if(e.keyId!==r.keyId)throw new Error(B("keyId"))}catch(t){throw console.error(t,"\n\n",{"Composite Signature":e,"Authz Service":r}),new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+t.message)}}(r,e),r})}catch(e){return Promise.reject(e)}}(u,e))}catch(e){return Promise.reject(e)}},resolve:null,roles:e.roles})}var o,i,u=(void 0===(o=t.services)&&(o=[]),o.find(function(e){return"authz"===e.type})),c=function(){if(e.role.proposer)return Promise.resolve(function(){try{return K(),Promise.resolve(Y()).then(function(e){var t=e.addr;if(null==t)throw new Error("No Flow Address for Current User");return Promise.resolve(s([r.getAccount(t)])).then(function(e){return e.account})})}catch(e){return Promise.reject(e)}}()).then(function(e){var r=e.keys.find(function(e){return e.index===u.keyId});i=r.sequenceNumber})}();return c&&c.then?c.then(n):n()})}catch(e){return Promise.reject(e)}},_=function(){function e(){}return e.prototype.then=function(r,t){var n=new e,o=this.s;if(o){var i=1&o?r:t;if(i){try{D(n,1,i(this.v))}catch(e){D(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?D(n,1,r?r(o):o):t?D(n,1,t(o)):D(n,2,o)}catch(e){D(n,2,e)}},n},e}();function H(e){return e instanceof _&&1&e.s}var M=function(){try{return Promise.resolve(new Promise(function(r){try{return K(),Promise.resolve(Y()).then(function(n){return n.loggedIn?r(n):Promise.resolve(e.config().get("challenge.handshake")).then(function(e){var n=function(e){var r=e.handshake,t=e.l6n;if(!document.getElementById(x)){var n=new URL(r);n.searchParams.append("l6n",t);var o=document.createElement("iframe");return o.src=n.href,o.id=x,o.allow="usb",o.style.position="fixed",o.style.top="0px",o.style.right="0px",o.style.left="0px",o.style.bottom="0px",o.style.height="100vh",o.style.width="100vw",o.style.display="block",o.style.background="rgba(0,0,0,0.25)",o.frameBorder="0",o.style.boxSizing="border-box",o.style.border="1px solid white",document.body.append(o),function(){document.getElementById(x)&&document.getElementById(x).remove()}}}({handshake:e,l6n:window.location.origin});window.addEventListener("message",function e(o){var i=o.data;try{if(console.log("MESSAGE",i),i.type!==V)return Promise.resolve();n(),window.removeEventListener("message",e);var u="did:fcl:"+i.addr,s=i.addr,c=i.services||[];return Promise.resolve(function(e,r){try{if(null==e||null==r)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",r),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 r=[];if(Array.isArray(e.authorizations))for(var t,n=g(e.authorizations);!(t=n()).done;)r.push(y({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&r.push(y({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(i.hks,i.code)).then(function(e){var n,o,i={addr:s,cid:u,loggedIn:!0,services:(n=c,o=e,void 0===n&&(n=[]),void 0===o&&(o=[]),[].concat(n,o))};return t.send(F,G,i),Promise.resolve(Y()).then(function(e){r(e)})})}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},F="CURRENT_USER",J="CURRENT_USER/UPDATED",G="SET_CURRENT_USER",V="FCL::CHALLENGE::RESPONSE",q='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',W=function(e){try{return localStorage.setItem(F,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},X=((A={})[t.INIT]=function(e){try{var r=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(q),r=JSON.parse(localStorage.getItem(F));return null!=r&&e.VERSION!==r.VERSION?(localStorage.removeItem(F),Promise.resolve(e)):Promise.resolve(r||e)}catch(e){return Promise.reject(e)}}()).then(function(t){r.call(e,t)})}catch(e){return Promise.reject(e)}},A[t.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,J,e.all())},A[t.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},A.SNAPSHOT=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},A[G]=function(e,r,t){try{return e.merge(t),W(e.all()),e.broadcast(J,e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},A.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(q)),W(e.all()),e.broadcast(J,e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},A.GET_AS_PARAM=function(e,r,t){var o=t.key;try{return r.reply({key:o,value:e.get("addr",null),xform:n.Identity}),Promise.resolve()}catch(e){return Promise.reject(e)}},A),K=function(){return t.spawn(X,F)};function Z(){K(),t.send(F,"DEL_CURRENT_USER")}function $(e){return function(){try{return K(),Promise.resolve(M()).then(function(){return t.send(F,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})})}catch(e){return Promise.reject(e)}}}function Q(e){K();var r=t.spawn(function(r){try{var n;return r.send(F,t.SUBSCRIBE),Promise.resolve(function(e,r,t){for(var n;;){var o=e();if(H(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=t();if(i&&i.then){if(!H(i)){n=1;break}i=i.s}}var u=new _,s=D.bind(null,u,2);return(0===n?o.then(a):1===n?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,s):a(o):D(u,1,i)})).then(void 0,s),u;function c(r){i=r;do{if(!(o=e())||H(o)&&!o.v)return void D(u,1,i);if(o.then)return void o.then(a).then(void 0,s);H(i=t())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,s)}function a(e){e?(i=t())&&i.then?i.then(c).then(void 0,s):c(i):D(u,1,i)}}(function(){return!n&&1},0,function(){return Promise.resolve(r.receive()).then(function(o){if("@EXIT"===o.tag)return r.send(F,t.UNSUBSCRIBE),void(n=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return t.send(r,"@EXIT")}}function Y(){return K(),t.send(F,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var ee=function(){return{authenticate:M,unauthenticate:Z,authorization:z,param:$,subscribe:Q,snapshot:Y}};Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return e.config}}),Object.defineProperty(exports,"arg",{enumerable:!0,get:function(){return r.arg}}),Object.defineProperty(exports,"args",{enumerable:!0,get:function(){return r.args}}),Object.defineProperty(exports,"authorization",{enumerable:!0,get:function(){return r.authorization}}),Object.defineProperty(exports,"authorizations",{enumerable:!0,get:function(){return r.authorizations}}),Object.defineProperty(exports,"build",{enumerable:!0,get:function(){return r.build}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return r.cadence}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return r.cdc}}),Object.defineProperty(exports,"getAccount",{enumerable:!0,get:function(){return r.getAccount}}),Object.defineProperty(exports,"getBlockByHeight",{enumerable:!0,get:function(){return r.getBlockByHeight}}),Object.defineProperty(exports,"getBlockById",{enumerable:!0,get:function(){return r.getBlockById}}),Object.defineProperty(exports,"getEvents",{enumerable:!0,get:function(){return r.getEvents}}),Object.defineProperty(exports,"getLatestBlock",{enumerable:!0,get:function(){return r.getLatestBlock}}),Object.defineProperty(exports,"getTransactionStatus",{enumerable:!0,get:function(){return r.getTransactionStatus}}),Object.defineProperty(exports,"isBad",{enumerable:!0,get:function(){return r.isBad}}),Object.defineProperty(exports,"isOk",{enumerable:!0,get:function(){return r.isOk}}),Object.defineProperty(exports,"limit",{enumerable:!0,get:function(){return r.limit}}),Object.defineProperty(exports,"param",{enumerable:!0,get:function(){return r.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return r.params}}),Object.defineProperty(exports,"payer",{enumerable:!0,get:function(){return r.payer}}),Object.defineProperty(exports,"ping",{enumerable:!0,get:function(){return r.ping}}),Object.defineProperty(exports,"pipe",{enumerable:!0,get:function(){return r.pipe}}),Object.defineProperty(exports,"proposer",{enumerable:!0,get:function(){return r.proposer}}),Object.defineProperty(exports,"ref",{enumerable:!0,get:function(){return r.ref}}),Object.defineProperty(exports,"script",{enumerable:!0,get:function(){return r.script}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return r.transaction}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return r.why}}),exports.VERSION="0.0.55-debug.15",exports.authenticate=function(){return ee().authenticate()},exports.currentUser=ee,exports.decode=c,exports.events=function(e){return{subscribe:function(r){return t.subscriber(e,j,r)}}},exports.resolve=u,exports.sansPrefix=w,exports.send=s,exports.serialize=function(e){void 0===e&&(e=[]);try{var t=function(){return Promise.resolve(u(e)).then(JSON.stringify)},n=function(){if(Array.isArray(e))return Promise.resolve(r.build(e)).then(function(r){e=r})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},exports.tx=p,exports.unauthenticate=function(){return ee().unauthenticate()},exports.withPrefix=function(e){return null==e?null:"0x"+w(e)};
//# sourceMappingURL=fcl.js.map

@@ -1,2 +0,2 @@

import{config as e}from"@onflow/config";export{config}from"@onflow/config";import{resolve as t,resolveRefBlockId as n,resolveParams as r,resolveArguments as a,resolveAccounts as s,resolveSignatures as o,resolveValidators as i,build as c,send as l,decodeResponse as u,getTransactionStatus as d,getLatestBlock as f,getEvents as y,getAccount as m}from"@onflow/sdk";export{arg,args,authorization,authorizations,build,cadence,cdc,getAccount,getBlockByHeight,getBlockById,getEvents,getLatestBlock,getTransactionStatus,isBad,isOk,limit,param,params,payer,ping,pipe,proposer,ref,script,transaction,why}from"@onflow/sdk";import{subscriber as p,spawn as h,snapshoter as g,INIT as w,SUBSCRIBE as E,UPDATED as S,UNSUBSCRIBE as b,SNAPSHOT as T,send as v}from"@onflow/util-actor";import{Identity as I}from"@onflow/types";e().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");const R=async c=>t(c,[n({node:await e().get("accessNode.api")}),r,a,s,o,i]),P=async(t=[],n={})=>(n.node=n.node||await e().get("accessNode.api"),Array.isArray(t)&&(t=c(t)),l(await R(t),n)),N=async(e=[])=>(Array.isArray(e)&&(e=await c(e)),JSON.stringify(await R(e))),A=async t=>{const n=await e().where(/^decoder\./),r=Object.fromEntries(Object.entries(n).map(([e,t])=>[e=`/${e.replace(/^decoder\./,"")}$/`,t]));return u(t,r)},k=async e=>{const t=await P([d(e)]);return A(t)},O=e=>e.status>=4,C=e=>e.status>=3,L=e=>e.status>=2,x={[w]:async e=>{const t=await k(e.self());O(t)||setTimeout(()=>e.sendSelf("POLL"),2500),e.merge(t)},[E]:(e,t)=>{e.subscribe(t.from),e.send(t.from,S,e.all())},[b]:(e,t)=>{e.unsubscribe(t.from)},[T]:async(e,t)=>{t.reply(e.all())},POLL:async e=>{const t=await k(e.self());var n,r;O(t)||setTimeout(()=>e.sendSelf("POLL"),2500),n=e.all(),r=t,JSON.stringify(n)!==JSON.stringify(r)&&e.broadcast(S,t),e.merge(t)}},U=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},D=e=>h(x,U(e));function _(e){function t(t){return p(U(e),D,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 g(e,D)},subscribe:t,onceFinalized:n(L),onceExecuted:n(C),onceSealed:n(O)}}_.isUnknown=e=>e.status>=0,_.isPending=e=>e.status>=1,_.isFinalized=L,_.isExecuted=C,_.isSealed=O,_.isExpired=e=>5===e.status;const z=async()=>A(await P([f()])),B=async t=>setTimeout(()=>t.sendSelf("TICK"),await e().get("fcl.eventPollRate",1e4)),j={TICK:async e=>{if(!e.hasSubs())return;let t=e.get("hwm");if(null==t)e.put("hwm",await z()),e.put("tick",await B(e));else{let n=await z();e.put("hwm",n);const r=await P([y(e.self(),t.height,n.height-1)]),a=await A(r);for(let t of a)e.broadcast("UPDATED",t.data);e.put("tick",await B(e))}},[E]:async(e,t)=>{e.hasSubs()||e.put("tick",await B(e)),e.subscribe(t.from)},[b]:(e,t)=>{e.unsubscribe(t.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))}},F=e=>h(j,e);function H(e){return{subscribe:t=>p(e,F,t)}}function M(e){return null==e?null:e.replace(/^0x/,"")}function J(e){return null==e?null:"0x"+M(e)}const G="FCL_IFRAME_CHALLENGE";async function V(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({type:"authz",keyId:r.keyId,...e});return null!=r.provider&&a.push({type:"authn",id:"wallet-provider#authn",...r.provider}),a}function $(e=[],t=[]){return[...e,...t]}function q(e,t=!0){const n=new URL(e.endpoint);if(t)for(let[t,r]of Object.entries(e.params||{}))n.searchParams.append(t,r);return n}const W="FCL_IFRAME_AUTHZ";function X(e){if(document.getElementById(W))return;var t=q(e);const n=document.createElement("iframe");return n.src=t.href,n.id=W,n.allow="usb",n.style.position="fixed",n.style.top="0px",n.style.right="0px",n.style.left="0px",n.style.bottom="0px",n.style.height="100vh",n.style.width="100vw",n.style.display="block",n.style.background="rgba(0,0,0,0.25)",n.frameBorder="0",n.style.boxSizing="border-box",n.style.border="1px solid white",document.body.append(n),[n,()=>{document.getElementById(W)&&document.getElementById(W).remove()}]}const K={"HTTP/GET":"GET","HTTP/POST":"POST"},Z=e=>new Promise(async(t,n)=>{const r=await fetch(q(e),{method:K[e.method],headers:{"Content-Type":"application/json"}}).then(e=>e.json());"APPROVED"===r.status?t(r.compositeSignature):"DECLINED"===r.status?n({status:r.status,reason:r.reason}):setTimeout(()=>{t(Z(r.authorizationUpdates))},500)}),Q=(e,t)=>null==t?`'${e}'`:`'${e}' (${t})`,Y=(e,t)=>`Missing ${Q(e,t)} in Composite Signature.`,ee=(e,t)=>`${Q(e,t)} in Composit Signature did not match the requested ${e}.`;var te="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",ne=te.length;const re={"HTTP/POST":async function(e,t){var n=()=>{},r=null;try{const a=await fetch(q(e),{method:"POST",headers:{"Content-Type":"application/json"},body:t?JSON.stringify(t):void 0}).then(e=>e.json());if(a.local&&a.local.length>0){const[e,t]=X(a.local[0]);n=t}r=await Z(a.authorizationUpdates)}catch(e){throw n(),console.error(e),e}finally{return n(),r}},"IFRAME/RPC":async function(e,t){return new Promise((n,r)=>{try{const a=function(){for(var e="",t=32;t--;)e+=te[Math.random()*ne|0];return e}(),[s,o]=X(e);console.log("AUTHZ IFRAME",s),setTimeout(()=>{s.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[t,e.params]})),"*")},500);const i=async({data:e})=>{if("object"!=typeof e)return;if("2.0"!==e.jsonrpc)return;if(e.id!==a)return;const t=e.result;"APPROVED"===t.status?(window.removeEventListener("message",i),n(t.compositeSignature)):"DECLINED"===t.status?(window.removeEventListener("message",i),r({status:t.status,reason:t.reason})):(window.removeEventListener("message",i),r({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"}))};window.addEventListener("message",i)}catch(e){console.error("EXPECTING BOOM HERE",e),r({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}})}},ae="CURRENT_USER",se="CURRENT_USER/UPDATED",oe='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',ie=async e=>(localStorage.setItem(ae,JSON.stringify(e)),e),ce={[w]:async e=>{e.merge(await(async()=>{const e=JSON.parse(oe),t=JSON.parse(localStorage.getItem(ae));return null!=t&&e.VERSION!==t.VERSION?(localStorage.removeItem(ae),e):t||e})())},[E]:(e,t)=>{e.subscribe(t.from),e.send(t.from,se,e.all())},[b]:(e,t)=>{e.unsubscribe(t.from)},SNAPSHOT:async(e,t)=>{t.reply(e.all())},SET_CURRENT_USER:async(e,t,n)=>{e.merge(n),ie(e.all()),e.broadcast(se,e.all())},DEL_CURRENT_USER:async(e,t)=>{e.merge(JSON.parse(oe)),ie(e.all()),e.broadcast(se,e.all())},GET_AS_PARAM:async(e,t,{key:n})=>{t.reply({key:n,value:e.get("addr",null),xform:I})}},le=()=>h(ce,ae);async function ue(){return new Promise(async t=>{le();const n=await pe();if(n.loggedIn)return t(n);const r=function({handshake:e,l6n:t}){if(document.getElementById(G))return;var n=new URL(e);n.searchParams.append("l6n",t);const r=document.createElement("iframe");return r.src=n.href,r.id=G,r.allow="usb",r.style.position="fixed",r.style.top="0px",r.style.right="0px",r.style.left="0px",r.style.bottom="0px",r.style.height="100vh",r.style.width="100vw",r.style.display="block",r.style.background="rgba(0,0,0,0.25)",r.frameBorder="0",r.style.boxSizing="border-box",r.style.border="1px solid white",document.body.append(r),()=>{document.getElementById(G)&&document.getElementById(G).remove()}}({handshake:await e().get("challenge.handshake"),l6n:window.location.origin}),a=async({data:e})=>{if(console.log("MESSAGE",e),"FCL::CHALLENGE::RESPONSE"!==e.type)return;r(),window.removeEventListener("message",a);const n={addr:e.addr,cid:"did:fcl:"+e.addr,loggedIn:!0,services:$(e.services||[],await V(e.hks,e.code))};v(ae,"SET_CURRENT_USER",n),t(await pe())};window.addEventListener("message",a)})}function de(){le(),v(ae,"DEL_CURRENT_USER")}async function fe(e){le();const t=function(e=[],t){return e.find(e=>e.type===t)}((await ue()).services,"authz");let n;return e.role.proposer&&(n=(await async function(){le();const{addr:e}=await pe();if(null==e)throw new Error("No Flow Address for Current User");const{account:t}=await P([m(e)]);return t}()).keys.find(e=>e.index===t.keyId).sequenceNumber),{...e,addr:t.addr,keyId:t.keyId,sequenceNum:n,signature:e.signature||null,signingFunction:async e=>async function(e,t){const n=await re[e.method](e,t);return null==n.sig&&(n.sig=n.signature),null==n.signature&&(n.signature=n.sig),console.log("Normalized Composite Signature From Wallet Provider",n),function(e,t){try{if(null==e.addr)throw new Error(Y("addr","Address"));if(null==e.keyId)throw new Error(Y("keyId"));if(null==e.signature)throw new Error(Y("signature"));if(e.addr!==t.addr)throw new Error(ee("addr","Address"));if(e.keyId!==t.keyId)throw new Error(ee("keyId"))}catch(n){throw console.error(n,"\n\n",{"Composite Signature":e,"Authz Service":t}),new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+n.message)}}(n,e),n}(t,e),resolve:null,roles:e.roles}}function ye(e){return async function(){return le(),await ue(),v(ae,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})}}function me(e){le();const t=h(async t=>{for(t.send(ae,E);;){const n=await t.receive();if("@EXIT"===n.tag)return void t.send(ae,b);e(n.data)}});return()=>v(t,"@EXIT")}function pe(){return le(),v(ae,"SNAPSHOT",null,{expectReply:!0,timeout:0})}const he=()=>({authenticate:ue,unauthenticate:de,authorization:fe,param:ye,subscribe:me,snapshot:pe}),ge=()=>he().authenticate(),we=()=>he().unauthenticate(),Ee="0.0.55-debug.14";export{Ee as VERSION,ge as authenticate,he as currentUser,A as decode,H as events,R as resolve,M as sansPrefix,P as send,N as serialize,_ as tx,we as unauthenticate,J as withPrefix};
import{config as e}from"@onflow/config";export{config}from"@onflow/config";import{resolve as t,resolveRefBlockId as n,resolveParams as r,resolveArguments as a,resolveAccounts as s,resolveSignatures as o,resolveValidators as i,build as c,send as l,decodeResponse as u,getTransactionStatus as d,getLatestBlock as f,getEvents as y,getAccount as m}from"@onflow/sdk";export{arg,args,authorization,authorizations,build,cadence,cdc,getAccount,getBlockByHeight,getBlockById,getEvents,getLatestBlock,getTransactionStatus,isBad,isOk,limit,param,params,payer,ping,pipe,proposer,ref,script,transaction,why}from"@onflow/sdk";import{subscriber as p,spawn as h,snapshoter as g,INIT as w,SUBSCRIBE as E,UPDATED as S,UNSUBSCRIBE as b,SNAPSHOT as T,send as v}from"@onflow/util-actor";import{Identity as I}from"@onflow/types";e().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");const R=async c=>t(c,[n({node:await e().get("accessNode.api")}),r,a,s,o,i]),P=async(t=[],n={})=>(n.node=n.node||await e().get("accessNode.api"),Array.isArray(t)&&(t=c(t)),l(await R(t),n)),N=async(e=[])=>(Array.isArray(e)&&(e=await c(e)),JSON.stringify(await R(e))),A=async t=>{const n=await e().where(/^decoder\./),r=Object.fromEntries(Object.entries(n).map(([e,t])=>[e=`/${e.replace(/^decoder\./,"")}$/`,t]));return u(t,r)},k=async e=>{const t=await P([d(e)]);return A(t)},O=e=>e.status>=4,C=e=>e.status>=3,L=e=>e.status>=2,x={[w]:async e=>{const t=await k(e.self());O(t)||setTimeout(()=>e.sendSelf("POLL"),2500),e.merge(t)},[E]:(e,t)=>{e.subscribe(t.from),e.send(t.from,S,e.all())},[b]:(e,t)=>{e.unsubscribe(t.from)},[T]:async(e,t)=>{t.reply(e.all())},POLL:async e=>{const t=await k(e.self());var n,r;O(t)||setTimeout(()=>e.sendSelf("POLL"),2500),n=e.all(),r=t,JSON.stringify(n)!==JSON.stringify(r)&&e.broadcast(S,t),e.merge(t)}},U=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},D=e=>h(x,U(e));function _(e){function t(t){return p(U(e),D,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 g(e,D)},subscribe:t,onceFinalized:n(L),onceExecuted:n(C),onceSealed:n(O)}}_.isUnknown=e=>e.status>=0,_.isPending=e=>e.status>=1,_.isFinalized=L,_.isExecuted=C,_.isSealed=O,_.isExpired=e=>5===e.status;const z=async()=>A(await P([f()])),B=async t=>setTimeout(()=>t.sendSelf("TICK"),await e().get("fcl.eventPollRate",1e4)),j={TICK:async e=>{if(!e.hasSubs())return;let t=e.get("hwm");if(null==t)e.put("hwm",await z()),e.put("tick",await B(e));else{let n=await z();e.put("hwm",n);const r=await P([y(e.self(),t.height,n.height-1)]),a=await A(r);for(let t of a)e.broadcast("UPDATED",t.data);e.put("tick",await B(e))}},[E]:async(e,t)=>{e.hasSubs()||e.put("tick",await B(e)),e.subscribe(t.from)},[b]:(e,t)=>{e.unsubscribe(t.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))}},F=e=>h(j,e);function H(e){return{subscribe:t=>p(e,F,t)}}function M(e){return null==e?null:e.replace(/^0x/,"")}function J(e){return null==e?null:"0x"+M(e)}const G="FCL_IFRAME_CHALLENGE";async function V(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({type:"authz",keyId:r.keyId,...e});return null!=r.provider&&a.push({type:"authn",id:"wallet-provider#authn",...r.provider}),a}function $(e=[],t=[]){return[...e,...t]}function q(e,t=!0){const n=new URL(e.endpoint);if(t)for(let[t,r]of Object.entries(e.params||{}))n.searchParams.append(t,r);return n}const W="FCL_IFRAME_AUTHZ";function X(e){if(document.getElementById(W))return;var t=q(e);const n=document.createElement("iframe");return n.src=t.href,n.id=W,n.allow="usb",n.style.position="fixed",n.style.top="0px",n.style.right="0px",n.style.left="0px",n.style.bottom="0px",n.style.height="100vh",n.style.width="100vw",n.style.display="block",n.style.background="rgba(0,0,0,0.25)",n.frameBorder="0",n.style.boxSizing="border-box",n.style.border="1px solid white",document.body.append(n),[n,()=>{document.getElementById(W)&&document.getElementById(W).remove()}]}const K={"HTTP/GET":"GET","HTTP/POST":"POST"},Z=e=>new Promise(async(t,n)=>{const r=await fetch(q(e),{method:K[e.method],headers:{"Content-Type":"application/json"}}).then(e=>e.json());"APPROVED"===r.status?t(r.compositeSignature):"DECLINED"===r.status?n({status:r.status,reason:r.reason}):setTimeout(()=>{t(Z(r.authorizationUpdates))},500)}),Q=(e,t)=>null==t?`'${e}'`:`'${e}' (${t})`,Y=(e,t)=>`Missing ${Q(e,t)} in Composite Signature.`,ee=(e,t)=>`${Q(e,t)} in Composit Signature did not match the requested ${e}.`;var te="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",ne=te.length;const re={"HTTP/POST":async function(e,t){var n=()=>{},r=null;try{const a=await fetch(q(e),{method:"POST",headers:{"Content-Type":"application/json"},body:t?JSON.stringify(t):void 0}).then(e=>e.json());if(a.local&&a.local.length>0){const[e,t]=X(a.local[0]);n=t}r=await Z(a.authorizationUpdates)}catch(e){throw n(),console.error(e),e}finally{return n(),r}},"IFRAME/RPC":async function(e,t){return new Promise((n,r)=>{try{const a=function(){for(var e="",t=32;t--;)e+=te[Math.random()*ne|0];return e}(),[s,o]=X(e);console.log("AUTHZ IFRAME",s),setTimeout(()=>{s.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[t,e.params]})),"*")},500);const i=async({data:e})=>{if("object"!=typeof e)return;if("2.0"!==e.jsonrpc)return;if(e.id!==a)return;const t=e.result;"APPROVED"===t.status?(window.removeEventListener("message",i),o(),n(t.compositeSignature)):"DECLINED"===t.status?(window.removeEventListener("message",i),o(),r({status:t.status,reason:t.reason})):(window.removeEventListener("message",i),o(),r({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"}))};window.addEventListener("message",i)}catch(e){console.error("EXPECTING BOOM HERE",e),r({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}})}},ae="CURRENT_USER",se="CURRENT_USER/UPDATED",oe='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',ie=async e=>(localStorage.setItem(ae,JSON.stringify(e)),e),ce={[w]:async e=>{e.merge(await(async()=>{const e=JSON.parse(oe),t=JSON.parse(localStorage.getItem(ae));return null!=t&&e.VERSION!==t.VERSION?(localStorage.removeItem(ae),e):t||e})())},[E]:(e,t)=>{e.subscribe(t.from),e.send(t.from,se,e.all())},[b]:(e,t)=>{e.unsubscribe(t.from)},SNAPSHOT:async(e,t)=>{t.reply(e.all())},SET_CURRENT_USER:async(e,t,n)=>{e.merge(n),ie(e.all()),e.broadcast(se,e.all())},DEL_CURRENT_USER:async(e,t)=>{e.merge(JSON.parse(oe)),ie(e.all()),e.broadcast(se,e.all())},GET_AS_PARAM:async(e,t,{key:n})=>{t.reply({key:n,value:e.get("addr",null),xform:I})}},le=()=>h(ce,ae);async function ue(){return new Promise(async t=>{le();const n=await pe();if(n.loggedIn)return t(n);const r=function({handshake:e,l6n:t}){if(document.getElementById(G))return;var n=new URL(e);n.searchParams.append("l6n",t);const r=document.createElement("iframe");return r.src=n.href,r.id=G,r.allow="usb",r.style.position="fixed",r.style.top="0px",r.style.right="0px",r.style.left="0px",r.style.bottom="0px",r.style.height="100vh",r.style.width="100vw",r.style.display="block",r.style.background="rgba(0,0,0,0.25)",r.frameBorder="0",r.style.boxSizing="border-box",r.style.border="1px solid white",document.body.append(r),()=>{document.getElementById(G)&&document.getElementById(G).remove()}}({handshake:await e().get("challenge.handshake"),l6n:window.location.origin}),a=async({data:e})=>{if(console.log("MESSAGE",e),"FCL::CHALLENGE::RESPONSE"!==e.type)return;r(),window.removeEventListener("message",a);const n={addr:e.addr,cid:"did:fcl:"+e.addr,loggedIn:!0,services:$(e.services||[],await V(e.hks,e.code))};v(ae,"SET_CURRENT_USER",n),t(await pe())};window.addEventListener("message",a)})}function de(){le(),v(ae,"DEL_CURRENT_USER")}async function fe(e){le();const t=function(e=[],t){return e.find(e=>e.type===t)}((await ue()).services,"authz");let n;return e.role.proposer&&(n=(await async function(){le();const{addr:e}=await pe();if(null==e)throw new Error("No Flow Address for Current User");const{account:t}=await P([m(e)]);return t}()).keys.find(e=>e.index===t.keyId).sequenceNumber),{...e,addr:t.addr,keyId:t.keyId,sequenceNum:n,signature:e.signature||null,signingFunction:async e=>async function(e,t){const n=await re[e.method](e,t);return null==n.sig&&(n.sig=n.signature),null==n.signature&&(n.signature=n.sig),console.log("Normalized Composite Signature From Wallet Provider",n),function(e,t){try{if(null==e.addr)throw new Error(Y("addr","Address"));if(null==e.keyId)throw new Error(Y("keyId"));if(null==e.signature)throw new Error(Y("signature"));if(e.addr!==t.addr)throw new Error(ee("addr","Address"));if(e.keyId!==t.keyId)throw new Error(ee("keyId"))}catch(n){throw console.error(n,"\n\n",{"Composite Signature":e,"Authz Service":t}),new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+n.message)}}(n,e),n}(t,e),resolve:null,roles:e.roles}}function ye(e){return async function(){return le(),await ue(),v(ae,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})}}function me(e){le();const t=h(async t=>{for(t.send(ae,E);;){const n=await t.receive();if("@EXIT"===n.tag)return void t.send(ae,b);e(n.data)}});return()=>v(t,"@EXIT")}function pe(){return le(),v(ae,"SNAPSHOT",null,{expectReply:!0,timeout:0})}const he=()=>({authenticate:ue,unauthenticate:de,authorization:fe,param:ye,subscribe:me,snapshot:pe}),ge=()=>he().authenticate(),we=()=>he().unauthenticate(),Ee="0.0.55-debug.15";export{Ee as VERSION,ge as authenticate,he as currentUser,A as decode,H as events,R as resolve,M as sansPrefix,P as send,N as serialize,_ as tx,we as unauthenticate,J as withPrefix};
//# sourceMappingURL=fcl.modern.js.map

@@ -1,2 +0,2 @@

import{config as e}from"@onflow/config";export{config}from"@onflow/config";import{resolve as r,resolveRefBlockId as t,resolveParams as n,resolveArguments as o,resolveAccounts as i,resolveSignatures as u,resolveValidators as s,build as c,send as a,decodeResponse as l,getTransactionStatus as f,getEvents as d,getLatestBlock as h,getAccount as m}from"@onflow/sdk";export{arg,args,authorization,authorizations,build,cadence,cdc,getAccount,getBlockByHeight,getBlockById,getEvents,getLatestBlock,getTransactionStatus,isBad,isOk,limit,param,params,payer,ping,pipe,proposer,ref,script,transaction,why}from"@onflow/sdk";import{INIT as v,SUBSCRIBE as y,UPDATED as P,UNSUBSCRIBE as p,SNAPSHOT as g,subscriber as E,spawn as b,snapshoter as w,send as S}from"@onflow/util-actor";import{Identity as j}from"@onflow/types";e().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var T,I,A=function(c){try{return Promise.resolve(e().get("accessNode.api")).then(function(e){return r(c,[t({node:e}),n,o,i,u,s])})}catch(e){return Promise.reject(e)}},k=function(r,t){void 0===r&&(r=[]),void 0===t&&(t={});try{var n=function(e){return t.node=e,Array.isArray(r)&&(r=c(r)),Promise.resolve(A(r)).then(function(e){return a(e,t)})},o=t.node;return Promise.resolve(o?n(o):Promise.resolve(e().get("accessNode.api")).then(n))}catch(e){return Promise.reject(e)}},O=function(e){void 0===e&&(e=[]);try{var r=function(){return Promise.resolve(A(e)).then(JSON.stringify)},t=function(){if(Array.isArray(e))return Promise.resolve(c(e)).then(function(r){e=r})}();return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},N=function(r){try{return Promise.resolve(e().where(/^decoder\./)).then(function(e){var t=Object.fromEntries(Object.entries(e).map(function(e){var r=e[0],t=e[1];return[r="/"+r.replace(/^decoder\./,"")+"$/",t]}));return l(r,t)})}catch(e){return Promise.reject(e)}},R=function(e){try{return Promise.resolve(k([f(e)])).then(N)}catch(e){return Promise.reject(e)}},x=function(e){return e.status>=4},C=function(e){return e.status>=3},L=function(e){return e.status>=2},U=((T={})[v]=function(e){try{return Promise.resolve(R(e.self())).then(function(r){x(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},T[y]=function(e,r){e.subscribe(r.from),e.send(r.from,P,e.all())},T[p]=function(e,r){e.unsubscribe(r.from)},T[g]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},T.POLL=function(e){try{return Promise.resolve(R(e.self())).then(function(r){var t,n;x(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),t=e.all(),n=r,JSON.stringify(t)!==JSON.stringify(n)&&e.broadcast(P,r),e.merge(r)})}catch(e){return Promise.reject(e)}},T),D=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},z=function(e){return b(U,D(e))};function B(e){function r(r){return E(D(e),z,r)}function t(e){return function(t){void 0===t&&(t={});var n=t.suppress||!1;return new Promise(function(t,o){var i=r(function(r){r.statusCode&&!n?(o(r.errorMessage),i()):e(r)&&(t(r),i())})})}}return{snapshot:function(){return w(e,z)},subscribe:r,onceFinalized:t(L),onceExecuted:t(C),onceSealed:t(x)}}function _(){return(_=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function M(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function F(e){var r=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,r){if(e){if("string"==typeof e)return M(e,void 0);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(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?M(e,void 0):void 0}}(e)))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.")}return(r=e[Symbol.iterator]()).next.bind(r)}B.isUnknown=function(e){return e.status>=0},B.isPending=function(e){return e.status>=1},B.isFinalized=L,B.isExecuted=C,B.isSealed=x,B.isExpired=function(e){return 5===e.status};var H=function(){try{return Promise.resolve(k([h()])).then(N)}catch(e){return Promise.reject(e)}},J=function(r){try{var t=setTimeout;return Promise.resolve(e().get("fcl.eventPollRate",1e4)).then(function(e){return t(function(){return r.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},G=((I={}).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(H()).then(function(r){t.call(e,"hwm",r);var n=e.put;return Promise.resolve(J(e)).then(function(r){n.call(e,"tick",r)})})}return Promise.resolve(H()).then(function(t){return e.put("hwm",t),Promise.resolve(k([d(e.self(),r.height,t.height-1)])).then(function(r){return Promise.resolve(N(r)).then(function(r){for(var t,n=F(r);!(t=n()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(J(e)).then(function(r){o.call(e,"tick",r)})})})})}();return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},I[y]=function(e,r){try{var t=function(){e.subscribe(r.from)},n=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(J(e)).then(function(t){r.call(e,"tick",t)})}}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},I[p]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},I),V=function(e){return b(G,e)};function q(e){return{subscribe:function(r){return E(e,V,r)}}}function W(e){return null==e?null:e.replace(/^0x/,"")}function X(e){return null==e?null:"0x"+W(e)}var K="FCL_IFRAME_CHALLENGE";function Z(e,r){void 0===r&&(r=!0);var t=new URL(e.endpoint);if(r)for(var n=0,o=Object.entries(e.params||{});n<o.length;n++){var i=o[n];t.searchParams.append(i[0],i[1])}return t}var $="FCL_IFRAME_AUTHZ";function Q(e){if(!document.getElementById($)){var r=Z(e),t=document.createElement("iframe");return t.src=r.href,t.id=$,t.allow="usb",t.style.position="fixed",t.style.top="0px",t.style.right="0px",t.style.left="0px",t.style.bottom="0px",t.style.height="100vh",t.style.width="100vw",t.style.display="block",t.style.background="rgba(0,0,0,0.25)",t.frameBorder="0",t.style.boxSizing="border-box",t.style.border="1px solid white",document.body.append(t),[t,function(){document.getElementById($)&&document.getElementById($).remove()}]}}var Y,ee={"HTTP/GET":"GET","HTTP/POST":"POST"},re=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},te=function(e,r){return"Missing "+re(e,r)+" in Composite Signature."},ne=function(e,r){return re(e,r)+" in Composit Signature did not match the requested "+e+"."},oe="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",ie=oe.length,ue={"HTTP/POST":function(e,r){try{var t=function(){},n=null;return Promise.resolve(function(e,r){try{var t=e()}catch(e){return r()}return t&&t.then?t.then(r,r):r()}(function(){return function(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(function(){return Promise.resolve(fetch(Z(e),{method:"POST",headers:{"Content-Type":"application/json"},body:r?JSON.stringify(r):void 0}).then(function(e){return e.json()})).then(function(e){if(e.local&&e.local.length>0){var r=Q(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(Z(r),{method:ee[r.method],headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(r){"APPROVED"===r.status?t(r.compositeSignature):"DECLINED"===r.status?n({status:r.status,reason:r.reason}):setTimeout(function(){t(e(r.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){n=e})})},function(e){throw t(),console.error(e),e})},function(){return t(),n}))}catch(e){return Promise.reject(e)}},"IFRAME/RPC":function(e,r){try{return Promise.resolve(new Promise(function(t,n){try{var o=function(){for(var e="",r=32;r--;)e+=oe[Math.random()*ie|0];return e}(),i=Q(e)[0];console.log("AUTHZ IFRAME",i),setTimeout(function(){i.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")},500),window.addEventListener("message",function e(r){var i=r.data;try{if("object"!=typeof i)return Promise.resolve();if("2.0"!==i.jsonrpc)return Promise.resolve();if(i.id!==o)return Promise.resolve();var u=i.result;return"APPROVED"===u.status?(window.removeEventListener("message",e),t(u.compositeSignature)):"DECLINED"===u.status?(window.removeEventListener("message",e),n({status:u.status,reason:u.reason})):(window.removeEventListener("message",e),n({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"})),Promise.resolve()}catch(e){return Promise.reject(e)}})}catch(e){console.error("EXPECTING BOOM HERE",e),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function se(e,r,t){if(!e.s){if(t instanceof ae){if(!t.s)return void(t.o=se.bind(null,e,r));1&r&&(r=t.s),t=t.v}if(t&&t.then)return void t.then(se.bind(null,e,r),se.bind(null,e,2));e.s=r,e.v=t;var n=e.o;n&&n(e)}}var ce=function(e){try{return ge(),Promise.resolve(fe()).then(function(r){function t(){return _({},e,{addr:i.addr,keyId:i.keyId,sequenceNum:o,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(function(e,r){try{return Promise.resolve(ue[e.method](e,r)).then(function(r){return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),console.log("Normalized Composite Signature From Wallet Provider",r),function(e,r){try{if(null==e.addr)throw new Error(te("addr","Address"));if(null==e.keyId)throw new Error(te("keyId"));if(null==e.signature)throw new Error(te("signature"));if(e.addr!==r.addr)throw new Error(ne("addr","Address"));if(e.keyId!==r.keyId)throw new Error(ne("keyId"))}catch(t){throw console.error(t,"\n\n",{"Composite Signature":e,"Authz Service":r}),new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+t.message)}}(r,e),r})}catch(e){return Promise.reject(e)}}(i,e))}catch(e){return Promise.reject(e)}},resolve:null,roles:e.roles})}var n,o,i=(void 0===(n=r.services)&&(n=[]),n.find(function(e){return"authz"===e.type})),u=function(){if(e.role.proposer)return Promise.resolve(function(){try{return ge(),Promise.resolve(Se()).then(function(e){var r=e.addr;if(null==r)throw new Error("No Flow Address for Current User");return Promise.resolve(k([m(r)])).then(function(e){return e.account})})}catch(e){return Promise.reject(e)}}()).then(function(e){var r=e.keys.find(function(e){return e.index===i.keyId});o=r.sequenceNumber})}();return u&&u.then?u.then(t):t()})}catch(e){return Promise.reject(e)}},ae=function(){function e(){}return e.prototype.then=function(r,t){var n=new e,o=this.s;if(o){var i=1&o?r:t;if(i){try{se(n,1,i(this.v))}catch(e){se(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?se(n,1,r?r(o):o):t?se(n,1,t(o)):se(n,2,o)}catch(e){se(n,2,e)}},n},e}();function le(e){return e instanceof ae&&1&e.s}var fe=function(){try{return Promise.resolve(new Promise(function(r){try{return ge(),Promise.resolve(Se()).then(function(t){return t.loggedIn?r(t):Promise.resolve(e().get("challenge.handshake")).then(function(e){var t=function(e){var r=e.handshake,t=e.l6n;if(!document.getElementById(K)){var n=new URL(r);n.searchParams.append("l6n",t);var o=document.createElement("iframe");return o.src=n.href,o.id=K,o.allow="usb",o.style.position="fixed",o.style.top="0px",o.style.right="0px",o.style.left="0px",o.style.bottom="0px",o.style.height="100vh",o.style.width="100vw",o.style.display="block",o.style.background="rgba(0,0,0,0.25)",o.frameBorder="0",o.style.boxSizing="border-box",o.style.border="1px solid white",document.body.append(o),function(){document.getElementById(K)&&document.getElementById(K).remove()}}}({handshake:e,l6n:window.location.origin});window.addEventListener("message",function e(n){var o=n.data;try{if(console.log("MESSAGE",o),o.type!==ve)return Promise.resolve();t(),window.removeEventListener("message",e);var i="did:fcl:"+o.addr,u=o.addr,s=o.services||[];return Promise.resolve(function(e,r){try{if(null==e||null==r)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",r),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 r=[];if(Array.isArray(e.authorizations))for(var t,n=F(e.authorizations);!(t=n()).done;)r.push(_({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&r.push(_({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(o.hks,o.code)).then(function(e){var t,n,o={addr:u,cid:i,loggedIn:!0,services:(t=s,n=e,void 0===t&&(t=[]),void 0===n&&(n=[]),[].concat(t,n))};return S(de,me,o),Promise.resolve(Se()).then(function(e){r(e)})})}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},de="CURRENT_USER",he="CURRENT_USER/UPDATED",me="SET_CURRENT_USER",ve="FCL::CHALLENGE::RESPONSE",ye='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',Pe=function(e){try{return localStorage.setItem(de,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},pe=((Y={})[v]=function(e){try{var r=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(ye),r=JSON.parse(localStorage.getItem(de));return null!=r&&e.VERSION!==r.VERSION?(localStorage.removeItem(de),Promise.resolve(e)):Promise.resolve(r||e)}catch(e){return Promise.reject(e)}}()).then(function(t){r.call(e,t)})}catch(e){return Promise.reject(e)}},Y[y]=function(e,r){e.subscribe(r.from),e.send(r.from,he,e.all())},Y[p]=function(e,r){e.unsubscribe(r.from)},Y.SNAPSHOT=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Y[me]=function(e,r,t){try{return e.merge(t),Pe(e.all()),e.broadcast(he,e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Y.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(ye)),Pe(e.all()),e.broadcast(he,e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Y.GET_AS_PARAM=function(e,r,t){var n=t.key;try{return r.reply({key:n,value:e.get("addr",null),xform:j}),Promise.resolve()}catch(e){return Promise.reject(e)}},Y),ge=function(){return b(pe,de)};function Ee(){ge(),S(de,"DEL_CURRENT_USER")}function be(e){return function(){try{return ge(),Promise.resolve(fe()).then(function(){return S(de,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})})}catch(e){return Promise.reject(e)}}}function we(e){ge();var r=b(function(r){try{var t;return r.send(de,y),Promise.resolve(function(e,r,t){for(var n;;){var o=e();if(le(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=t();if(i&&i.then){if(!le(i)){n=1;break}i=i.s}}var u=new ae,s=se.bind(null,u,2);return(0===n?o.then(a):1===n?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,s):a(o):se(u,1,i)})).then(void 0,s),u;function c(r){i=r;do{if(!(o=e())||le(o)&&!o.v)return void se(u,1,i);if(o.then)return void o.then(a).then(void 0,s);le(i=t())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,s)}function a(e){e?(i=t())&&i.then?i.then(c).then(void 0,s):c(i):se(u,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(n){if("@EXIT"===n.tag)return r.send(de,p),void(t=1);e(n.data)})}))}catch(e){return Promise.reject(e)}});return function(){return S(r,"@EXIT")}}function Se(){return ge(),S(de,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var je=function(){return{authenticate:fe,unauthenticate:Ee,authorization:ce,param:be,subscribe:we,snapshot:Se}},Te=function(){return je().authenticate()},Ie=function(){return je().unauthenticate()},Ae="0.0.55-debug.14";export{Ae as VERSION,Te as authenticate,je as currentUser,N as decode,q as events,A as resolve,W as sansPrefix,k as send,O as serialize,B as tx,Ie as unauthenticate,X as withPrefix};
import{config as e}from"@onflow/config";export{config}from"@onflow/config";import{resolve as r,resolveRefBlockId as t,resolveParams as n,resolveArguments as o,resolveAccounts as i,resolveSignatures as u,resolveValidators as s,build as c,send as a,decodeResponse as l,getTransactionStatus as f,getEvents as d,getLatestBlock as h,getAccount as m}from"@onflow/sdk";export{arg,args,authorization,authorizations,build,cadence,cdc,getAccount,getBlockByHeight,getBlockById,getEvents,getLatestBlock,getTransactionStatus,isBad,isOk,limit,param,params,payer,ping,pipe,proposer,ref,script,transaction,why}from"@onflow/sdk";import{INIT as v,SUBSCRIBE as y,UPDATED as P,UNSUBSCRIBE as p,SNAPSHOT as g,subscriber as E,spawn as b,snapshoter as w,send as S}from"@onflow/util-actor";import{Identity as j}from"@onflow/types";e().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var T,I,A=function(c){try{return Promise.resolve(e().get("accessNode.api")).then(function(e){return r(c,[t({node:e}),n,o,i,u,s])})}catch(e){return Promise.reject(e)}},k=function(r,t){void 0===r&&(r=[]),void 0===t&&(t={});try{var n=function(e){return t.node=e,Array.isArray(r)&&(r=c(r)),Promise.resolve(A(r)).then(function(e){return a(e,t)})},o=t.node;return Promise.resolve(o?n(o):Promise.resolve(e().get("accessNode.api")).then(n))}catch(e){return Promise.reject(e)}},O=function(e){void 0===e&&(e=[]);try{var r=function(){return Promise.resolve(A(e)).then(JSON.stringify)},t=function(){if(Array.isArray(e))return Promise.resolve(c(e)).then(function(r){e=r})}();return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},N=function(r){try{return Promise.resolve(e().where(/^decoder\./)).then(function(e){var t=Object.fromEntries(Object.entries(e).map(function(e){var r=e[0],t=e[1];return[r="/"+r.replace(/^decoder\./,"")+"$/",t]}));return l(r,t)})}catch(e){return Promise.reject(e)}},R=function(e){try{return Promise.resolve(k([f(e)])).then(N)}catch(e){return Promise.reject(e)}},x=function(e){return e.status>=4},C=function(e){return e.status>=3},L=function(e){return e.status>=2},U=((T={})[v]=function(e){try{return Promise.resolve(R(e.self())).then(function(r){x(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},T[y]=function(e,r){e.subscribe(r.from),e.send(r.from,P,e.all())},T[p]=function(e,r){e.unsubscribe(r.from)},T[g]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},T.POLL=function(e){try{return Promise.resolve(R(e.self())).then(function(r){var t,n;x(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),t=e.all(),n=r,JSON.stringify(t)!==JSON.stringify(n)&&e.broadcast(P,r),e.merge(r)})}catch(e){return Promise.reject(e)}},T),D=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},z=function(e){return b(U,D(e))};function B(e){function r(r){return E(D(e),z,r)}function t(e){return function(t){void 0===t&&(t={});var n=t.suppress||!1;return new Promise(function(t,o){var i=r(function(r){r.statusCode&&!n?(o(r.errorMessage),i()):e(r)&&(t(r),i())})})}}return{snapshot:function(){return w(e,z)},subscribe:r,onceFinalized:t(L),onceExecuted:t(C),onceSealed:t(x)}}function _(){return(_=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function M(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function F(e){var r=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,r){if(e){if("string"==typeof e)return M(e,void 0);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(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?M(e,void 0):void 0}}(e)))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.")}return(r=e[Symbol.iterator]()).next.bind(r)}B.isUnknown=function(e){return e.status>=0},B.isPending=function(e){return e.status>=1},B.isFinalized=L,B.isExecuted=C,B.isSealed=x,B.isExpired=function(e){return 5===e.status};var H=function(){try{return Promise.resolve(k([h()])).then(N)}catch(e){return Promise.reject(e)}},J=function(r){try{var t=setTimeout;return Promise.resolve(e().get("fcl.eventPollRate",1e4)).then(function(e){return t(function(){return r.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},G=((I={}).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(H()).then(function(r){t.call(e,"hwm",r);var n=e.put;return Promise.resolve(J(e)).then(function(r){n.call(e,"tick",r)})})}return Promise.resolve(H()).then(function(t){return e.put("hwm",t),Promise.resolve(k([d(e.self(),r.height,t.height-1)])).then(function(r){return Promise.resolve(N(r)).then(function(r){for(var t,n=F(r);!(t=n()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(J(e)).then(function(r){o.call(e,"tick",r)})})})})}();return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},I[y]=function(e,r){try{var t=function(){e.subscribe(r.from)},n=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(J(e)).then(function(t){r.call(e,"tick",t)})}}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},I[p]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},I),V=function(e){return b(G,e)};function q(e){return{subscribe:function(r){return E(e,V,r)}}}function W(e){return null==e?null:e.replace(/^0x/,"")}function X(e){return null==e?null:"0x"+W(e)}var K="FCL_IFRAME_CHALLENGE";function Z(e,r){void 0===r&&(r=!0);var t=new URL(e.endpoint);if(r)for(var n=0,o=Object.entries(e.params||{});n<o.length;n++){var i=o[n];t.searchParams.append(i[0],i[1])}return t}var $="FCL_IFRAME_AUTHZ";function Q(e){if(!document.getElementById($)){var r=Z(e),t=document.createElement("iframe");return t.src=r.href,t.id=$,t.allow="usb",t.style.position="fixed",t.style.top="0px",t.style.right="0px",t.style.left="0px",t.style.bottom="0px",t.style.height="100vh",t.style.width="100vw",t.style.display="block",t.style.background="rgba(0,0,0,0.25)",t.frameBorder="0",t.style.boxSizing="border-box",t.style.border="1px solid white",document.body.append(t),[t,function(){document.getElementById($)&&document.getElementById($).remove()}]}}var Y,ee={"HTTP/GET":"GET","HTTP/POST":"POST"},re=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},te=function(e,r){return"Missing "+re(e,r)+" in Composite Signature."},ne=function(e,r){return re(e,r)+" in Composit Signature did not match the requested "+e+"."},oe="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",ie=oe.length,ue={"HTTP/POST":function(e,r){try{var t=function(){},n=null;return Promise.resolve(function(e,r){try{var t=e()}catch(e){return r()}return t&&t.then?t.then(r,r):r()}(function(){return function(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(function(){return Promise.resolve(fetch(Z(e),{method:"POST",headers:{"Content-Type":"application/json"},body:r?JSON.stringify(r):void 0}).then(function(e){return e.json()})).then(function(e){if(e.local&&e.local.length>0){var r=Q(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(Z(r),{method:ee[r.method],headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(r){"APPROVED"===r.status?t(r.compositeSignature):"DECLINED"===r.status?n({status:r.status,reason:r.reason}):setTimeout(function(){t(e(r.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){n=e})})},function(e){throw t(),console.error(e),e})},function(){return t(),n}))}catch(e){return Promise.reject(e)}},"IFRAME/RPC":function(e,r){try{return Promise.resolve(new Promise(function(t,n){try{var o=function(){for(var e="",r=32;r--;)e+=oe[Math.random()*ie|0];return e}(),i=Q(e),u=i[0],s=i[1];console.log("AUTHZ IFRAME",u),setTimeout(function(){u.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")},500),window.addEventListener("message",function e(r){var i=r.data;try{if("object"!=typeof i)return Promise.resolve();if("2.0"!==i.jsonrpc)return Promise.resolve();if(i.id!==o)return Promise.resolve();var u=i.result;return"APPROVED"===u.status?(window.removeEventListener("message",e),s(),t(u.compositeSignature)):"DECLINED"===u.status?(window.removeEventListener("message",e),s(),n({status:u.status,reason:u.reason})):(window.removeEventListener("message",e),s(),n({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"})),Promise.resolve()}catch(e){return Promise.reject(e)}})}catch(e){console.error("EXPECTING BOOM HERE",e),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function se(e,r,t){if(!e.s){if(t instanceof ae){if(!t.s)return void(t.o=se.bind(null,e,r));1&r&&(r=t.s),t=t.v}if(t&&t.then)return void t.then(se.bind(null,e,r),se.bind(null,e,2));e.s=r,e.v=t;var n=e.o;n&&n(e)}}var ce=function(e){try{return ge(),Promise.resolve(fe()).then(function(r){function t(){return _({},e,{addr:i.addr,keyId:i.keyId,sequenceNum:o,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(function(e,r){try{return Promise.resolve(ue[e.method](e,r)).then(function(r){return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),console.log("Normalized Composite Signature From Wallet Provider",r),function(e,r){try{if(null==e.addr)throw new Error(te("addr","Address"));if(null==e.keyId)throw new Error(te("keyId"));if(null==e.signature)throw new Error(te("signature"));if(e.addr!==r.addr)throw new Error(ne("addr","Address"));if(e.keyId!==r.keyId)throw new Error(ne("keyId"))}catch(t){throw console.error(t,"\n\n",{"Composite Signature":e,"Authz Service":r}),new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+t.message)}}(r,e),r})}catch(e){return Promise.reject(e)}}(i,e))}catch(e){return Promise.reject(e)}},resolve:null,roles:e.roles})}var n,o,i=(void 0===(n=r.services)&&(n=[]),n.find(function(e){return"authz"===e.type})),u=function(){if(e.role.proposer)return Promise.resolve(function(){try{return ge(),Promise.resolve(Se()).then(function(e){var r=e.addr;if(null==r)throw new Error("No Flow Address for Current User");return Promise.resolve(k([m(r)])).then(function(e){return e.account})})}catch(e){return Promise.reject(e)}}()).then(function(e){var r=e.keys.find(function(e){return e.index===i.keyId});o=r.sequenceNumber})}();return u&&u.then?u.then(t):t()})}catch(e){return Promise.reject(e)}},ae=function(){function e(){}return e.prototype.then=function(r,t){var n=new e,o=this.s;if(o){var i=1&o?r:t;if(i){try{se(n,1,i(this.v))}catch(e){se(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?se(n,1,r?r(o):o):t?se(n,1,t(o)):se(n,2,o)}catch(e){se(n,2,e)}},n},e}();function le(e){return e instanceof ae&&1&e.s}var fe=function(){try{return Promise.resolve(new Promise(function(r){try{return ge(),Promise.resolve(Se()).then(function(t){return t.loggedIn?r(t):Promise.resolve(e().get("challenge.handshake")).then(function(e){var t=function(e){var r=e.handshake,t=e.l6n;if(!document.getElementById(K)){var n=new URL(r);n.searchParams.append("l6n",t);var o=document.createElement("iframe");return o.src=n.href,o.id=K,o.allow="usb",o.style.position="fixed",o.style.top="0px",o.style.right="0px",o.style.left="0px",o.style.bottom="0px",o.style.height="100vh",o.style.width="100vw",o.style.display="block",o.style.background="rgba(0,0,0,0.25)",o.frameBorder="0",o.style.boxSizing="border-box",o.style.border="1px solid white",document.body.append(o),function(){document.getElementById(K)&&document.getElementById(K).remove()}}}({handshake:e,l6n:window.location.origin});window.addEventListener("message",function e(n){var o=n.data;try{if(console.log("MESSAGE",o),o.type!==ve)return Promise.resolve();t(),window.removeEventListener("message",e);var i="did:fcl:"+o.addr,u=o.addr,s=o.services||[];return Promise.resolve(function(e,r){try{if(null==e||null==r)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",r),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 r=[];if(Array.isArray(e.authorizations))for(var t,n=F(e.authorizations);!(t=n()).done;)r.push(_({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&r.push(_({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(o.hks,o.code)).then(function(e){var t,n,o={addr:u,cid:i,loggedIn:!0,services:(t=s,n=e,void 0===t&&(t=[]),void 0===n&&(n=[]),[].concat(t,n))};return S(de,me,o),Promise.resolve(Se()).then(function(e){r(e)})})}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},de="CURRENT_USER",he="CURRENT_USER/UPDATED",me="SET_CURRENT_USER",ve="FCL::CHALLENGE::RESPONSE",ye='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',Pe=function(e){try{return localStorage.setItem(de,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},pe=((Y={})[v]=function(e){try{var r=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(ye),r=JSON.parse(localStorage.getItem(de));return null!=r&&e.VERSION!==r.VERSION?(localStorage.removeItem(de),Promise.resolve(e)):Promise.resolve(r||e)}catch(e){return Promise.reject(e)}}()).then(function(t){r.call(e,t)})}catch(e){return Promise.reject(e)}},Y[y]=function(e,r){e.subscribe(r.from),e.send(r.from,he,e.all())},Y[p]=function(e,r){e.unsubscribe(r.from)},Y.SNAPSHOT=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Y[me]=function(e,r,t){try{return e.merge(t),Pe(e.all()),e.broadcast(he,e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Y.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(ye)),Pe(e.all()),e.broadcast(he,e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Y.GET_AS_PARAM=function(e,r,t){var n=t.key;try{return r.reply({key:n,value:e.get("addr",null),xform:j}),Promise.resolve()}catch(e){return Promise.reject(e)}},Y),ge=function(){return b(pe,de)};function Ee(){ge(),S(de,"DEL_CURRENT_USER")}function be(e){return function(){try{return ge(),Promise.resolve(fe()).then(function(){return S(de,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})})}catch(e){return Promise.reject(e)}}}function we(e){ge();var r=b(function(r){try{var t;return r.send(de,y),Promise.resolve(function(e,r,t){for(var n;;){var o=e();if(le(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=t();if(i&&i.then){if(!le(i)){n=1;break}i=i.s}}var u=new ae,s=se.bind(null,u,2);return(0===n?o.then(a):1===n?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,s):a(o):se(u,1,i)})).then(void 0,s),u;function c(r){i=r;do{if(!(o=e())||le(o)&&!o.v)return void se(u,1,i);if(o.then)return void o.then(a).then(void 0,s);le(i=t())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,s)}function a(e){e?(i=t())&&i.then?i.then(c).then(void 0,s):c(i):se(u,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(n){if("@EXIT"===n.tag)return r.send(de,p),void(t=1);e(n.data)})}))}catch(e){return Promise.reject(e)}});return function(){return S(r,"@EXIT")}}function Se(){return ge(),S(de,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var je=function(){return{authenticate:fe,unauthenticate:Ee,authorization:ce,param:be,subscribe:we,snapshot:Se}},Te=function(){return je().authenticate()},Ie=function(){return je().unauthenticate()},Ae="0.0.55-debug.15";export{Ae as VERSION,Te as authenticate,je as currentUser,N as decode,q as events,A as resolve,W as sansPrefix,k as send,O as serialize,B as tx,Ie as unauthenticate,X as withPrefix};
//# sourceMappingURL=fcl.module.js.map

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@onflow/config"),require("@onflow/sdk"),require("@onflow/util-actor"),require("@onflow/types")):"function"==typeof define&&define.amd?define(["exports","@onflow/config","@onflow/sdk","@onflow/util-actor","@onflow/types"],r):r((e=e||self).fcl={},e.config,e.sdk,e.utilActor,e.types)}(this,function(e,r,t,n,o){r.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var i,u,s=function(e){try{return Promise.resolve(r.config().get("accessNode.api")).then(function(r){return t.resolve(e,[t.resolveRefBlockId({node:r}),t.resolveParams,t.resolveArguments,t.resolveAccounts,t.resolveSignatures,t.resolveValidators])})}catch(e){return Promise.reject(e)}},c=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{var o=function(r){return n.node=r,Array.isArray(e)&&(e=t.build(e)),Promise.resolve(s(e)).then(function(e){return t.send(e,n)})},i=n.node;return Promise.resolve(i?o(i):Promise.resolve(r.config().get("accessNode.api")).then(o))}catch(e){return Promise.reject(e)}},a=function(e){try{return Promise.resolve(r.config().where(/^decoder\./)).then(function(r){var n=Object.fromEntries(Object.entries(r).map(function(e){var r=e[0],t=e[1];return[r="/"+r.replace(/^decoder\./,"")+"$/",t]}));return t.decodeResponse(e,n)})}catch(e){return Promise.reject(e)}},l=function(e){try{return Promise.resolve(c([t.getTransactionStatus(e)])).then(a)}catch(e){return Promise.reject(e)}},f=function(e){return e.status>=4},d=function(e){return e.status>=3},m=function(e){return e.status>=2},h=((i={})[n.INIT]=function(e){try{return Promise.resolve(l(e.self())).then(function(r){f(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},i[n.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,n.UPDATED,e.all())},i[n.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},i[n.SNAPSHOT]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},i.POLL=function(e){try{return Promise.resolve(l(e.self())).then(function(r){var t,o;f(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),t=e.all(),o=r,JSON.stringify(t)!==JSON.stringify(o)&&e.broadcast(n.UPDATED,r),e.merge(r)})}catch(e){return Promise.reject(e)}},i),v=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},y=function(e){return n.spawn(h,v(e))};function p(e){function r(r){return n.subscriber(v(e),y,r)}function t(e){return function(t){void 0===t&&(t={});var n=t.suppress||!1;return new Promise(function(t,o){var i=r(function(r){r.statusCode&&!n?(o(r.errorMessage),i()):e(r)&&(t(r),i())})})}}return{snapshot:function(){return n.snapshoter(e,y)},subscribe:r,onceFinalized:t(m),onceExecuted:t(d),onceSealed:t(f)}}function P(){return(P=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function g(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function b(e){var r=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,r){if(e){if("string"==typeof e)return g(e,void 0);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(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?g(e,void 0):void 0}}(e)))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.")}return(r=e[Symbol.iterator]()).next.bind(r)}p.isUnknown=function(e){return e.status>=0},p.isPending=function(e){return e.status>=1},p.isFinalized=m,p.isExecuted=d,p.isSealed=f,p.isExpired=function(e){return 5===e.status};var E=function(){try{return Promise.resolve(c([t.getLatestBlock()])).then(a)}catch(e){return Promise.reject(e)}},S=function(e){try{var t=setTimeout;return Promise.resolve(r.config().get("fcl.eventPollRate",1e4)).then(function(r){return t(function(){return e.sendSelf("TICK")},r)})}catch(e){return Promise.reject(e)}},j=((u={}).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(E()).then(function(r){n.call(e,"hwm",r);var t=e.put;return Promise.resolve(S(e)).then(function(r){t.call(e,"tick",r)})})}return Promise.resolve(E()).then(function(n){return e.put("hwm",n),Promise.resolve(c([t.getEvents(e.self(),r.height,n.height-1)])).then(function(r){return Promise.resolve(a(r)).then(function(r){for(var t,n=b(r);!(t=n()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(S(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)}},u[n.SUBSCRIBE]=function(e,r){try{var t=function(){e.subscribe(r.from)},n=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(S(e)).then(function(t){r.call(e,"tick",t)})}}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},u[n.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},u),w=function(e){return n.spawn(j,e)};function O(e){return null==e?null:e.replace(/^0x/,"")}var I="FCL_IFRAME_CHALLENGE";function T(e,r){void 0===r&&(r=!0);var t=new URL(e.endpoint);if(r)for(var n=0,o=Object.entries(e.params||{});n<o.length;n++){var i=o[n];t.searchParams.append(i[0],i[1])}return t}var A="FCL_IFRAME_AUTHZ";function R(e){if(!document.getElementById(A)){var r=T(e),t=document.createElement("iframe");return t.src=r.href,t.id=A,t.allow="usb",t.style.position="fixed",t.style.top="0px",t.style.right="0px",t.style.left="0px",t.style.bottom="0px",t.style.height="100vh",t.style.width="100vw",t.style.display="block",t.style.background="rgba(0,0,0,0.25)",t.frameBorder="0",t.style.boxSizing="border-box",t.style.border="1px solid white",document.body.append(t),[t,function(){document.getElementById(A)&&document.getElementById(A).remove()}]}}var k,N={"HTTP/GET":"GET","HTTP/POST":"POST"},B=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},C=function(e,r){return"Missing "+B(e,r)+" in Composite Signature."},U=function(e,r){return B(e,r)+" in Composit Signature did not match the requested "+e+"."},x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",L=x.length,D={"HTTP/POST":function(e,r){try{var t=function(){},n=null;return Promise.resolve(function(e,r){try{var t=e()}catch(e){return r()}return t&&t.then?t.then(r,r):r()}(function(){return function(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(function(){return Promise.resolve(fetch(T(e),{method:"POST",headers:{"Content-Type":"application/json"},body:r?JSON.stringify(r):void 0}).then(function(e){return e.json()})).then(function(e){if(e.local&&e.local.length>0){var r=R(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(T(r),{method:N[r.method],headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(r){"APPROVED"===r.status?t(r.compositeSignature):"DECLINED"===r.status?n({status:r.status,reason:r.reason}):setTimeout(function(){t(e(r.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){n=e})})},function(e){throw t(),console.error(e),e})},function(){return t(),n}))}catch(e){return Promise.reject(e)}},"IFRAME/RPC":function(e,r){try{return Promise.resolve(new Promise(function(t,n){try{var o=function(){for(var e="",r=32;r--;)e+=x[Math.random()*L|0];return e}(),i=R(e)[0];console.log("AUTHZ IFRAME",i),setTimeout(function(){i.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")},500),window.addEventListener("message",function e(r){var i=r.data;try{if("object"!=typeof i)return Promise.resolve();if("2.0"!==i.jsonrpc)return Promise.resolve();if(i.id!==o)return Promise.resolve();var u=i.result;return"APPROVED"===u.status?(window.removeEventListener("message",e),t(u.compositeSignature)):"DECLINED"===u.status?(window.removeEventListener("message",e),n({status:u.status,reason:u.reason})):(window.removeEventListener("message",e),n({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"})),Promise.resolve()}catch(e){return Promise.reject(e)}})}catch(e){console.error("EXPECTING BOOM HERE",e),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function z(e,r,t){if(!e.s){if(t instanceof H){if(!t.s)return void(t.o=z.bind(null,e,r));1&r&&(r=t.s),t=t.v}if(t&&t.then)return void t.then(z.bind(null,e,r),z.bind(null,e,2));e.s=r,e.v=t;var n=e.o;n&&n(e)}}var _=function(e){try{return Z(),Promise.resolve(F()).then(function(r){function n(){return P({},e,{addr:u.addr,keyId:u.keyId,sequenceNum:i,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(function(e,r){try{return Promise.resolve(D[e.method](e,r)).then(function(r){return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),console.log("Normalized Composite Signature From Wallet Provider",r),function(e,r){try{if(null==e.addr)throw new Error(C("addr","Address"));if(null==e.keyId)throw new Error(C("keyId"));if(null==e.signature)throw new Error(C("signature"));if(e.addr!==r.addr)throw new Error(U("addr","Address"));if(e.keyId!==r.keyId)throw new Error(U("keyId"))}catch(t){throw console.error(t,"\n\n",{"Composite Signature":e,"Authz Service":r}),new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+t.message)}}(r,e),r})}catch(e){return Promise.reject(e)}}(u,e))}catch(e){return Promise.reject(e)}},resolve:null,roles:e.roles})}var o,i,u=(void 0===(o=r.services)&&(o=[]),o.find(function(e){return"authz"===e.type})),s=function(){if(e.role.proposer)return Promise.resolve(function(){try{return Z(),Promise.resolve(ee()).then(function(e){var r=e.addr;if(null==r)throw new Error("No Flow Address for Current User");return Promise.resolve(c([t.getAccount(r)])).then(function(e){return e.account})})}catch(e){return Promise.reject(e)}}()).then(function(e){var r=e.keys.find(function(e){return e.index===u.keyId});i=r.sequenceNumber})}();return s&&s.then?s.then(n):n()})}catch(e){return Promise.reject(e)}},H=function(){function e(){}return e.prototype.then=function(r,t){var n=new e,o=this.s;if(o){var i=1&o?r:t;if(i){try{z(n,1,i(this.v))}catch(e){z(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?z(n,1,r?r(o):o):t?z(n,1,t(o)):z(n,2,o)}catch(e){z(n,2,e)}},n},e}();function M(e){return e instanceof H&&1&e.s}var F=function(){try{return Promise.resolve(new Promise(function(e){try{return Z(),Promise.resolve(ee()).then(function(t){return t.loggedIn?e(t):Promise.resolve(r.config().get("challenge.handshake")).then(function(r){var t=function(e){var r=e.handshake,t=e.l6n;if(!document.getElementById(I)){var n=new URL(r);n.searchParams.append("l6n",t);var o=document.createElement("iframe");return o.src=n.href,o.id=I,o.allow="usb",o.style.position="fixed",o.style.top="0px",o.style.right="0px",o.style.left="0px",o.style.bottom="0px",o.style.height="100vh",o.style.width="100vw",o.style.display="block",o.style.background="rgba(0,0,0,0.25)",o.frameBorder="0",o.style.boxSizing="border-box",o.style.border="1px solid white",document.body.append(o),function(){document.getElementById(I)&&document.getElementById(I).remove()}}}({handshake:r,l6n:window.location.origin});window.addEventListener("message",function r(o){var i=o.data;try{if(console.log("MESSAGE",i),i.type!==q)return Promise.resolve();t(),window.removeEventListener("message",r);var u="did:fcl:"+i.addr,s=i.addr,c=i.services||[];return Promise.resolve(function(e,r){try{if(null==e||null==r)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",r),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 r=[];if(Array.isArray(e.authorizations))for(var t,n=b(e.authorizations);!(t=n()).done;)r.push(P({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&r.push(P({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(i.hks,i.code)).then(function(r){var t,o,i={addr:s,cid:u,loggedIn:!0,services:(t=c,o=r,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o))};return n.send(J,V,i),Promise.resolve(ee()).then(function(r){e(r)})})}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},J="CURRENT_USER",G="CURRENT_USER/UPDATED",V="SET_CURRENT_USER",q="FCL::CHALLENGE::RESPONSE",W='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',X=function(e){try{return localStorage.setItem(J,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},K=((k={})[n.INIT]=function(e){try{var r=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(W),r=JSON.parse(localStorage.getItem(J));return null!=r&&e.VERSION!==r.VERSION?(localStorage.removeItem(J),Promise.resolve(e)):Promise.resolve(r||e)}catch(e){return Promise.reject(e)}}()).then(function(t){r.call(e,t)})}catch(e){return Promise.reject(e)}},k[n.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,G,e.all())},k[n.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},k.SNAPSHOT=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},k[V]=function(e,r,t){try{return e.merge(t),X(e.all()),e.broadcast(G,e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},k.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(W)),X(e.all()),e.broadcast(G,e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},k.GET_AS_PARAM=function(e,r,t){var n=t.key;try{return r.reply({key:n,value:e.get("addr",null),xform:o.Identity}),Promise.resolve()}catch(e){return Promise.reject(e)}},k),Z=function(){return n.spawn(K,J)};function $(){Z(),n.send(J,"DEL_CURRENT_USER")}function Q(e){return function(){try{return Z(),Promise.resolve(F()).then(function(){return n.send(J,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})})}catch(e){return Promise.reject(e)}}}function Y(e){Z();var r=n.spawn(function(r){try{var t;return r.send(J,n.SUBSCRIBE),Promise.resolve(function(e,r,t){for(var n;;){var o=e();if(M(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=t();if(i&&i.then){if(!M(i)){n=1;break}i=i.s}}var u=new H,s=z.bind(null,u,2);return(0===n?o.then(a):1===n?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,s):a(o):z(u,1,i)})).then(void 0,s),u;function c(r){i=r;do{if(!(o=e())||M(o)&&!o.v)return void z(u,1,i);if(o.then)return void o.then(a).then(void 0,s);M(i=t())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,s)}function a(e){e?(i=t())&&i.then?i.then(c).then(void 0,s):c(i):z(u,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(o){if("@EXIT"===o.tag)return r.send(J,n.UNSUBSCRIBE),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return n.send(r,"@EXIT")}}function ee(){return Z(),n.send(J,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var re=function(){return{authenticate:F,unauthenticate:$,authorization:_,param:Q,subscribe:Y,snapshot:ee}};Object.defineProperty(e,"config",{enumerable:!0,get:function(){return r.config}}),Object.defineProperty(e,"arg",{enumerable:!0,get:function(){return t.arg}}),Object.defineProperty(e,"args",{enumerable:!0,get:function(){return t.args}}),Object.defineProperty(e,"authorization",{enumerable:!0,get:function(){return t.authorization}}),Object.defineProperty(e,"authorizations",{enumerable:!0,get:function(){return t.authorizations}}),Object.defineProperty(e,"build",{enumerable:!0,get:function(){return t.build}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return t.cadence}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return t.cdc}}),Object.defineProperty(e,"getAccount",{enumerable:!0,get:function(){return t.getAccount}}),Object.defineProperty(e,"getBlockByHeight",{enumerable:!0,get:function(){return t.getBlockByHeight}}),Object.defineProperty(e,"getBlockById",{enumerable:!0,get:function(){return t.getBlockById}}),Object.defineProperty(e,"getEvents",{enumerable:!0,get:function(){return t.getEvents}}),Object.defineProperty(e,"getLatestBlock",{enumerable:!0,get:function(){return t.getLatestBlock}}),Object.defineProperty(e,"getTransactionStatus",{enumerable:!0,get:function(){return t.getTransactionStatus}}),Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return t.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return t.isOk}}),Object.defineProperty(e,"limit",{enumerable:!0,get:function(){return t.limit}}),Object.defineProperty(e,"param",{enumerable:!0,get:function(){return t.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return t.params}}),Object.defineProperty(e,"payer",{enumerable:!0,get:function(){return t.payer}}),Object.defineProperty(e,"ping",{enumerable:!0,get:function(){return t.ping}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return t.pipe}}),Object.defineProperty(e,"proposer",{enumerable:!0,get:function(){return t.proposer}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return t.ref}}),Object.defineProperty(e,"script",{enumerable:!0,get:function(){return t.script}}),Object.defineProperty(e,"transaction",{enumerable:!0,get:function(){return t.transaction}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return t.why}}),e.VERSION="0.0.55-debug.14",e.authenticate=function(){return re().authenticate()},e.currentUser=re,e.decode=a,e.events=function(e){return{subscribe:function(r){return n.subscriber(e,w,r)}}},e.resolve=s,e.sansPrefix=O,e.send=c,e.serialize=function(e){void 0===e&&(e=[]);try{var r=function(){return Promise.resolve(s(e)).then(JSON.stringify)},n=function(){if(Array.isArray(e))return Promise.resolve(t.build(e)).then(function(r){e=r})}();return Promise.resolve(n&&n.then?n.then(r):r())}catch(e){return Promise.reject(e)}},e.tx=p,e.unauthenticate=function(){return re().unauthenticate()},e.withPrefix=function(e){return null==e?null:"0x"+O(e)}});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@onflow/config"),require("@onflow/sdk"),require("@onflow/util-actor"),require("@onflow/types")):"function"==typeof define&&define.amd?define(["exports","@onflow/config","@onflow/sdk","@onflow/util-actor","@onflow/types"],r):r((e=e||self).fcl={},e.config,e.sdk,e.utilActor,e.types)}(this,function(e,r,t,n,o){r.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var i,u,s=function(e){try{return Promise.resolve(r.config().get("accessNode.api")).then(function(r){return t.resolve(e,[t.resolveRefBlockId({node:r}),t.resolveParams,t.resolveArguments,t.resolveAccounts,t.resolveSignatures,t.resolveValidators])})}catch(e){return Promise.reject(e)}},c=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{var o=function(r){return n.node=r,Array.isArray(e)&&(e=t.build(e)),Promise.resolve(s(e)).then(function(e){return t.send(e,n)})},i=n.node;return Promise.resolve(i?o(i):Promise.resolve(r.config().get("accessNode.api")).then(o))}catch(e){return Promise.reject(e)}},a=function(e){try{return Promise.resolve(r.config().where(/^decoder\./)).then(function(r){var n=Object.fromEntries(Object.entries(r).map(function(e){var r=e[0],t=e[1];return[r="/"+r.replace(/^decoder\./,"")+"$/",t]}));return t.decodeResponse(e,n)})}catch(e){return Promise.reject(e)}},l=function(e){try{return Promise.resolve(c([t.getTransactionStatus(e)])).then(a)}catch(e){return Promise.reject(e)}},f=function(e){return e.status>=4},d=function(e){return e.status>=3},m=function(e){return e.status>=2},h=((i={})[n.INIT]=function(e){try{return Promise.resolve(l(e.self())).then(function(r){f(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},i[n.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,n.UPDATED,e.all())},i[n.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},i[n.SNAPSHOT]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},i.POLL=function(e){try{return Promise.resolve(l(e.self())).then(function(r){var t,o;f(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),t=e.all(),o=r,JSON.stringify(t)!==JSON.stringify(o)&&e.broadcast(n.UPDATED,r),e.merge(r)})}catch(e){return Promise.reject(e)}},i),v=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},y=function(e){return n.spawn(h,v(e))};function p(e){function r(r){return n.subscriber(v(e),y,r)}function t(e){return function(t){void 0===t&&(t={});var n=t.suppress||!1;return new Promise(function(t,o){var i=r(function(r){r.statusCode&&!n?(o(r.errorMessage),i()):e(r)&&(t(r),i())})})}}return{snapshot:function(){return n.snapshoter(e,y)},subscribe:r,onceFinalized:t(m),onceExecuted:t(d),onceSealed:t(f)}}function P(){return(P=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function g(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function b(e){var r=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,r){if(e){if("string"==typeof e)return g(e,void 0);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(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?g(e,void 0):void 0}}(e)))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.")}return(r=e[Symbol.iterator]()).next.bind(r)}p.isUnknown=function(e){return e.status>=0},p.isPending=function(e){return e.status>=1},p.isFinalized=m,p.isExecuted=d,p.isSealed=f,p.isExpired=function(e){return 5===e.status};var E=function(){try{return Promise.resolve(c([t.getLatestBlock()])).then(a)}catch(e){return Promise.reject(e)}},S=function(e){try{var t=setTimeout;return Promise.resolve(r.config().get("fcl.eventPollRate",1e4)).then(function(r){return t(function(){return e.sendSelf("TICK")},r)})}catch(e){return Promise.reject(e)}},j=((u={}).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(E()).then(function(r){n.call(e,"hwm",r);var t=e.put;return Promise.resolve(S(e)).then(function(r){t.call(e,"tick",r)})})}return Promise.resolve(E()).then(function(n){return e.put("hwm",n),Promise.resolve(c([t.getEvents(e.self(),r.height,n.height-1)])).then(function(r){return Promise.resolve(a(r)).then(function(r){for(var t,n=b(r);!(t=n()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(S(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)}},u[n.SUBSCRIBE]=function(e,r){try{var t=function(){e.subscribe(r.from)},n=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(S(e)).then(function(t){r.call(e,"tick",t)})}}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},u[n.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},u),w=function(e){return n.spawn(j,e)};function O(e){return null==e?null:e.replace(/^0x/,"")}var I="FCL_IFRAME_CHALLENGE";function T(e,r){void 0===r&&(r=!0);var t=new URL(e.endpoint);if(r)for(var n=0,o=Object.entries(e.params||{});n<o.length;n++){var i=o[n];t.searchParams.append(i[0],i[1])}return t}var A="FCL_IFRAME_AUTHZ";function R(e){if(!document.getElementById(A)){var r=T(e),t=document.createElement("iframe");return t.src=r.href,t.id=A,t.allow="usb",t.style.position="fixed",t.style.top="0px",t.style.right="0px",t.style.left="0px",t.style.bottom="0px",t.style.height="100vh",t.style.width="100vw",t.style.display="block",t.style.background="rgba(0,0,0,0.25)",t.frameBorder="0",t.style.boxSizing="border-box",t.style.border="1px solid white",document.body.append(t),[t,function(){document.getElementById(A)&&document.getElementById(A).remove()}]}}var k,N={"HTTP/GET":"GET","HTTP/POST":"POST"},B=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},C=function(e,r){return"Missing "+B(e,r)+" in Composite Signature."},U=function(e,r){return B(e,r)+" in Composit Signature did not match the requested "+e+"."},x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",L=x.length,D={"HTTP/POST":function(e,r){try{var t=function(){},n=null;return Promise.resolve(function(e,r){try{var t=e()}catch(e){return r()}return t&&t.then?t.then(r,r):r()}(function(){return function(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(function(){return Promise.resolve(fetch(T(e),{method:"POST",headers:{"Content-Type":"application/json"},body:r?JSON.stringify(r):void 0}).then(function(e){return e.json()})).then(function(e){if(e.local&&e.local.length>0){var r=R(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(T(r),{method:N[r.method],headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(r){"APPROVED"===r.status?t(r.compositeSignature):"DECLINED"===r.status?n({status:r.status,reason:r.reason}):setTimeout(function(){t(e(r.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){n=e})})},function(e){throw t(),console.error(e),e})},function(){return t(),n}))}catch(e){return Promise.reject(e)}},"IFRAME/RPC":function(e,r){try{return Promise.resolve(new Promise(function(t,n){try{var o=function(){for(var e="",r=32;r--;)e+=x[Math.random()*L|0];return e}(),i=R(e),u=i[0],s=i[1];console.log("AUTHZ IFRAME",u),setTimeout(function(){u.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")},500),window.addEventListener("message",function e(r){var i=r.data;try{if("object"!=typeof i)return Promise.resolve();if("2.0"!==i.jsonrpc)return Promise.resolve();if(i.id!==o)return Promise.resolve();var u=i.result;return"APPROVED"===u.status?(window.removeEventListener("message",e),s(),t(u.compositeSignature)):"DECLINED"===u.status?(window.removeEventListener("message",e),s(),n({status:u.status,reason:u.reason})):(window.removeEventListener("message",e),s(),n({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"})),Promise.resolve()}catch(e){return Promise.reject(e)}})}catch(e){console.error("EXPECTING BOOM HERE",e),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function z(e,r,t){if(!e.s){if(t instanceof H){if(!t.s)return void(t.o=z.bind(null,e,r));1&r&&(r=t.s),t=t.v}if(t&&t.then)return void t.then(z.bind(null,e,r),z.bind(null,e,2));e.s=r,e.v=t;var n=e.o;n&&n(e)}}var _=function(e){try{return Z(),Promise.resolve(F()).then(function(r){function n(){return P({},e,{addr:u.addr,keyId:u.keyId,sequenceNum:i,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(function(e,r){try{return Promise.resolve(D[e.method](e,r)).then(function(r){return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),console.log("Normalized Composite Signature From Wallet Provider",r),function(e,r){try{if(null==e.addr)throw new Error(C("addr","Address"));if(null==e.keyId)throw new Error(C("keyId"));if(null==e.signature)throw new Error(C("signature"));if(e.addr!==r.addr)throw new Error(U("addr","Address"));if(e.keyId!==r.keyId)throw new Error(U("keyId"))}catch(t){throw console.error(t,"\n\n",{"Composite Signature":e,"Authz Service":r}),new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+t.message)}}(r,e),r})}catch(e){return Promise.reject(e)}}(u,e))}catch(e){return Promise.reject(e)}},resolve:null,roles:e.roles})}var o,i,u=(void 0===(o=r.services)&&(o=[]),o.find(function(e){return"authz"===e.type})),s=function(){if(e.role.proposer)return Promise.resolve(function(){try{return Z(),Promise.resolve(ee()).then(function(e){var r=e.addr;if(null==r)throw new Error("No Flow Address for Current User");return Promise.resolve(c([t.getAccount(r)])).then(function(e){return e.account})})}catch(e){return Promise.reject(e)}}()).then(function(e){var r=e.keys.find(function(e){return e.index===u.keyId});i=r.sequenceNumber})}();return s&&s.then?s.then(n):n()})}catch(e){return Promise.reject(e)}},H=function(){function e(){}return e.prototype.then=function(r,t){var n=new e,o=this.s;if(o){var i=1&o?r:t;if(i){try{z(n,1,i(this.v))}catch(e){z(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?z(n,1,r?r(o):o):t?z(n,1,t(o)):z(n,2,o)}catch(e){z(n,2,e)}},n},e}();function M(e){return e instanceof H&&1&e.s}var F=function(){try{return Promise.resolve(new Promise(function(e){try{return Z(),Promise.resolve(ee()).then(function(t){return t.loggedIn?e(t):Promise.resolve(r.config().get("challenge.handshake")).then(function(r){var t=function(e){var r=e.handshake,t=e.l6n;if(!document.getElementById(I)){var n=new URL(r);n.searchParams.append("l6n",t);var o=document.createElement("iframe");return o.src=n.href,o.id=I,o.allow="usb",o.style.position="fixed",o.style.top="0px",o.style.right="0px",o.style.left="0px",o.style.bottom="0px",o.style.height="100vh",o.style.width="100vw",o.style.display="block",o.style.background="rgba(0,0,0,0.25)",o.frameBorder="0",o.style.boxSizing="border-box",o.style.border="1px solid white",document.body.append(o),function(){document.getElementById(I)&&document.getElementById(I).remove()}}}({handshake:r,l6n:window.location.origin});window.addEventListener("message",function r(o){var i=o.data;try{if(console.log("MESSAGE",i),i.type!==q)return Promise.resolve();t(),window.removeEventListener("message",r);var u="did:fcl:"+i.addr,s=i.addr,c=i.services||[];return Promise.resolve(function(e,r){try{if(null==e||null==r)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",r),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 r=[];if(Array.isArray(e.authorizations))for(var t,n=b(e.authorizations);!(t=n()).done;)r.push(P({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&r.push(P({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(i.hks,i.code)).then(function(r){var t,o,i={addr:s,cid:u,loggedIn:!0,services:(t=c,o=r,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o))};return n.send(J,V,i),Promise.resolve(ee()).then(function(r){e(r)})})}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},J="CURRENT_USER",G="CURRENT_USER/UPDATED",V="SET_CURRENT_USER",q="FCL::CHALLENGE::RESPONSE",W='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',X=function(e){try{return localStorage.setItem(J,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},K=((k={})[n.INIT]=function(e){try{var r=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(W),r=JSON.parse(localStorage.getItem(J));return null!=r&&e.VERSION!==r.VERSION?(localStorage.removeItem(J),Promise.resolve(e)):Promise.resolve(r||e)}catch(e){return Promise.reject(e)}}()).then(function(t){r.call(e,t)})}catch(e){return Promise.reject(e)}},k[n.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,G,e.all())},k[n.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},k.SNAPSHOT=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},k[V]=function(e,r,t){try{return e.merge(t),X(e.all()),e.broadcast(G,e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},k.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(W)),X(e.all()),e.broadcast(G,e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},k.GET_AS_PARAM=function(e,r,t){var n=t.key;try{return r.reply({key:n,value:e.get("addr",null),xform:o.Identity}),Promise.resolve()}catch(e){return Promise.reject(e)}},k),Z=function(){return n.spawn(K,J)};function $(){Z(),n.send(J,"DEL_CURRENT_USER")}function Q(e){return function(){try{return Z(),Promise.resolve(F()).then(function(){return n.send(J,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})})}catch(e){return Promise.reject(e)}}}function Y(e){Z();var r=n.spawn(function(r){try{var t;return r.send(J,n.SUBSCRIBE),Promise.resolve(function(e,r,t){for(var n;;){var o=e();if(M(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=t();if(i&&i.then){if(!M(i)){n=1;break}i=i.s}}var u=new H,s=z.bind(null,u,2);return(0===n?o.then(a):1===n?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,s):a(o):z(u,1,i)})).then(void 0,s),u;function c(r){i=r;do{if(!(o=e())||M(o)&&!o.v)return void z(u,1,i);if(o.then)return void o.then(a).then(void 0,s);M(i=t())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,s)}function a(e){e?(i=t())&&i.then?i.then(c).then(void 0,s):c(i):z(u,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(o){if("@EXIT"===o.tag)return r.send(J,n.UNSUBSCRIBE),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return n.send(r,"@EXIT")}}function ee(){return Z(),n.send(J,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var re=function(){return{authenticate:F,unauthenticate:$,authorization:_,param:Q,subscribe:Y,snapshot:ee}};Object.defineProperty(e,"config",{enumerable:!0,get:function(){return r.config}}),Object.defineProperty(e,"arg",{enumerable:!0,get:function(){return t.arg}}),Object.defineProperty(e,"args",{enumerable:!0,get:function(){return t.args}}),Object.defineProperty(e,"authorization",{enumerable:!0,get:function(){return t.authorization}}),Object.defineProperty(e,"authorizations",{enumerable:!0,get:function(){return t.authorizations}}),Object.defineProperty(e,"build",{enumerable:!0,get:function(){return t.build}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return t.cadence}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return t.cdc}}),Object.defineProperty(e,"getAccount",{enumerable:!0,get:function(){return t.getAccount}}),Object.defineProperty(e,"getBlockByHeight",{enumerable:!0,get:function(){return t.getBlockByHeight}}),Object.defineProperty(e,"getBlockById",{enumerable:!0,get:function(){return t.getBlockById}}),Object.defineProperty(e,"getEvents",{enumerable:!0,get:function(){return t.getEvents}}),Object.defineProperty(e,"getLatestBlock",{enumerable:!0,get:function(){return t.getLatestBlock}}),Object.defineProperty(e,"getTransactionStatus",{enumerable:!0,get:function(){return t.getTransactionStatus}}),Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return t.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return t.isOk}}),Object.defineProperty(e,"limit",{enumerable:!0,get:function(){return t.limit}}),Object.defineProperty(e,"param",{enumerable:!0,get:function(){return t.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return t.params}}),Object.defineProperty(e,"payer",{enumerable:!0,get:function(){return t.payer}}),Object.defineProperty(e,"ping",{enumerable:!0,get:function(){return t.ping}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return t.pipe}}),Object.defineProperty(e,"proposer",{enumerable:!0,get:function(){return t.proposer}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return t.ref}}),Object.defineProperty(e,"script",{enumerable:!0,get:function(){return t.script}}),Object.defineProperty(e,"transaction",{enumerable:!0,get:function(){return t.transaction}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return t.why}}),e.VERSION="0.0.55-debug.15",e.authenticate=function(){return re().authenticate()},e.currentUser=re,e.decode=a,e.events=function(e){return{subscribe:function(r){return n.subscriber(e,w,r)}}},e.resolve=s,e.sansPrefix=O,e.send=c,e.serialize=function(e){void 0===e&&(e=[]);try{var r=function(){return Promise.resolve(s(e)).then(JSON.stringify)},n=function(){if(Array.isArray(e))return Promise.resolve(t.build(e)).then(function(r){e=r})}();return Promise.resolve(n&&n.then?n.then(r):r())}catch(e){return Promise.reject(e)}},e.tx=p,e.unauthenticate=function(){return re().unauthenticate()},e.withPrefix=function(e){return null==e?null:"0x"+O(e)}});
//# sourceMappingURL=fcl.umd.js.map
{
"name": "@onflow/fcl",
"version": "0.0.55-debug.14",
"version": "0.0.55-debug.15",
"description": "Flow Client Library",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc