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

@onflow/fcl

Package Overview
Dependencies
Maintainers
8
Versions
313
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.67-alpha.1 to 0.0.67-alpha.2

4

CHANGELOG.md

@@ -5,2 +5,6 @@ ### Unreleased

### 0.0.67-alpha.2 - 2020-11-17
- 2020-11-17 -- Injected in a custom resolver in prep for pre-authz service
### 0.0.67-alpha.1 - 2020-11-17

@@ -7,0 +11,0 @@

2

dist/fcl.js

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

var e=require("@onflow/config"),r=require("@onflow/interaction"),t=require("@onflow/sdk-resolve"),n=require("@onflow/util-actor"),o=require("@onflow/sdk-send"),i=require("@onflow/sdk-decode"),u=require("@onflow/sdk-build-transaction-status"),s=require("@onflow/sdk-latest-block"),a=require("@onflow/sdk-build-get-events"),c=require("@onflow/sdk-account"),l=require("@onflow/util-address"),f=require("@onflow/util-uid"),d=require("@onflow/util-template"),h=require("@onflow/sdk-build-transaction"),m=require("@onflow/sdk-build-script"),p=require("@onflow/sdk-build-ping"),v=require("@onflow/sdk-build-get-account"),g=require("@onflow/sdk-build-get-latest-block"),P=require("@onflow/sdk-build-get-block-by-id"),b=require("@onflow/sdk-build-get-block-by-height"),y=require("@onflow/sdk-build-authorizations"),w=require("@onflow/sdk-build-arguments"),E=require("@onflow/sdk-build-proposer"),S=require("@onflow/sdk-build-payer"),j=require("@onflow/sdk-build-limit"),O=require("@onflow/sdk-build-ref"),x=require("@onflow/sdk-build-params");e.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var k,I,T=function(e){try{return Promise.resolve(o.send([u.getTransactionStatus(e)]).then(i.decode))}catch(e){return Promise.reject(e)}},R=function(e){return e.status>=4},C=function(e){return e.status>=3},N=function(e){return e.status>=2},L=((k={})[n.INIT]=function(e){try{return Promise.resolve(T(e.self())).then(function(r){R(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},k[n.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,n.UPDATED,e.all())},k[n.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},k[n.SNAPSHOT]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},k.POLL=function(e){try{return Promise.resolve(T(e.self())).then(function(r){var t,o;R(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)}},k),A=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},U=function(e){return n.spawn(L,A(e))};function B(e){function r(r){return n.subscriber(A(e),U,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,U)},subscribe:r,onceFinalized:t(N),onceExecuted:t(C),onceSealed:t(R)}}function q(){return(q=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 D(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 z(e,r){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return D(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(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?D(e,void 0):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}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(t=e[Symbol.iterator]()).next.bind(t)}B.isUnknown=function(e){return e.status>=0},B.isPending=function(e){return e.status>=1},B.isFinalized=N,B.isExecuted=C,B.isSealed=R,B.isExpired=function(e){return 5===e.status};var F=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)}},_=((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(s.latestBlock()).then(function(r){t.call(e,"hwm",r);var n=e.put;return Promise.resolve(F(e)).then(function(r){n.call(e,"tick",r)})})}return Promise.resolve(s.latestBlock()).then(function(t){return e.put("hwm",t),Promise.resolve(o.send([getEvents(e.self(),r.height,t.height-1)]).then(i.decode)).then(function(r){for(var t,n=z(r);!(t=n()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(F(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[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(F(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[n.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},I),H=function(e){return n.spawn(_,e)};function J(e){if(!document.getElementById("FCL_IFRAME")){var r=document.createElement("iframe");return r.src=e,r.id="FCL_IFRAME",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.style.zIndex=2147483647,r.frameBorder="0",r.style.boxSizing="border-box",document.body.append(r),[r,function(){document.getElementById("FCL_IFRAME")&&document.getElementById("FCL_IFRAME").remove()}]}}function M(e){return"cid:"+(e.addr||e.name)+":"+e.pid}function V(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}function G(e){return J(V(e).href)}var W,K={"HTTP/GET":"GET","HTTP/POST":"POST"},X=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},Y=function(e,r){return"Missing "+X(e,r)+" in Composite Signature."},Z=function(e,r){return X(e,r)+" in Composit Signature did not match the requested "+e+"."},$={"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(V(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=G(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(V(r),{method:K[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(n){throw t(),Q(e,r,n),n})},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=f.uid(),i=G(e),u=i[0],s=i[1],a=function(){u.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")};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)}}),new Promise(function(e){window.addEventListener("message",t);var r=setTimeout(function(){window.removeEventListener("message",t),a(),e()},5e3);function t(n){"FCL::AUTHZ_READY"===n.data.type&&(clearTimeout(r),window.removeEventListener("message",t),a(),e())}})}catch(t){Q(e,r,t),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function Q(e,r,t){console.error("["+e.method+"] Trouble talking to Wallet Provider","\n\n",{authz:e,signable:r},t)}function ee(e,r,t){if(!e.s){if(t instanceof te){if(!t.s)return void(t.o=ee.bind(null,e,r));1&r&&(r=t.s),t=t.v}if(t&&t.then)return void t.then(ee.bind(null,e,r),ee.bind(null,e,2));e.s=r,e.v=t;var n=e.o;n&&n(e)}}var re=function(e){try{return me(),Promise.resolve(oe()).then(function(r){function t(){return q({},e,{addr:l.sansPrefix(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($[e.method](e,r)).then(function(r){return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),r.addr=l.sansPrefix(r.addr),function(e,r){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(l.sansPrefix(e.addr)!==l.sansPrefix(r.addr))throw new Error(Z("addr","Address"));if(e.keyId!==r.keyId)throw new Error(Z("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 me(),Promise.resolve(ge()).then(function(e){var r=e.addr;if(null==r)throw new Error("No Flow Address for Current User");return c.account(r)})}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)}},te=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{ee(n,1,i(this.v))}catch(e){ee(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?ee(n,1,r?r(o):o):t?ee(n,1,t(o)):ee(n,2,o)}catch(e){ee(n,2,e)}},n},e}();function ne(e){return e instanceof te&&1&e.s}var oe=function(){try{return Promise.resolve(new Promise(function(r){try{return me(),Promise.resolve(ge()).then(function(t){return t.loggedIn?r(t):Promise.resolve(e.config().get("challenge.handshake")).then(function(e){var t,o,i,u=(o=(t={handshake:e,l6n:window.location.origin}).l6n,(i=new URL(t.handshake)).searchParams.append("l6n",o),J(i.href))[1];window.addEventListener("message",function e(t){var o=t.data;try{return o.type===ce?(u(),window.removeEventListener("message",e),Promise.resolve()):o.type!==ae?Promise.resolve():(u(),window.removeEventListener("message",e),Promise.resolve(function(e){try{var r=e.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=z(e.authorizations);!(t=n()).done;)r.push(q({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&r.push(q({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(t){var n,o,i=(void 0===(n=r)&&(n=[]),void 0===(o=t)&&(o=[]),[].concat(n,o)),u=i.find(function(e){return"authn"===e.type});return console.log("RAWR",{data:e,services:i,authn:u}),{addr:e.addr?l.withPrefix(e.addr):null,cid:M(u),loggedIn:!0,services:i}})}catch(e){return Promise.reject(e)}}(o)).then(function(e){return n.send(ie,se,e),Promise.resolve(ge()).then(function(e){r(e)})}))}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},ie="CURRENT_USER",ue="CURRENT_USER/UPDATED",se="SET_CURRENT_USER",ae="FCL::CHALLENGE::RESPONSE",ce="FCL::CHALLENGE::CANCEL",le='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',fe=function(e){try{return sessionStorage.setItem(ie,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},de=function(){return e.config().get("persistSession",!0)},he=((W={})[n.INIT]=function(e){try{return e.merge(JSON.parse(le)),Promise.resolve(de()).then(function(r){var t=function(){if(r){var t=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(le),r=JSON.parse(sessionStorage.getItem(ie));return null!=r&&e.VERSION!==r.VERSION?(sessionStorage.removeItem(ie),Promise.resolve(e)):Promise.resolve(r||e)}catch(e){return Promise.reject(e)}}()).then(function(r){t.call(e,r)})}}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}},W[n.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,ue,q({},e.all()))},W[n.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},W.SNAPSHOT=function(e,r){try{return r.reply(q({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},W[se]=function(e,r,t){try{return e.merge(t),Promise.resolve(de()).then(function(r){r&&fe(e.all()),e.broadcast(ue,q({},e.all()))})}catch(e){return Promise.reject(e)}},W.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(le)),Promise.resolve(de()).then(function(r){r&&fe(e.all()),e.broadcast(ue,q({},e.all()))})}catch(e){return Promise.reject(e)}},W),me=function(){return n.spawn(he,ie)};function pe(){me(),n.send(ie,"DEL_CURRENT_USER")}function ve(e){me();var r=n.spawn(function(r){try{var t;return r.send(ie,n.SUBSCRIBE),Promise.resolve(function(e,r,t){for(var n;;){var o=e();if(ne(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=t();if(i&&i.then){if(!ne(i)){n=1;break}i=i.s}}var u=new te,s=ee.bind(null,u,2);return(0===n?o.then(c):1===n?i.then(a):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):ee(u,1,i)})).then(void 0,s),u;function a(r){i=r;do{if(!(o=e())||ne(o)&&!o.v)return void ee(u,1,i);if(o.then)return void o.then(c).then(void 0,s);ne(i=t())&&(i=i.v)}while(!i||!i.then);i.then(a).then(void 0,s)}function c(e){e?(i=t())&&i.then?i.then(a).then(void 0,s):a(i):ee(u,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(o){if("@EXIT"===o.tag)return r.send(ie,n.UNSUBSCRIBE),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return n.send(r,"@EXIT")}}function ge(){return me(),n.send(ie,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Pe=function(){return{authenticate:oe,unauthenticate:pe,authorization:re,subscribe:ve,snapshot:ge}},be=Pe().authorization;Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return e.config}}),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,"pipe",{enumerable:!0,get:function(){return r.pipe}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return r.why}}),Object.defineProperty(exports,"send",{enumerable:!0,get:function(){return o.send}}),Object.defineProperty(exports,"decode",{enumerable:!0,get:function(){return i.decode}}),Object.defineProperty(exports,"getTransactionStatus",{enumerable:!0,get:function(){return u.getTransactionStatus}}),Object.defineProperty(exports,"latestBlock",{enumerable:!0,get:function(){return s.latestBlock}}),Object.defineProperty(exports,"getEvents",{enumerable:!0,get:function(){return a.getEvents}}),Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return c.account}}),Object.defineProperty(exports,"display",{enumerable:!0,get:function(){return l.display}}),Object.defineProperty(exports,"sansPrefix",{enumerable:!0,get:function(){return l.sansPrefix}}),Object.defineProperty(exports,"withPrefix",{enumerable:!0,get:function(){return l.withPrefix}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return d.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return d.template}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return h.transaction}}),Object.defineProperty(exports,"script",{enumerable:!0,get:function(){return m.script}}),Object.defineProperty(exports,"ping",{enumerable:!0,get:function(){return p.ping}}),Object.defineProperty(exports,"getAccount",{enumerable:!0,get:function(){return v.getAccount}}),Object.defineProperty(exports,"getLatestBlock",{enumerable:!0,get:function(){return g.getLatestBlock}}),Object.defineProperty(exports,"getBlockById",{enumerable:!0,get:function(){return P.getBlockById}}),Object.defineProperty(exports,"getBlockByHeight",{enumerable:!0,get:function(){return b.getBlockByHeight}}),Object.defineProperty(exports,"authorization",{enumerable:!0,get:function(){return y.authorization}}),Object.defineProperty(exports,"authorizations",{enumerable:!0,get:function(){return y.authorizations}}),Object.defineProperty(exports,"arg",{enumerable:!0,get:function(){return w.arg}}),Object.defineProperty(exports,"args",{enumerable:!0,get:function(){return w.args}}),Object.defineProperty(exports,"proposer",{enumerable:!0,get:function(){return E.proposer}}),Object.defineProperty(exports,"payer",{enumerable:!0,get:function(){return S.payer}}),Object.defineProperty(exports,"limit",{enumerable:!0,get:function(){return j.limit}}),Object.defineProperty(exports,"ref",{enumerable:!0,get:function(){return O.ref}}),Object.defineProperty(exports,"param",{enumerable:!0,get:function(){return x.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return x.params}}),exports.VERSION="0.0.67-alpha.1",exports.authenticate=function(){return Pe().authenticate()},exports.authz=be,exports.currentUser=Pe,exports.events=function(e){return{subscribe:function(r){return n.subscriber(e,H,r)}}},exports.logIn=function(){return Pe().authenticate()},exports.reauthenticate=function(){Pe().unauthenticate(),Pe().authenticate()},exports.serialize=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{var o=function(){return Promise.resolve(t.resolve(n)(e)).then(JSON.stringify)},i=function(){if(Array.isArray(e))return Promise.resolve(r.pipe(r.interaction(),e)).then(function(r){e=r})}();return Promise.resolve(i&&i.then?i.then(o):o())}catch(e){return Promise.reject(e)}},exports.signUp=function(){return Pe().authenticate()},exports.tx=B,exports.unauthenticate=function(){return Pe().unauthenticate()};
var e=require("@onflow/config"),r=require("@onflow/util-invariant"),n=require("@onflow/interaction"),t=require("@onflow/sdk-latest-block"),o=require("@onflow/util-address"),i=require("@onflow/sdk-account"),u=require("@onflow/rlp"),s=require("@onflow/sdk-resolve"),a=require("@onflow/util-actor"),c=require("@onflow/sdk-send"),f=require("@onflow/sdk-decode"),l=require("@onflow/sdk-build-transaction-status"),d=require("@onflow/sdk-build-get-events"),p=require("@onflow/util-uid"),h=require("@onflow/util-template"),m=require("@onflow/sdk-build-transaction"),v=require("@onflow/sdk-build-script"),y=require("@onflow/sdk-build-ping"),g=require("@onflow/sdk-build-get-account"),P=require("@onflow/sdk-build-get-latest-block"),b=require("@onflow/sdk-build-get-block-by-id"),w=require("@onflow/sdk-build-get-block-by-height"),S=require("@onflow/sdk-build-authorizations"),k=require("@onflow/sdk-build-arguments"),E=require("@onflow/sdk-build-proposer"),x=require("@onflow/sdk-build-payer"),I=require("@onflow/sdk-build-limit"),j=require("@onflow/sdk-build-ref"),O=require("@onflow/sdk-build-params");function T(){return(T=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}function A(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function N(e,r){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return A(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?A(e,void 0):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}e.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var R=function(e,r){return Buffer.from(e.padStart(2*r,0),"hex")},L=function(e){return R(e,8)},B=function(e){return Buffer.from(JSON.stringify(e),"utf8")},C=function(e){return u.encode(e).toString("hex")},U=function(e){return D(e),[(n=e.script,Buffer.from(n,"utf8")),e.arguments.map(B),(r=e.refBlock,R(r,32)),e.gasLimit,L(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,L(e.payer),e.authorizers.map(L)];var r,n},q=function(e){var r=z(e);return e.payloadSigs.map(function(e){return{signerIndex:r.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,r){return e.signerIndex>r.signerIndex?1:e.signerIndex<r.signerIndex?-1:e.keyId>r.keyId?1:e.keyId<r.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(r=e.sig,Buffer.from(r,"hex"))];var r})},z=function(e){var r=new Map,n=0,t=function(e){r.has(e)||(r.set(e,n),n++)};return t(e.proposalKey.address),t(e.payer),e.authorizers.forEach(t),r},D=function(e){M.forEach(function(r){return W(e,r)}),K.forEach(function(r){return W(e.proposalKey,r,"proposalKey")})},F=function(e){return"number"==typeof e},_=function(e){return"string"==typeof e},J=function(e){return null!==e&&"object"==typeof e},H=function(e){return J(e)&&e instanceof Array},M=[{name:"script",check:_},{name:"arguments",check:H},{name:"refBlock",check:_,defaultVal:"0"},{name:"gasLimit",check:F},{name:"proposalKey",check:J},{name:"payer",check:_},{name:"authorizers",check:H}],K=[{name:"address",check:_},{name:"keyId",check:F},{name:"sequenceNum",check:F}],V=[{name:"payloadSigs",check:H}],G=[{name:"address",check:_},{name:"keyId",check:F},{name:"sig",check:_}],W=function(e,r,n,t){var o=r.name,i=r.check,u=r.defaultVal;if(null==e[o]&&null!=u&&(e[o]=u),null==e[o])throw Y(o,n,t);if(!i(e[o]))throw Z(o,n,t)},X=function(e,r,n){return r?null==n?r+"."+e:r+"."+n+"."+e:e},Y=function(e,r,n){return new Error("Missing field "+X(e,r,n))},Z=function(e,r,n){return new Error("Invalid field "+X(e,r,n))},$="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Q(e,r,n){if(!e.s){if(n instanceof ee){if(!n.s)return void(n.o=Q.bind(null,e,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(Q.bind(null,e,r),Q.bind(null,e,2));e.s=r,e.v=n;var t=e.o;t&&t(e)}}var ee=function(){function e(){}return e.prototype.then=function(r,n){var t=new e,o=this.s;if(o){var i=1&o?r:n;if(i){try{Q(t,1,i(this.v))}catch(e){Q(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Q(t,1,r?r(o):o):n?Q(t,1,n(o)):Q(t,2,o)}catch(e){Q(t,2,e)}},t},e}();function re(e){return e instanceof ee&&1&e.s}var ne=function(e){return"string"==typeof e},te=function(e){return"function"==typeof e};function oe(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(r){return e.arguments[r].asArgument}),proposalKey:{address:o.sansPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:o.sansPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(r){return o.sansPrefix(e.accounts[r].addr)}).reduce(function(e,r){return e.find(function(e){return e===r})?e:[].concat(e,[r])},[])}}e.config().put("sdk.resolve",function(e){try{return Promise.resolve(e).then(function(u){function s(){function u(){function u(){function t(){var r=function(){if(n.isTransaction(e)){console.log("RESOLVE SIGNATURES START",e);var r=new Set(e.authorizations);r.add(e.proposer),r.delete(e.payer),r=Array.from(r);var t=new Set([e.payer]);t=Array.from(t),console.log("SIGNATORIES",{insideSigners:r,outsideSigners:t});var i=(u=oe(e),C(U(u)));return Promise.resolve(Promise.all(r.map(function(r){try{var n=e.accounts[r];return null!=n.signature?Promise.resolve():Promise.resolve(n.signingFunction({message:i,addr:o.sansPrefix(n.addr),keyId:n.keyId,roles:n.role,interaction:e})).then(function(n){e.accounts[r].signature=n.signature})}catch(e){return Promise.reject(e)}}))).then(function(){var n=function(e){return C(function(e){return function(e){V.forEach(function(r){return W(e,r)}),e.payloadSigs.forEach(function(e,r){G.forEach(function(n){return W(e,n,"payloadSigs",r)})})}(e),[U(e),q(e)]}(e))}(T({},oe(e),{payloadSigs:r.map(function(r){return e.accounts[r].signature})}));return Promise.resolve(Promise.all(t.map(function(r){try{var t=e.accounts[r];return null!=t.signature?Promise.resolve():Promise.resolve(t.signingFunction({message:n,addr:o.sansPrefix(t.addr),keyId:t.keyId,roles:t.role,interaction:e})).then(function(n){e.accounts[r].signature=n.signature})}catch(e){return Promise.reject(e)}}))).then(function(){console.log("RESOLVE SIGNATURES END",e)})})}var u}();return r&&r.then?r.then(function(){return e}):e}var u=function(){if(n.isTransaction(e)){var t=Object.values(e.accounts).find(function(e){return e.role.proposer});r.invariant(t,"Transactions require a proposer");var o=function(){if(null===t.sequenceNum)return Promise.resolve(i.account(t.addr).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===t.keyId})}).then(function(e){return e.sequenceNumber})).then(function(r){e.accounts[t.tempId].sequenceNum=r})}();if(o&&o.then)return o.then(function(){})}}();return u&&u.then?u.then(t):t()}n.isTransaction(e);var s=function(){if(n.isTransaction(e)&&null==e.message.refBlock)return Promise.resolve(t.latestBlock()).then(function(r){e.message.refBlock=r.id})}();return s&&s.then?s.then(u):u()}if(n.isTransaction(e)||n.isScript(e))for(var s=0,a=Object.entries(e.arguments);s<a.length;s++){var c=a[s];e.arguments[c[0]].asArgument=(r.invariant(null!=typeof(f=c[1]).xform,"No type specified for argument: "+f.value),te(f.xform)?f.xform(f.value):te(f.xform.asArgument)?f.xform.asArgument(f.value):void r.invariant(!1,"Invalid Argument",f))}var f,l=function(){if(n.isTransaction(e)){var r=function(){e.accounts=t},t={},o=function(e,r,n){if("function"==typeof e[$]){var t,o,i,u=e[$]();if(function e(n){try{for(;!(t=u.next()).done;)if((n=r(t.value))&&n.then){if(!re(n))return void n.then(e,i||(i=Q.bind(null,o=new ee,2)));n=n.v}o?Q(o,1,n):o=n}catch(e){Q(o||(o=new ee),2,e)}}(),u.return){var s=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(s,function(e){throw s(e)});s()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],c=0;c<e.length;c++)a.push(e[c]);return function(e,r,n){var t,o,i=-1;return function n(u){try{for(;++i<e.length;)if((u=r(i))&&u.then){if(!re(u))return void u.then(n,o||(o=Q.bind(null,t=new ee,2)));u=u.v}t?Q(t,1,u):t=u}catch(e){Q(t||(t=new ee),2,e)}}(),t}(a,function(e){return r(a[e])})}(Object.entries(e.accounts),function(r){var n=r[0],o=r[1];function i(){t[n]=t[n]||o,t[n].role.proposer=t[n].role.proposer||o.role.proposer,t[n].role.payer=t[n].role.payer||o.role.payer,t[n].role.authorizer=t[n].role.authorizer||o.role.authorizer,e.proposer===u&&(e.proposer=n),e.payer===u&&(e.payer=n),e.authorizations=e.authorizations.map(function(e){return e===u?n:e})}var u=n,s=function(){if(te(o.resolve))return Promise.resolve(o.resolve(o)).then(function(e){n=(o=e).tempId})}();return s&&s.then?s.then(i):i()});return o&&o.then?o.then(r):r()}}();return l&&l.then?l.then(u):u()}e=u;var a=function(){if(n.isTransaction(e)||n.isScript(e)){var t=function(){r.invariant(ne(o),"Cadence needs to be a string at this point."),e.message.cadence=o},o=n.get(e,"ix.cadence");r.invariant(te(o)||ne(o),"Cadence needs to be a function or a string.");var i=function(){if(te(o))return Promise.resolve(o({})).then(function(e){o=e})}();return i&&i.then?i.then(t):t()}}();return a&&a.then?a.then(s):s()})}catch(e){return Promise.reject(e)}});var ie,ue,se=function(e){try{return Promise.resolve(c.send([l.getTransactionStatus(e)]).then(f.decode))}catch(e){return Promise.reject(e)}},ae=function(e){return e.status>=4},ce=function(e){return e.status>=3},fe=function(e){return e.status>=2},le=((ie={})[a.INIT]=function(e){try{return Promise.resolve(se(e.self())).then(function(r){ae(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},ie[a.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,a.UPDATED,e.all())},ie[a.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},ie[a.SNAPSHOT]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},ie.POLL=function(e){try{return Promise.resolve(se(e.self())).then(function(r){var n,t;ae(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),n=e.all(),t=r,JSON.stringify(n)!==JSON.stringify(t)&&e.broadcast(a.UPDATED,r),e.merge(r)})}catch(e){return Promise.reject(e)}},ie),de=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},pe=function(e){return a.spawn(le,de(e))};function he(e){function r(r){return a.subscriber(de(e),pe,r)}function n(e){return function(n){void 0===n&&(n={});var t=n.suppress||!1;return new Promise(function(n,o){var i=r(function(r){r.statusCode&&!t?(o(r.errorMessage),i()):e(r)&&(n(r),i())})})}}return{snapshot:function(){return a.snapshoter(e,pe)},subscribe:r,onceFinalized:n(fe),onceExecuted:n(ce),onceSealed:n(ae)}}he.isUnknown=function(e){return e.status>=0},he.isPending=function(e){return e.status>=1},he.isFinalized=fe,he.isExecuted=ce,he.isSealed=ae,he.isExpired=function(e){return 5===e.status};var me=function(r){try{var n=setTimeout;return Promise.resolve(e.config().get("fcl.eventPollRate",1e4)).then(function(e){return n(function(){return r.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},ve=((ue={}).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(t.latestBlock()).then(function(r){n.call(e,"hwm",r);var t=e.put;return Promise.resolve(me(e)).then(function(r){t.call(e,"tick",r)})})}return Promise.resolve(t.latestBlock()).then(function(n){return e.put("hwm",n),Promise.resolve(c.send([getEvents(e.self(),r.height,n.height-1)]).then(f.decode)).then(function(r){for(var n,t=N(r);!(n=t()).done;)e.broadcast("UPDATED",n.value.data);var o=e.put;return Promise.resolve(me(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)}},ue[a.SUBSCRIBE]=function(e,r){try{var n=function(){e.subscribe(r.from)},t=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(me(e)).then(function(n){r.call(e,"tick",n)})}}();return Promise.resolve(t&&t.then?t.then(n):n())}catch(e){return Promise.reject(e)}},ue[a.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},ue),ye=function(e){return a.spawn(ve,e)};function ge(e){if(!document.getElementById("FCL_IFRAME")){var r=document.createElement("iframe");return r.src=e,r.id="FCL_IFRAME",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.style.zIndex=2147483647,r.frameBorder="0",r.style.boxSizing="border-box",document.body.append(r),[r,function(){document.getElementById("FCL_IFRAME")&&document.getElementById("FCL_IFRAME").remove()}]}}var Pe={"@type":"Service","@vsn":"1.0.0"},be={"@type":"Identity","@vsn":"1.0.0"},we={"@type":"USER","@vsn":"1.0.0"},Se={authn:function(e){switch(e["@vsn"]){case"1.0.0":return e;default:return T({},Pe,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:o.withPrefix(e.addr),name:e.name,icon:e.icon}})}},authz:function(e){switch(e["@vsn"]){case"1.0.0":return e;default:return T({},Pe,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:T({},be,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})}},"pre-authz":function(e){switch(e["@vsn"]){case"1.0.0":return e;default:return T({},Pe,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:T({},be,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})}}};function ke(e){return u.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}function Ee(e,r){return void 0===e&&(e=[]),e.find(function(e){return e.type===r})}function xe(e,r){void 0===r&&(r=!0);var n=new URL(e.endpoint);if(r)for(var t=0,o=Object.entries(e.params||{});t<o.length;t++){var i=o[t];n.searchParams.append(i[0],i[1])}return n}function Ie(e){return ge(xe(e).href)}var je,Oe={"HTTP/GET":"GET","HTTP/POST":"POST"},Te=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},Ae=function(e,r){return"Missing "+Te(e,r)+" in Composite Signature."},Ne=function(e,r){return Te(e,r)+" in Composit Signature did not match the requested "+e+"."},Re={"HTTP/POST":function(e,r){try{var n=function(){},t=null;return Promise.resolve(function(e,r){try{var n=e()}catch(e){return r()}return n&&n.then?n.then(r,r):r()}(function(){return function(e,r){try{var n=e()}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(function(){return Promise.resolve(fetch(xe(e,!0),{method:"POST",headers:{"Content-Type":"application/json"},body:r?JSON.stringify(r):void 0}).then(function(e){return e.json()})).then(function(e){if(console.log("RESP",e),e.local&&e.local.length>0){var r=Ie(e.local[0]);n=r[1]}return Promise.resolve(function e(r){return new Promise(function(n,t){try{return Promise.resolve(fetch(xe(r),{method:Oe[r.method],headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(r){"APPROVED"===r.status?n(r.compositeSignature):"DECLINED"===r.status?t({status:r.status,reason:r.reason}):setTimeout(function(){n(e(r.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){t=e})})},function(t){throw n(),Le(e,r,t),t})},function(){return n(),t}))}catch(e){return Promise.reject(e)}},"IFRAME/RPC":function(e,r){try{return Promise.resolve(new Promise(function(n,t){try{var o=p.uid(),i=Ie(e),u=i[0],s=i[1],a=function(){u.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")};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(),n(u.compositeSignature)):"DECLINED"===u.status?(window.removeEventListener("message",e),s(),t({status:u.status,reason:u.reason})):(window.removeEventListener("message",e),s(),t({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"})),Promise.resolve()}catch(e){return Promise.reject(e)}}),new Promise(function(e){window.addEventListener("message",n);var r=setTimeout(function(){window.removeEventListener("message",n),a(),e()},5e3);function n(t){"FCL::AUTHZ_READY"===t.data.type&&(clearTimeout(r),window.removeEventListener("message",n),a(),e())}})}catch(n){Le(e,r,n),t({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function Le(e,r,n){console.error("["+e.method+"] Trouble talking to Wallet Provider","\n\n",{authz:e,signable:r},n)}function Be(e,r,n){if(!e.s){if(n instanceof Ue){if(!n.s)return void(n.o=Be.bind(null,e,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(Be.bind(null,e,r),Be.bind(null,e,2));e.s=r,e.v=n;var t=e.o;t&&t(e)}}var Ce=function(e){try{return Xe(),Promise.resolve(ze()).then(function(n){Ee(n.services,"authn");var t=Ee(n.services,"authz");return Ee(n.services,"pre-authz"),T({},e,{tempId:"CURRENT_USER",resolve:null,addr:o.sansPrefix(t.identity.address),keyId:t.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(function(e,n){try{return Promise.resolve(Re[e.method](e,n)).then(function(n){return null==n.sig&&(n.sig=n.signature),null==n.signature&&(n.signature=n.sig),n.addr=o.sansPrefix(n.addr),function(e,n){try{var t={compSig:e,authz:n};r.invariant(e.addr,Ae("addr","Address"),t),r.invariant(e.keyId,Ae("keyId"),t),r.invariant(e.signature,Ae("signature"),t),r.invariant(e.keyId===n.identity.keyId,Ne("keyId"),t),r.invariant(o.sansPrefix(e.addr)===o.sansPrefix(n.identity.address),Ne("addr","Address"),t)}catch(e){throw new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+e.message)}}(n,e),n})}catch(e){return Promise.reject(e)}}(t,e))}catch(e){return Promise.reject(e)}}})})}catch(e){return Promise.reject(e)}},Ue=function(){function e(){}return e.prototype.then=function(r,n){var t=new e,o=this.s;if(o){var i=1&o?r:n;if(i){try{Be(t,1,i(this.v))}catch(e){Be(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Be(t,1,r?r(o):o):n?Be(t,1,n(o)):Be(t,2,o)}catch(e){Be(t,2,e)}},t},e}();function qe(e){return e instanceof Ue&&1&e.s}var ze=function(){try{return Promise.resolve(new Promise(function(r){try{return Xe(),Promise.resolve(Qe()).then(function(n){return n.loggedIn&&Ye(n)?r(n):Promise.resolve(e.config().get("challenge.handshake")).then(function(e){var n,t,i,u=(t=(n={handshake:e,l6n:window.location.origin}).l6n,(i=new URL(n.handshake)).searchParams.append("l6n",t),ge(i.href))[1];window.addEventListener("message",function e(n){var t=n.data;try{return t.type===Me||t.type===Je?(u(),window.removeEventListener("message",e),Promise.resolve()):t.type!==He?Promise.resolve():(u(),window.removeEventListener("message",e),Promise.resolve(function(e){try{var r=(e=function(e){return e.addr=e.addr?o.withPrefix(e.addr):null,e.paddr=e.paddr?o.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,r){try{if(null==e||null==r)return Promise.resolve([]);var n=new URL(e);return n.searchParams.append("code",r),Promise.resolve(fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var r=[];if(Array.isArray(e.authorizations))for(var n,t=N(e.authorizations);!(n=t()).done;)r.push(T({type:"authz",keyId:e.keyId},n.value));return null!=e.provider&&r.push(T({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(n){var t,i,u=(t=r,i=n,void 0===t&&(t=[]),void 0===i&&(i=[]),[].concat(t,i)).map(function(r){return function(e,r){try{var n=Se[e.type](e,r);return console.log(e.type,{normalized:n,service:e}),n}catch(r){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,r),e}}(r,e)});console.log("BUILD USER",u);var s=function(e,r){return r.find(function(e){return"authn"===e.type})}(0,u);return T({},we,{addr:o.withPrefix(e.addr),cid:ke(s),loggedIn:!0,services:u,expiresAt:e.exp})})}catch(e){return Promise.reject(e)}}(t)).then(function(e){return a.send(De,_e,e),Promise.resolve(Qe()).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",Fe="CURRENT_USER/UPDATED",_e="SET_CURRENT_USER",Je="FCL::CANCEL",He="FCL::CHALLENGE::RESPONSE",Me="FCL::CHALLENGE::CANCEL",Ke='{\n "@type": "User",\n "@vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Ve=function(e){try{return sessionStorage.setItem(De,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},Ge=function(){return e.config().get("persistSession",!0)},We=((je={})[a.INIT]=function(e){try{return e.merge(JSON.parse(Ke)),Promise.resolve(Ge()).then(function(r){var n=function(){if(r)return Promise.resolve(function(){try{var e=JSON.parse(Ke),r=JSON.parse(sessionStorage.getItem(De));return null!=r&&e["@vsn"]!==r["@vsn"]?(sessionStorage.removeItem(De),Promise.resolve(e)):Promise.resolve(r||e)}catch(e){return Promise.reject(e)}}()).then(function(r){Ye(r)&&e.merge(r)})}();if(n&&n.then)return n.then(function(){})})}catch(e){return Promise.reject(e)}},je[a.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,Fe,T({},e.all()))},je[a.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},je.SNAPSHOT=function(e,r){try{return r.reply(T({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},je[_e]=function(e,r,n){try{return e.merge(n),Promise.resolve(Ge()).then(function(r){r&&Ve(e.all()),e.broadcast(Fe,T({},e.all()))})}catch(e){return Promise.reject(e)}},je.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(Ke)),Promise.resolve(Ge()).then(function(r){r&&Ve(e.all()),e.broadcast(Fe,T({},e.all()))})}catch(e){return Promise.reject(e)}},je),Xe=function(){return a.spawn(We,De)};function Ye(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()}function Ze(){Xe(),a.send(De,"DEL_CURRENT_USER")}function $e(e){Xe();var r=a.spawn(function(r){try{var n;return r.send(De,a.SUBSCRIBE),Promise.resolve(function(e,r,n){for(var t;;){var o=e();if(qe(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=n();if(i&&i.then){if(!qe(i)){t=1;break}i=i.s}}var u=new Ue,s=Be.bind(null,u,2);return(0===t?o.then(c):1===t?i.then(a):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):Be(u,1,i)})).then(void 0,s),u;function a(r){i=r;do{if(!(o=e())||qe(o)&&!o.v)return void Be(u,1,i);if(o.then)return void o.then(c).then(void 0,s);qe(i=n())&&(i=i.v)}while(!i||!i.then);i.then(a).then(void 0,s)}function c(e){e?(i=n())&&i.then?i.then(a).then(void 0,s):a(i):Be(u,1,i)}}(function(){return!n&&1},0,function(){return Promise.resolve(r.receive()).then(function(t){if("@EXIT"===t.tag)return r.send(De,a.UNSUBSCRIBE),void(n=1);e(t.data)})}))}catch(e){return Promise.reject(e)}});return function(){return a.send(r,"@EXIT")}}function Qe(){return Xe(),a.send(De,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var er=function(){return{authenticate:ze,unauthenticate:Ze,authorization:Ce,subscribe:$e,snapshot:Qe}},rr=er().authorization;Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return e.config}}),Object.defineProperty(exports,"isBad",{enumerable:!0,get:function(){return n.isBad}}),Object.defineProperty(exports,"isOk",{enumerable:!0,get:function(){return n.isOk}}),Object.defineProperty(exports,"pipe",{enumerable:!0,get:function(){return n.pipe}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return n.why}}),Object.defineProperty(exports,"latestBlock",{enumerable:!0,get:function(){return t.latestBlock}}),Object.defineProperty(exports,"display",{enumerable:!0,get:function(){return o.display}}),Object.defineProperty(exports,"sansPrefix",{enumerable:!0,get:function(){return o.sansPrefix}}),Object.defineProperty(exports,"withPrefix",{enumerable:!0,get:function(){return o.withPrefix}}),Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return i.account}}),Object.defineProperty(exports,"send",{enumerable:!0,get:function(){return c.send}}),Object.defineProperty(exports,"decode",{enumerable:!0,get:function(){return f.decode}}),Object.defineProperty(exports,"getTransactionStatus",{enumerable:!0,get:function(){return l.getTransactionStatus}}),Object.defineProperty(exports,"getEvents",{enumerable:!0,get:function(){return d.getEvents}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return h.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return h.template}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return m.transaction}}),Object.defineProperty(exports,"script",{enumerable:!0,get:function(){return v.script}}),Object.defineProperty(exports,"ping",{enumerable:!0,get:function(){return y.ping}}),Object.defineProperty(exports,"getAccount",{enumerable:!0,get:function(){return g.getAccount}}),Object.defineProperty(exports,"getLatestBlock",{enumerable:!0,get:function(){return P.getLatestBlock}}),Object.defineProperty(exports,"getBlockById",{enumerable:!0,get:function(){return b.getBlockById}}),Object.defineProperty(exports,"getBlockByHeight",{enumerable:!0,get:function(){return w.getBlockByHeight}}),Object.defineProperty(exports,"authorization",{enumerable:!0,get:function(){return S.authorization}}),Object.defineProperty(exports,"authorizations",{enumerable:!0,get:function(){return S.authorizations}}),Object.defineProperty(exports,"arg",{enumerable:!0,get:function(){return k.arg}}),Object.defineProperty(exports,"args",{enumerable:!0,get:function(){return k.args}}),Object.defineProperty(exports,"proposer",{enumerable:!0,get:function(){return E.proposer}}),Object.defineProperty(exports,"payer",{enumerable:!0,get:function(){return x.payer}}),Object.defineProperty(exports,"limit",{enumerable:!0,get:function(){return I.limit}}),Object.defineProperty(exports,"ref",{enumerable:!0,get:function(){return j.ref}}),Object.defineProperty(exports,"param",{enumerable:!0,get:function(){return O.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return O.params}}),exports.VERSION="0.0.67-alpha.2",exports.authenticate=function(){return er().authenticate()},exports.authz=rr,exports.currentUser=er,exports.events=function(e){return{subscribe:function(r){return a.subscriber(e,ye,r)}}},exports.logIn=function(){return er().authenticate()},exports.reauthenticate=function(){er().unauthenticate(),er().authenticate()},exports.serialize=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{var t=function(){return Promise.resolve(s.resolve(r)(e)).then(JSON.stringify)},o=function(){if(Array.isArray(e))return Promise.resolve(n.pipe(n.interaction(),e)).then(function(r){e=r})}();return Promise.resolve(o&&o.then?o.then(t):t())}catch(e){return Promise.reject(e)}},exports.signUp=function(){return er().authenticate()},exports.tx=he,exports.unauthenticate=function(){return er().unauthenticate()};
//# sourceMappingURL=fcl.js.map

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

import{config as t}from"@onflow/config";export{config}from"@onflow/config";import{pipe as e,interaction as n}from"@onflow/interaction";export{isBad,isOk,pipe,why}from"@onflow/interaction";import{resolve as o}from"@onflow/sdk-resolve";import{subscriber as r,spawn as s,snapshoter as a,INIT as i,SUBSCRIBE as l,UPDATED as u,UNSUBSCRIBE as c,SNAPSHOT as d,send as f}from"@onflow/util-actor";import{send as m}from"@onflow/sdk-send";export{send}from"@onflow/sdk-send";import{decode as p}from"@onflow/sdk-decode";export{decode}from"@onflow/sdk-decode";import{getTransactionStatus as w}from"@onflow/sdk-build-transaction-status";export{getTransactionStatus}from"@onflow/sdk-build-transaction-status";import{latestBlock as h}from"@onflow/sdk-latest-block";export{latestBlock}from"@onflow/sdk-latest-block";export{getEvents}from"@onflow/sdk-build-get-events";import{account as g}from"@onflow/sdk-account";export{account}from"@onflow/sdk-account";import{withPrefix as y,sansPrefix as E}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import{uid as b}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";export{transaction}from"@onflow/sdk-build-transaction";export{script}from"@onflow/sdk-build-script";export{ping}from"@onflow/sdk-build-ping";export{getAccount}from"@onflow/sdk-build-get-account";export{getLatestBlock}from"@onflow/sdk-build-get-latest-block";export{getBlockById}from"@onflow/sdk-build-get-block-by-id";export{getBlockByHeight}from"@onflow/sdk-build-get-block-by-height";export{authorization,authorizations}from"@onflow/sdk-build-authorizations";export{arg,args}from"@onflow/sdk-build-arguments";export{proposer}from"@onflow/sdk-build-proposer";export{payer}from"@onflow/sdk-build-payer";export{limit}from"@onflow/sdk-build-limit";export{ref}from"@onflow/sdk-build-ref";export{param,params}from"@onflow/sdk-build-params";t().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");const k=async(t=[],r={})=>(Array.isArray(t)&&(t=await e(n(),t)),JSON.stringify(await o(r)(t))),S=async t=>m([w(t)]).then(p),v=t=>t.status>=4,T=t=>t.status>=3,x=t=>t.status>=2,I={[i]:async t=>{const e=await S(t.self());v(e)||setTimeout(()=>t.sendSelf("POLL"),2500),t.merge(e)},[l]:(t,e)=>{t.subscribe(e.from),t.send(e.from,u,t.all())},[c]:(t,e)=>{t.unsubscribe(e.from)},[d]:async(t,e)=>{e.reply(t.all())},POLL:async t=>{const e=await S(t.self());var n,o;v(e)||setTimeout(()=>t.sendSelf("POLL"),2500),n=t.all(),o=e,JSON.stringify(n)!==JSON.stringify(o)&&t.broadcast(u,e),t.merge(e)}},P=t=>{if("object"==typeof t&&(t=t.transactionId),null==t)throw new Error("transactionId required");return t},R=t=>s(I,P(t));function L(t){function e(e){return r(P(t),R,e)}function n(t){return function(n={}){const o=n.suppress||!1;return new Promise((n,r)=>{const s=e(e=>{e.statusCode&&!o?(r(e.errorMessage),s()):t(e)&&(n(e),s())})})}}return{snapshot:function(){return a(t,R)},subscribe:e,onceFinalized:n(x),onceExecuted:n(T),onceSealed:n(v)}}L.isUnknown=t=>t.status>=0,L.isPending=t=>t.status>=1,L.isFinalized=x,L.isExecuted=T,L.isSealed=v,L.isExpired=t=>5===t.status;const N=async e=>setTimeout(()=>e.sendSelf("TICK"),await t().get("fcl.eventPollRate",1e4)),C={TICK:async t=>{if(!t.hasSubs())return;let e=t.get("hwm");if(null==e)t.put("hwm",await h()),t.put("tick",await N(t));else{let n=await h();t.put("hwm",n);const o=await m([getEvents(t.self(),e.height,n.height-1)]).then(p);for(let e of o)t.broadcast("UPDATED",e.data);t.put("tick",await N(t))}},[l]:async(t,e)=>{t.hasSubs()||t.put("tick",await N(t)),t.subscribe(e.from)},[c]:(t,e)=>{t.unsubscribe(e.from),t.hasSubs()||(clearTimeout(t.get("tick")),t.delete("tick"),t.delete("hwm"))}},O=t=>s(C,t);function A(t){return{subscribe:e=>r(t,O,e)}}function U(){return(U=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}function D(t){if(document.getElementById("FCL_IFRAME"))return;const e=document.createElement("iframe");return e.src=t,e.id="FCL_IFRAME",e.allow="usb *",e.style.position="fixed",e.style.top="0px",e.style.right="0px",e.style.left="0px",e.style.bottom="0px",e.style.height="100vh",e.style.width="100vw",e.style.display="block",e.style.background="rgba(0,0,0,0.25)",e.style.zIndex=2147483647,e.frameBorder="0",e.style.boxSizing="border-box",document.body.append(e),[e,()=>{document.getElementById("FCL_IFRAME")&&document.getElementById("FCL_IFRAME").remove()}]}function z(t){return`cid:${t.addr||t.name}:${t.pid}`}function F(t,e=!0){const n=new URL(t.endpoint);if(e)for(let[e,o]of Object.entries(t.params||{}))n.searchParams.append(e,o);return n}function _(t){return D(F(t).href)}const j={"HTTP/GET":"GET","HTTP/POST":"POST"},B=t=>new Promise(async(e,n)=>{const o=await fetch(F(t),{method:j[t.method],headers:{"Content-Type":"application/json"}}).then(t=>t.json());"APPROVED"===o.status?e(o.compositeSignature):"DECLINED"===o.status?n({status:o.status,reason:o.reason}):setTimeout(()=>{e(B(o.authorizationUpdates))},500)}),J=(t,e)=>null==e?`'${t}'`:`'${t}' (${e})`,H=(t,e)=>`Missing ${J(t,e)} in Composite Signature.`,$=(t,e)=>`${J(t,e)} in Composit Signature did not match the requested ${t}.`,M={"HTTP/POST":async function(t,e){var n=()=>{},o=null;try{const r=await fetch(F(t),{method:"POST",headers:{"Content-Type":"application/json"},body:e?JSON.stringify(e):void 0}).then(t=>t.json());if(r.local&&r.local.length>0){const[t,e]=_(r.local[0]);n=e}o=await B(r.authorizationUpdates)}catch(o){throw n(),V(t,e,o),o}finally{return n(),o}},"IFRAME/RPC":async function(t,e){return new Promise((n,o)=>{try{const r=b(),[s,a]=_(t),i=()=>{s.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:r,method:"fcl:sign",params:[e,t.params]})),"*")},l=async({data:t})=>{if("object"!=typeof t)return;if("2.0"!==t.jsonrpc)return;if(t.id!==r)return;const e=t.result;"APPROVED"===e.status?(window.removeEventListener("message",l),a(),n(e.compositeSignature)):"DECLINED"===e.status?(window.removeEventListener("message",l),a(),o({status:e.status,reason:e.reason})):(window.removeEventListener("message",l),a(),o({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"}))};window.addEventListener("message",l),new Promise(t=>{window.addEventListener("message",n);const e=setTimeout(()=>{window.removeEventListener("message",n),i(),t()},5e3);function n({data:o}){"FCL::AUTHZ_READY"===o.type&&(clearTimeout(e),window.removeEventListener("message",n),i(),t())}})}catch(n){V(t,e,n),o({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}})}};function V(t,e,n){console.error(`[${t.method}] Trouble talking to Wallet Provider`,"\n\n",{authz:t,signable:e},n)}const G="CURRENT_USER",W="CURRENT_USER/UPDATED",q='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',K=async t=>(sessionStorage.setItem(G,JSON.stringify(t)),t),X=()=>t().get("persistSession",!0),Y={[i]:async t=>{t.merge(JSON.parse(q)),await X()&&t.merge(await(async()=>{const t=JSON.parse(q),e=JSON.parse(sessionStorage.getItem(G));return null!=e&&t.VERSION!==e.VERSION?(sessionStorage.removeItem(G),t):e||t})())},[l]:(t,e)=>{t.subscribe(e.from),t.send(e.from,W,U({},t.all()))},[c]:(t,e)=>{t.unsubscribe(e.from)},SNAPSHOT:async(t,e)=>{e.reply(U({},t.all()))},SET_CURRENT_USER:async(t,e,n)=>{t.merge(n),await X()&&K(t.all()),t.broadcast(W,U({},t.all()))},DEL_CURRENT_USER:async(t,e)=>{t.merge(JSON.parse(q)),await X()&&K(t.all()),t.broadcast(W,U({},t.all()))}},Z=()=>s(Y,G);async function Q(){return new Promise(async e=>{Z();const n=await ot();if(n.loggedIn)return e(n);const[o,r]=function({handshake:t,l6n:e}){var n=new URL(t);return n.searchParams.append("l6n",e),D(n.href)}({handshake:await t().get("challenge.handshake"),l6n:window.location.origin}),s=async({data:t})=>{if("FCL::CHALLENGE::CANCEL"===t.type)return r(),void window.removeEventListener("message",s);"FCL::CHALLENGE::RESPONSE"===t.type&&(r(),window.removeEventListener("message",s),f(G,"SET_CURRENT_USER",await async function(t){const e=function(t=[],e=[]){return[...t,...e]}(t.services||[],await async function(t,e){if(null==t||null==e)return[];const n=new URL(t);n.searchParams.append("code",e);const o=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(t=>t.json());if(Array.isArray(o))return o;const r=[];if(Array.isArray(o.authorizations))for(let t of o.authorizations)r.push(U({type:"authz",keyId:o.keyId},t));return null!=o.provider&&r.push(U({type:"authn",id:"wallet-provider#authn"},o.provider)),r}(t.hks,t.code)),n=e.find(t=>"authn"===t.type);return console.log("RAWR",{data:t,services:e,authn:n}),{addr:t.addr?y(t.addr):null,cid:z(n),loggedIn:!0,services:e}}(t)),e(await ot()))};window.addEventListener("message",s)})}function tt(){Z(),f(G,"DEL_CURRENT_USER")}async function et(t){Z();const e=function(t=[],e){return t.find(t=>t.type===e)}((await Q()).services,"authz");let n;return t.role.proposer&&(n=(await rt()).keys.find(t=>t.index===e.keyId).sequenceNumber),U({},t,{addr:E(e.addr),keyId:e.keyId,sequenceNum:n,signature:t.signature||null,signingFunction:async t=>async function(t,e){const n=await M[t.method](t,e);return null==n.sig&&(n.sig=n.signature),null==n.signature&&(n.signature=n.sig),n.addr=E(n.addr),function(t,e){try{if(null==t.addr)throw new Error(H("addr","Address"));if(null==t.keyId)throw new Error(H("keyId"));if(null==t.signature)throw new Error(H("signature"));if(E(t.addr)!==E(e.addr))throw new Error($("addr","Address"));if(t.keyId!==e.keyId)throw new Error($("keyId"))}catch(n){throw console.error(n,"\n\n",{"Composite Signature":t,"Authz Service":e}),new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+n.message)}}(n,t),n}(e,t),resolve:null,roles:t.roles})}function nt(t){Z();const e=s(async e=>{for(e.send(G,l);;){const n=await e.receive();if("@EXIT"===n.tag)return void e.send(G,c);t(n.data)}});return()=>f(e,"@EXIT")}function ot(){return Z(),f(G,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function rt(){Z();const{addr:t}=await ot();if(null==t)throw new Error("No Flow Address for Current User");return g(t)}const st=()=>({authenticate:Q,unauthenticate:tt,authorization:et,subscribe:nt,snapshot:ot}),at=()=>st().authenticate(),it=()=>st().unauthenticate(),lt=()=>{st().unauthenticate(),st().authenticate()},ut=()=>st().authenticate(),ct=()=>st().authenticate(),dt=st().authorization,ft="0.0.67-alpha.1";export{ft as VERSION,at as authenticate,dt as authz,st as currentUser,A as events,ct as logIn,lt as reauthenticate,k as serialize,ut as signUp,L as tx,it as unauthenticate};
import{config as e}from"@onflow/config";export{config}from"@onflow/config";import{invariant as t}from"@onflow/util-invariant";import{isTransaction as n,isScript as r,get as o,pipe as a,interaction as s}from"@onflow/interaction";export{isBad,isOk,pipe,why}from"@onflow/interaction";import{latestBlock as i}from"@onflow/sdk-latest-block";export{latestBlock}from"@onflow/sdk-latest-block";import{sansPrefix as u,withPrefix as c}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import{account as d}from"@onflow/sdk-account";export{account}from"@onflow/sdk-account";import{encode as l}from"@onflow/rlp";import{resolve as f}from"@onflow/sdk-resolve";import{subscriber as p,spawn as m,snapshoter as y,INIT as g,SUBSCRIBE as h,UPDATED as w,UNSUBSCRIBE as k,SNAPSHOT as E,send as v}from"@onflow/util-actor";import{send as S}from"@onflow/sdk-send";export{send}from"@onflow/sdk-send";import{decode as I}from"@onflow/sdk-decode";export{decode}from"@onflow/sdk-decode";import{getTransactionStatus as b}from"@onflow/sdk-build-transaction-status";export{getTransactionStatus}from"@onflow/sdk-build-transaction-status";export{getEvents}from"@onflow/sdk-build-get-events";import{uid as x}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";export{transaction}from"@onflow/sdk-build-transaction";export{script}from"@onflow/sdk-build-script";export{ping}from"@onflow/sdk-build-ping";export{getAccount}from"@onflow/sdk-build-get-account";export{getLatestBlock}from"@onflow/sdk-build-get-latest-block";export{getBlockById}from"@onflow/sdk-build-get-block-by-id";export{getBlockByHeight}from"@onflow/sdk-build-get-block-by-height";export{authorization,authorizations}from"@onflow/sdk-build-authorizations";export{arg,args}from"@onflow/sdk-build-arguments";export{proposer}from"@onflow/sdk-build-proposer";export{payer}from"@onflow/sdk-build-payer";export{limit}from"@onflow/sdk-build-limit";export{ref}from"@onflow/sdk-build-ref";export{param,params}from"@onflow/sdk-build-params";function T(){return(T=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}e().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var L=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},N=function(e){return L(e,8)},R=function(e){return Buffer.from(JSON.stringify(e),"utf8")},A=function(e){return l(e).toString("hex")},P=function(e){return z(e),[(n=e.script,Buffer.from(n,"utf8")),e.arguments.map(R),(t=e.refBlock,L(t,32)),e.gasLimit,N(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,N(e.payer),e.authorizers.map(N)];var t,n},C=function(e){var t=O(e);return e.payloadSigs.map(function(e){return{signerIndex:t.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,t){return e.signerIndex>t.signerIndex?1:e.signerIndex<t.signerIndex?-1:e.keyId>t.keyId?1:e.keyId<t.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},O=function(e){var t=new Map,n=0,r=function(e){t.has(e)||(t.set(e,n),n++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),t},z=function(e){j.forEach(function(t){return H(e,t)}),_.forEach(function(t){return H(e.proposalKey,t,"proposalKey")})},U=function(e){return"number"==typeof e},D=function(e){return"string"==typeof e},B=function(e){return null!==e&&"object"==typeof e},F=function(e){return B(e)&&e instanceof Array},j=[{name:"script",check:D},{name:"arguments",check:F},{name:"refBlock",check:D,defaultVal:"0"},{name:"gasLimit",check:U},{name:"proposalKey",check:B},{name:"payer",check:D},{name:"authorizers",check:F}],_=[{name:"address",check:D},{name:"keyId",check:U},{name:"sequenceNum",check:U}],J=[{name:"payloadSigs",check:F}],q=[{name:"address",check:D},{name:"keyId",check:U},{name:"sig",check:D}],H=function(e,t,n,r){var o=t.name,a=t.check,s=t.defaultVal;if(null==e[o]&&null!=s&&(e[o]=s),null==e[o])throw M(o,n,r);if(!a(e[o]))throw G(o,n,r)},K=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},M=function(e,t,n){return new Error("Missing field "+K(e,t,n))},G=function(e,t,n){return new Error("Invalid field "+K(e,t,n))};const V=e=>"string"==typeof e,$=e=>"function"==typeof e;function W(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(t=>e.arguments[t].asArgument),proposalKey:{address:u(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:u(e.accounts[e.payer].addr),authorizers:e.authorizations.map(t=>u(e.accounts[t].addr)).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[])}}e().put("sdk.resolve",async function(e){if(e=await e,n(e)||r(e)){var a=o(e,"ix.cadence");t($(a)||V(a),"Cadence needs to be a function or a string."),$(a)&&(a=await a({})),t(V(a),"Cadence needs to be a string at this point."),e.message.cadence=a}if(n(e)||r(e)){function s(e){return t(null!=typeof e.xform,"No type specified for argument: "+e.value),$(e.xform)?e.xform(e.value):$(e.xform.asArgument)?e.xform.asArgument(e.value):void t(!1,"Invalid Argument",e)}for(let[t,n]of Object.entries(e.arguments))e.arguments[t].asArgument=s(n)}if(n(e)){var c={};for(let[t,n]of Object.entries(e.accounts)){var l=t;$(n.resolve)&&(n=await n.resolve(n),t=n.tempId),c[t]=c[t]||n,c[t].role.proposer=c[t].role.proposer||n.role.proposer,c[t].role.payer=c[t].role.payer||n.role.payer,c[t].role.authorizer=c[t].role.authorizer||n.role.authorizer,e.proposer===l&&(e.proposer=t),e.payer===l&&(e.payer=t),e.authorizations=e.authorizations.map(e=>e===l?t:e)}e.accounts=c}if(n(e),n(e)&&null==e.message.refBlock&&(e.message.refBlock=(await i()).id),n(e)){var f=Object.values(e.accounts).find(e=>e.role.proposer);t(f,"Transactions require a proposer"),null===f.sequenceNum&&(e.accounts[f.tempId].sequenceNum=await d(f.addr).then(e=>e.keys).then(e=>e.find(e=>e.index===f.keyId)).then(e=>e.sequenceNumber))}if(n(e)){console.log("RESOLVE SIGNATURES START",e);let t=new Set(e.authorizations);t.add(e.proposer),t.delete(e.payer),t=Array.from(t);let n=new Set([e.payer]);n=Array.from(n),console.log("SIGNATORIES",{insideSigners:t,outsideSigners:n});const r=(p=W(e),A(P(p)));await Promise.all(t.map(async t=>{const n=e.accounts[t];if(null!=n.signature)return;const{signature:o}=await n.signingFunction({message:r,addr:u(n.addr),keyId:n.keyId,roles:n.role,interaction:e});e.accounts[t].signature=o}));const o=function(e){return A(function(e){return function(e){J.forEach(function(t){return H(e,t)}),e.payloadSigs.forEach(function(e,t){q.forEach(function(n){return H(e,n,"payloadSigs",t)})})}(e),[P(e),C(e)]}(e))}(T({},W(e),{payloadSigs:t.map(t=>e.accounts[t].signature)}));await Promise.all(n.map(async t=>{const n=e.accounts[t];if(null!=n.signature)return;const{signature:r}=await n.signingFunction({message:o,addr:u(n.addr),keyId:n.keyId,roles:n.role,interaction:e});e.accounts[t].signature=r})),console.log("RESOLVE SIGNATURES END",e)}var p;return e});const X=async(e=[],t={})=>(Array.isArray(e)&&(e=await a(s(),e)),JSON.stringify(await f(t)(e))),Y=async e=>S([b(e)]).then(I),Z=e=>e.status>=4,Q=e=>e.status>=3,ee=e=>e.status>=2,te={[g]:async e=>{const t=await Y(e.self());Z(t)||setTimeout(()=>e.sendSelf("POLL"),2500),e.merge(t)},[h]:(e,t)=>{e.subscribe(t.from),e.send(t.from,w,e.all())},[k]:(e,t)=>{e.unsubscribe(t.from)},[E]:async(e,t)=>{t.reply(e.all())},POLL:async e=>{const t=await Y(e.self());var n,r;Z(t)||setTimeout(()=>e.sendSelf("POLL"),2500),n=e.all(),r=t,JSON.stringify(n)!==JSON.stringify(r)&&e.broadcast(w,t),e.merge(t)}},ne=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},re=e=>m(te,ne(e));function oe(e){function t(t){return p(ne(e),re,t)}function n(e){return function(n={}){const r=n.suppress||!1;return new Promise((n,o)=>{const a=t(t=>{t.statusCode&&!r?(o(t.errorMessage),a()):e(t)&&(n(t),a())})})}}return{snapshot:function(){return y(e,re)},subscribe:t,onceFinalized:n(ee),onceExecuted:n(Q),onceSealed:n(Z)}}oe.isUnknown=e=>e.status>=0,oe.isPending=e=>e.status>=1,oe.isFinalized=ee,oe.isExecuted=Q,oe.isSealed=Z,oe.isExpired=e=>5===e.status;const ae=async t=>setTimeout(()=>t.sendSelf("TICK"),await e().get("fcl.eventPollRate",1e4)),se={TICK:async e=>{if(!e.hasSubs())return;let t=e.get("hwm");if(null==t)e.put("hwm",await i()),e.put("tick",await ae(e));else{let n=await i();e.put("hwm",n);const r=await S([getEvents(e.self(),t.height,n.height-1)]).then(I);for(let t of r)e.broadcast("UPDATED",t.data);e.put("tick",await ae(e))}},[h]:async(e,t)=>{e.hasSubs()||e.put("tick",await ae(e)),e.subscribe(t.from)},[k]:(e,t)=>{e.unsubscribe(t.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))}},ie=e=>m(se,e);function ue(e){return{subscribe:t=>p(e,ie,t)}}function ce(e){if(document.getElementById("FCL_IFRAME"))return;const t=document.createElement("iframe");return t.src=e,t.id="FCL_IFRAME",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.style.zIndex=2147483647,t.frameBorder="0",t.style.boxSizing="border-box",document.body.append(t),[t,()=>{document.getElementById("FCL_IFRAME")&&document.getElementById("FCL_IFRAME").remove()}]}const de={"@type":"Service","@vsn":"1.0.0"},le={"@type":"Identity","@vsn":"1.0.0"},fe={"@type":"USER","@vsn":"1.0.0"},pe={authn:function(e){switch(e["@vsn"]){case"1.0.0":return e;default:return T({},de,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:c(e.addr),name:e.name,icon:e.icon}})}},authz:function(e){switch(e["@vsn"]){case"1.0.0":return e;default:return T({},de,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:T({},le,{address:c(e.addr),keyId:e.keyId}),params:e.params,data:e.data})}},"pre-authz":function(e){switch(e["@vsn"]){case"1.0.0":return e;default:return T({},de,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:T({},le,{address:c(e.addr),keyId:e.keyId}),params:e.params,data:e.data})}}};function me(e){return l([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}function ye(e=[],t){return e.find(e=>e.type===t)}function ge(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}function he(e){return ce(ge(e).href)}const we={"HTTP/GET":"GET","HTTP/POST":"POST"},ke=e=>new Promise(async(t,n)=>{const r=await fetch(ge(e),{method:we[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(ke(r.authorizationUpdates))},500)}),Ee=(e,t)=>null==t?`'${e}'`:`'${e}' (${t})`,ve=(e,t)=>`Missing ${Ee(e,t)} in Composite Signature.`,Se=(e,t)=>`${Ee(e,t)} in Composit Signature did not match the requested ${e}.`,Ie={"HTTP/POST":async function(e,t){var n=()=>{},r=null;try{const o=await fetch(ge(e,!0),{method:"POST",headers:{"Content-Type":"application/json"},body:t?JSON.stringify(t):void 0}).then(e=>e.json());if(console.log("RESP",o),o.local&&o.local.length>0){const[e,t]=he(o.local[0]);n=t}r=await ke(o.authorizationUpdates)}catch(r){throw n(),be(e,t,r),r}finally{return n(),r}},"IFRAME/RPC":async function(e,t){return new Promise((n,r)=>{try{const o=x(),[a,s]=he(e),i=()=>{a.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params]})),"*")},u=async({data:e})=>{if("object"!=typeof e)return;if("2.0"!==e.jsonrpc)return;if(e.id!==o)return;const t=e.result;"APPROVED"===t.status?(window.removeEventListener("message",u),s(),n(t.compositeSignature)):"DECLINED"===t.status?(window.removeEventListener("message",u),s(),r({status:t.status,reason:t.reason})):(window.removeEventListener("message",u),s(),r({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"}))};window.addEventListener("message",u),new Promise(e=>{window.addEventListener("message",n);const t=setTimeout(()=>{window.removeEventListener("message",n),i(),e()},5e3);function n({data:r}){"FCL::AUTHZ_READY"===r.type&&(clearTimeout(t),window.removeEventListener("message",n),i(),e())}})}catch(n){be(e,t,n),r({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}})}};function be(e,t,n){console.error(`[${e.method}] Trouble talking to Wallet Provider`,"\n\n",{authz:e,signable:t},n)}const xe="CURRENT_USER",Te="CURRENT_USER/UPDATED",Le='{\n "@type": "User",\n "@vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Ne=async e=>(sessionStorage.setItem(xe,JSON.stringify(e)),e),Re=()=>e().get("persistSession",!0),Ae={[g]:async e=>{if(e.merge(JSON.parse(Le)),await Re()){const t=await(async()=>{const e=JSON.parse(Le),t=JSON.parse(sessionStorage.getItem(xe));return null!=t&&e["@vsn"]!==t["@vsn"]?(sessionStorage.removeItem(xe),e):t||e})();Ce(t)&&e.merge(t)}},[h]:(e,t)=>{e.subscribe(t.from),e.send(t.from,Te,T({},e.all()))},[k]:(e,t)=>{e.unsubscribe(t.from)},SNAPSHOT:async(e,t)=>{t.reply(T({},e.all()))},SET_CURRENT_USER:async(e,t,n)=>{e.merge(n),await Re()&&Ne(e.all()),e.broadcast(Te,T({},e.all()))},DEL_CURRENT_USER:async(e,t)=>{e.merge(JSON.parse(Le)),await Re()&&Ne(e.all()),e.broadcast(Te,T({},e.all()))}},Pe=()=>m(Ae,xe);function Ce(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()}async function Oe(){return new Promise(async t=>{Pe();const n=await Be();if(n.loggedIn&&Ce(n))return t(n);const[r,o]=function({handshake:e,l6n:t}){var n=new URL(e);return n.searchParams.append("l6n",t),ce(n.href)}({handshake:await e().get("challenge.handshake"),l6n:window.location.origin}),a=async({data:e})=>{if("FCL::CHALLENGE::CANCEL"===e.type||"FCL::CANCEL"===e.type)return o(),void window.removeEventListener("message",a);"FCL::CHALLENGE::RESPONSE"===e.type&&(o(),window.removeEventListener("message",a),v(xe,"SET_CURRENT_USER",await async function(e){var t=function(e=[],t=[]){return[...e,...t]}((e=function(e){return e.addr=e.addr?c(e.addr):null,e.paddr=e.paddr?c(e.paddr):null,e}(e)).services||[],await async function(e,t){if(null==e||null==t)return[];const n=new URL(e);n.searchParams.append("code",t);const r=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json());if(Array.isArray(r))return r;const o=[];if(Array.isArray(r.authorizations))for(let e of r.authorizations)o.push(T({type:"authz",keyId:r.keyId},e));return null!=r.provider&&o.push(T({type:"authn",id:"wallet-provider#authn"},r.provider)),o}(e.hks,e.code)).map(t=>function(e,t){try{var n=pe[e.type](e,t);return console.log(e.type,{normalized:n,service:e}),n}catch(t){return console.error(`Unrecognized FCL Service Type [${e.type}]`,e,t),e}}(t,e));console.log("BUILD USER",t);const n=function(e,t){return t.find(e=>"authn"===e.type)}(0,t);return T({},fe,{addr:c(e.addr),cid:me(n),loggedIn:!0,services:t,expiresAt:e.exp})}(e)),t(await Be()))};window.addEventListener("message",a)})}function ze(){Pe(),v(xe,"DEL_CURRENT_USER")}async function Ue(e){Pe();const n=await Oe(),r=(ye(n.services,"authn"),ye(n.services,"authz"));return ye(n.services,"pre-authz"),T({},e,{tempId:"CURRENT_USER",resolve:null,addr:u(r.identity.address),keyId:r.identity.keyId,sequenceNum:null,signature:null,signingFunction:async e=>async function(e,n){const r=await Ie[e.method](e,n);return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),r.addr=u(r.addr),function(e,n){try{const r={compSig:e,authz:n};t(e.addr,ve("addr","Address"),r),t(e.keyId,ve("keyId"),r),t(e.signature,ve("signature"),r),t(e.keyId===n.identity.keyId,Se("keyId"),r),t(u(e.addr)===u(n.identity.address),Se("addr","Address"),r)}catch(e){throw new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+e.message)}}(r,e),r}(r,e)})}function De(e){Pe();const t=m(async t=>{for(t.send(xe,h);;){const n=await t.receive();if("@EXIT"===n.tag)return void t.send(xe,k);e(n.data)}});return()=>v(t,"@EXIT")}function Be(){return Pe(),v(xe,"SNAPSHOT",null,{expectReply:!0,timeout:0})}const Fe=()=>({authenticate:Oe,unauthenticate:ze,authorization:Ue,subscribe:De,snapshot:Be}),je=()=>Fe().authenticate(),_e=()=>Fe().unauthenticate(),Je=()=>{Fe().unauthenticate(),Fe().authenticate()},qe=()=>Fe().authenticate(),He=()=>Fe().authenticate(),Ke=Fe().authorization,Me="0.0.67-alpha.2";export{Me as VERSION,je as authenticate,Ke as authz,Fe as currentUser,ue as events,He as logIn,Je as reauthenticate,X as serialize,qe as signUp,oe as tx,_e as unauthenticate};
//# sourceMappingURL=fcl.modern.js.map

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

import{config as e}from"@onflow/config";export{config}from"@onflow/config";import{pipe as r,interaction as t}from"@onflow/interaction";export{isBad,isOk,pipe,why}from"@onflow/interaction";import{resolve as n}from"@onflow/sdk-resolve";import{INIT as o,SUBSCRIBE as i,UPDATED as s,UNSUBSCRIBE as u,SNAPSHOT as a,subscriber as c,spawn as l,snapshoter as f,send as d}from"@onflow/util-actor";import{send as m}from"@onflow/sdk-send";export{send}from"@onflow/sdk-send";import{decode as h}from"@onflow/sdk-decode";export{decode}from"@onflow/sdk-decode";import{getTransactionStatus as v}from"@onflow/sdk-build-transaction-status";export{getTransactionStatus}from"@onflow/sdk-build-transaction-status";import{latestBlock as p}from"@onflow/sdk-latest-block";export{latestBlock}from"@onflow/sdk-latest-block";export{getEvents}from"@onflow/sdk-build-get-events";import{account as P}from"@onflow/sdk-account";export{account}from"@onflow/sdk-account";import{withPrefix as y,sansPrefix as g}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import{uid as w}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";export{transaction}from"@onflow/sdk-build-transaction";export{script}from"@onflow/sdk-build-script";export{ping}from"@onflow/sdk-build-ping";export{getAccount}from"@onflow/sdk-build-get-account";export{getLatestBlock}from"@onflow/sdk-build-get-latest-block";export{getBlockById}from"@onflow/sdk-build-get-block-by-id";export{getBlockByHeight}from"@onflow/sdk-build-get-block-by-height";export{authorization,authorizations}from"@onflow/sdk-build-authorizations";export{arg,args}from"@onflow/sdk-build-arguments";export{proposer}from"@onflow/sdk-build-proposer";export{payer}from"@onflow/sdk-build-payer";export{limit}from"@onflow/sdk-build-limit";export{ref}from"@onflow/sdk-build-ref";export{param,params}from"@onflow/sdk-build-params";e().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var b,E,k=function(e,o){void 0===e&&(e=[]),void 0===o&&(o={});try{var i=function(){return Promise.resolve(n(o)(e)).then(JSON.stringify)},s=function(){if(Array.isArray(e))return Promise.resolve(r(t(),e)).then(function(r){e=r})}();return Promise.resolve(s&&s.then?s.then(i):i())}catch(e){return Promise.reject(e)}},S=function(e){try{return Promise.resolve(m([v(e)]).then(h))}catch(e){return Promise.reject(e)}},j=function(e){return e.status>=4},T=function(e){return e.status>=3},I=function(e){return e.status>=2},x=((b={})[o]=function(e){try{return Promise.resolve(S(e.self())).then(function(r){j(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},b[i]=function(e,r){e.subscribe(r.from),e.send(r.from,s,e.all())},b[u]=function(e,r){e.unsubscribe(r.from)},b[a]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},b.POLL=function(e){try{return Promise.resolve(S(e.self())).then(function(r){var t,n;j(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),t=e.all(),n=r,JSON.stringify(t)!==JSON.stringify(n)&&e.broadcast(s,r),e.merge(r)})}catch(e){return Promise.reject(e)}},b),L=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},A=function(e){return l(x,L(e))};function R(e){function r(r){return c(L(e),A,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 f(e,A)},subscribe:r,onceFinalized:t(I),onceExecuted:t(T),onceSealed:t(j)}}function N(){return(N=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 O(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 C(e,r){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return O(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(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?O(e,void 0):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}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(t=e[Symbol.iterator]()).next.bind(t)}R.isUnknown=function(e){return e.status>=0},R.isPending=function(e){return e.status>=1},R.isFinalized=I,R.isExecuted=T,R.isSealed=j,R.isExpired=function(e){return 5===e.status};var D=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)}},U=((E={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var r=e.get("hwm"),t=function(){if(null==r){var t=e.put;return Promise.resolve(p()).then(function(r){t.call(e,"hwm",r);var n=e.put;return Promise.resolve(D(e)).then(function(r){n.call(e,"tick",r)})})}return Promise.resolve(p()).then(function(t){return e.put("hwm",t),Promise.resolve(m([getEvents(e.self(),r.height,t.height-1)]).then(h)).then(function(r){for(var t,n=C(r);!(t=n()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(D(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)}},E[i]=function(e,r){try{var t=function(){e.subscribe(r.from)},n=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(D(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)}},E[u]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},E),z=function(e){return l(U,e)};function F(e){return{subscribe:function(r){return c(e,z,r)}}}function _(e){if(!document.getElementById("FCL_IFRAME")){var r=document.createElement("iframe");return r.src=e,r.id="FCL_IFRAME",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.style.zIndex=2147483647,r.frameBorder="0",r.style.boxSizing="border-box",document.body.append(r),[r,function(){document.getElementById("FCL_IFRAME")&&document.getElementById("FCL_IFRAME").remove()}]}}function B(e){return"cid:"+(e.addr||e.name)+":"+e.pid}function J(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}function H(e){return _(J(e).href)}var M,V={"HTTP/GET":"GET","HTTP/POST":"POST"},G=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},W=function(e,r){return"Missing "+G(e,r)+" in Composite Signature."},q=function(e,r){return G(e,r)+" in Composit Signature did not match the requested "+e+"."},K={"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(J(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=H(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(J(r),{method:V[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(n){throw t(),X(e,r,n),n})},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=w(),i=H(e),s=i[0],u=i[1],a=function(){s.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")};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 s=i.result;return"APPROVED"===s.status?(window.removeEventListener("message",e),u(),t(s.compositeSignature)):"DECLINED"===s.status?(window.removeEventListener("message",e),u(),n({status:s.status,reason:s.reason})):(window.removeEventListener("message",e),u(),n({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"})),Promise.resolve()}catch(e){return Promise.reject(e)}}),new Promise(function(e){window.addEventListener("message",t);var r=setTimeout(function(){window.removeEventListener("message",t),a(),e()},5e3);function t(n){"FCL::AUTHZ_READY"===n.data.type&&(clearTimeout(r),window.removeEventListener("message",t),a(),e())}})}catch(t){X(e,r,t),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function X(e,r,t){console.error("["+e.method+"] Trouble talking to Wallet Provider","\n\n",{authz:e,signable:r},t)}function Y(e,r,t){if(!e.s){if(t instanceof Q){if(!t.s)return void(t.o=Y.bind(null,e,r));1&r&&(r=t.s),t=t.v}if(t&&t.then)return void t.then(Y.bind(null,e,r),Y.bind(null,e,2));e.s=r,e.v=t;var n=e.o;n&&n(e)}}var Z=function(){try{return fe(),Promise.resolve(he()).then(function(e){var r=e.addr;if(null==r)throw new Error("No Flow Address for Current User");return P(r)})}catch(e){return Promise.reject(e)}},$=function(e){try{return fe(),Promise.resolve(re()).then(function(r){function t(){return N({},e,{addr:g(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(K[e.method](e,r)).then(function(r){return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),r.addr=g(r.addr),function(e,r){try{if(null==e.addr)throw new Error(W("addr","Address"));if(null==e.keyId)throw new Error(W("keyId"));if(null==e.signature)throw new Error(W("signature"));if(g(e.addr)!==g(r.addr))throw new Error(q("addr","Address"));if(e.keyId!==r.keyId)throw new Error(q("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})),s=function(){if(e.role.proposer)return Promise.resolve(Z()).then(function(e){var r=e.keys.find(function(e){return e.index===i.keyId});o=r.sequenceNumber})}();return s&&s.then?s.then(t):t()})}catch(e){return Promise.reject(e)}},Q=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{Y(n,1,i(this.v))}catch(e){Y(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?Y(n,1,r?r(o):o):t?Y(n,1,t(o)):Y(n,2,o)}catch(e){Y(n,2,e)}},n},e}();function ee(e){return e instanceof Q&&1&e.s}var re=function(){try{return Promise.resolve(new Promise(function(r){try{return fe(),Promise.resolve(he()).then(function(t){return t.loggedIn?r(t):Promise.resolve(e().get("challenge.handshake")).then(function(e){var t,n,o,i=(n=(t={handshake:e,l6n:window.location.origin}).l6n,(o=new URL(t.handshake)).searchParams.append("l6n",n),_(o.href))[1];window.addEventListener("message",function e(t){var n=t.data;try{return n.type===se?(i(),window.removeEventListener("message",e),Promise.resolve()):n.type!==ie?Promise.resolve():(i(),window.removeEventListener("message",e),Promise.resolve(function(e){try{var r=e.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=C(e.authorizations);!(t=n()).done;)r.push(N({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&r.push(N({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(t){var n,o,i=(void 0===(n=r)&&(n=[]),void 0===(o=t)&&(o=[]),[].concat(n,o)),s=i.find(function(e){return"authn"===e.type});return console.log("RAWR",{data:e,services:i,authn:s}),{addr:e.addr?y(e.addr):null,cid:B(s),loggedIn:!0,services:i}})}catch(e){return Promise.reject(e)}}(n)).then(function(e){return d(te,oe,e),Promise.resolve(he()).then(function(e){r(e)})}))}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},te="CURRENT_USER",ne="CURRENT_USER/UPDATED",oe="SET_CURRENT_USER",ie="FCL::CHALLENGE::RESPONSE",se="FCL::CHALLENGE::CANCEL",ue='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',ae=function(e){try{return sessionStorage.setItem(te,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},ce=function(){return e().get("persistSession",!0)},le=((M={})[o]=function(e){try{return e.merge(JSON.parse(ue)),Promise.resolve(ce()).then(function(r){var t=function(){if(r){var t=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(ue),r=JSON.parse(sessionStorage.getItem(te));return null!=r&&e.VERSION!==r.VERSION?(sessionStorage.removeItem(te),Promise.resolve(e)):Promise.resolve(r||e)}catch(e){return Promise.reject(e)}}()).then(function(r){t.call(e,r)})}}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}},M[i]=function(e,r){e.subscribe(r.from),e.send(r.from,ne,N({},e.all()))},M[u]=function(e,r){e.unsubscribe(r.from)},M.SNAPSHOT=function(e,r){try{return r.reply(N({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},M[oe]=function(e,r,t){try{return e.merge(t),Promise.resolve(ce()).then(function(r){r&&ae(e.all()),e.broadcast(ne,N({},e.all()))})}catch(e){return Promise.reject(e)}},M.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(ue)),Promise.resolve(ce()).then(function(r){r&&ae(e.all()),e.broadcast(ne,N({},e.all()))})}catch(e){return Promise.reject(e)}},M),fe=function(){return l(le,te)};function de(){fe(),d(te,"DEL_CURRENT_USER")}function me(e){fe();var r=l(function(r){try{var t;return r.send(te,i),Promise.resolve(function(e,r,t){for(var n;;){var o=e();if(ee(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=t();if(i&&i.then){if(!ee(i)){n=1;break}i=i.s}}var s=new Q,u=Y.bind(null,s,2);return(0===n?o.then(c):1===n?i.then(a):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,u):c(o):Y(s,1,i)})).then(void 0,u),s;function a(r){i=r;do{if(!(o=e())||ee(o)&&!o.v)return void Y(s,1,i);if(o.then)return void o.then(c).then(void 0,u);ee(i=t())&&(i=i.v)}while(!i||!i.then);i.then(a).then(void 0,u)}function c(e){e?(i=t())&&i.then?i.then(a).then(void 0,u):a(i):Y(s,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(n){if("@EXIT"===n.tag)return r.send(te,u),void(t=1);e(n.data)})}))}catch(e){return Promise.reject(e)}});return function(){return d(r,"@EXIT")}}function he(){return fe(),d(te,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var ve=function(){return{authenticate:re,unauthenticate:de,authorization:$,subscribe:me,snapshot:he}},pe=function(){return ve().authenticate()},Pe=function(){return ve().unauthenticate()},ye=function(){ve().unauthenticate(),ve().authenticate()},ge=function(){return ve().authenticate()},we=function(){return ve().authenticate()},be=ve().authorization,Ee="0.0.67-alpha.1";export{Ee as VERSION,pe as authenticate,be as authz,ve as currentUser,F as events,we as logIn,ye as reauthenticate,k as serialize,ge as signUp,R as tx,Pe as unauthenticate};
import{config as e}from"@onflow/config";export{config}from"@onflow/config";import{invariant as r}from"@onflow/util-invariant";import{isTransaction as n,isScript as t,get as o,pipe as i,interaction as u}from"@onflow/interaction";export{isBad,isOk,pipe,why}from"@onflow/interaction";import{latestBlock as s}from"@onflow/sdk-latest-block";export{latestBlock}from"@onflow/sdk-latest-block";import{sansPrefix as a,withPrefix as c}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import{account as f}from"@onflow/sdk-account";export{account}from"@onflow/sdk-account";import{encode as l}from"@onflow/rlp";import{resolve as d}from"@onflow/sdk-resolve";import{INIT as m,SUBSCRIBE as h,UPDATED as p,UNSUBSCRIBE as v,SNAPSHOT as y,subscriber as g,spawn as P,snapshoter as w,send as k}from"@onflow/util-actor";import{send as b}from"@onflow/sdk-send";export{send}from"@onflow/sdk-send";import{decode as E}from"@onflow/sdk-decode";export{decode}from"@onflow/sdk-decode";import{getTransactionStatus as S}from"@onflow/sdk-build-transaction-status";export{getTransactionStatus}from"@onflow/sdk-build-transaction-status";export{getEvents}from"@onflow/sdk-build-get-events";import{uid as I}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";export{transaction}from"@onflow/sdk-build-transaction";export{script}from"@onflow/sdk-build-script";export{ping}from"@onflow/sdk-build-ping";export{getAccount}from"@onflow/sdk-build-get-account";export{getLatestBlock}from"@onflow/sdk-build-get-latest-block";export{getBlockById}from"@onflow/sdk-build-get-block-by-id";export{getBlockByHeight}from"@onflow/sdk-build-get-block-by-height";export{authorization,authorizations}from"@onflow/sdk-build-authorizations";export{arg,args}from"@onflow/sdk-build-arguments";export{proposer}from"@onflow/sdk-build-proposer";export{payer}from"@onflow/sdk-build-payer";export{limit}from"@onflow/sdk-build-limit";export{ref}from"@onflow/sdk-build-ref";export{param,params}from"@onflow/sdk-build-params";function x(){return(x=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}function T(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function A(e,r){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return T(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?T(e,void 0):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}e().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var j=function(e,r){return Buffer.from(e.padStart(2*r,0),"hex")},L=function(e){return j(e,8)},N=function(e){return Buffer.from(JSON.stringify(e),"utf8")},R=function(e){return l(e).toString("hex")},C=function(e){return U(e),[(n=e.script,Buffer.from(n,"utf8")),e.arguments.map(N),(r=e.refBlock,j(r,32)),e.gasLimit,L(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,L(e.payer),e.authorizers.map(L)];var r,n},O=function(e){var r=z(e);return e.payloadSigs.map(function(e){return{signerIndex:r.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,r){return e.signerIndex>r.signerIndex?1:e.signerIndex<r.signerIndex?-1:e.keyId>r.keyId?1:e.keyId<r.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(r=e.sig,Buffer.from(r,"hex"))];var r})},z=function(e){var r=new Map,n=0,t=function(e){r.has(e)||(r.set(e,n),n++)};return t(e.proposalKey.address),t(e.payer),e.authorizers.forEach(t),r},U=function(e){J.forEach(function(r){return K(e,r)}),q.forEach(function(r){return K(e.proposalKey,r,"proposalKey")})},D=function(e){return"number"==typeof e},B=function(e){return"string"==typeof e},F=function(e){return null!==e&&"object"==typeof e},_=function(e){return F(e)&&e instanceof Array},J=[{name:"script",check:B},{name:"arguments",check:_},{name:"refBlock",check:B,defaultVal:"0"},{name:"gasLimit",check:D},{name:"proposalKey",check:F},{name:"payer",check:B},{name:"authorizers",check:_}],q=[{name:"address",check:B},{name:"keyId",check:D},{name:"sequenceNum",check:D}],M=[{name:"payloadSigs",check:_}],H=[{name:"address",check:B},{name:"keyId",check:D},{name:"sig",check:B}],K=function(e,r,n,t){var o=r.name,i=r.check,u=r.defaultVal;if(null==e[o]&&null!=u&&(e[o]=u),null==e[o])throw V(o,n,t);if(!i(e[o]))throw W(o,n,t)},G=function(e,r,n){return r?null==n?r+"."+e:r+"."+n+"."+e:e},V=function(e,r,n){return new Error("Missing field "+G(e,r,n))},W=function(e,r,n){return new Error("Invalid field "+G(e,r,n))},X="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Y(e,r,n){if(!e.s){if(n instanceof Z){if(!n.s)return void(n.o=Y.bind(null,e,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(Y.bind(null,e,r),Y.bind(null,e,2));e.s=r,e.v=n;var t=e.o;t&&t(e)}}var Z=function(){function e(){}return e.prototype.then=function(r,n){var t=new e,o=this.s;if(o){var i=1&o?r:n;if(i){try{Y(t,1,i(this.v))}catch(e){Y(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Y(t,1,r?r(o):o):n?Y(t,1,n(o)):Y(t,2,o)}catch(e){Y(t,2,e)}},t},e}();function $(e){return e instanceof Z&&1&e.s}var Q=function(e){return"string"==typeof e},ee=function(e){return"function"==typeof e};function re(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(r){return e.arguments[r].asArgument}),proposalKey:{address:a(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:a(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(r){return a(e.accounts[r].addr)}).reduce(function(e,r){return e.find(function(e){return e===r})?e:[].concat(e,[r])},[])}}e().put("sdk.resolve",function(e){try{return Promise.resolve(e).then(function(i){function u(){function o(){function t(){function t(){var r=function(){if(n(e)){console.log("RESOLVE SIGNATURES START",e);var r=new Set(e.authorizations);r.add(e.proposer),r.delete(e.payer),r=Array.from(r);var t=new Set([e.payer]);t=Array.from(t),console.log("SIGNATORIES",{insideSigners:r,outsideSigners:t});var o=(i=re(e),R(C(i)));return Promise.resolve(Promise.all(r.map(function(r){try{var n=e.accounts[r];return null!=n.signature?Promise.resolve():Promise.resolve(n.signingFunction({message:o,addr:a(n.addr),keyId:n.keyId,roles:n.role,interaction:e})).then(function(n){e.accounts[r].signature=n.signature})}catch(e){return Promise.reject(e)}}))).then(function(){var n=function(e){return R(function(e){return function(e){M.forEach(function(r){return K(e,r)}),e.payloadSigs.forEach(function(e,r){H.forEach(function(n){return K(e,n,"payloadSigs",r)})})}(e),[C(e),O(e)]}(e))}(x({},re(e),{payloadSigs:r.map(function(r){return e.accounts[r].signature})}));return Promise.resolve(Promise.all(t.map(function(r){try{var t=e.accounts[r];return null!=t.signature?Promise.resolve():Promise.resolve(t.signingFunction({message:n,addr:a(t.addr),keyId:t.keyId,roles:t.role,interaction:e})).then(function(n){e.accounts[r].signature=n.signature})}catch(e){return Promise.reject(e)}}))).then(function(){console.log("RESOLVE SIGNATURES END",e)})})}var i}();return r&&r.then?r.then(function(){return e}):e}var o=function(){if(n(e)){var t=Object.values(e.accounts).find(function(e){return e.role.proposer});r(t,"Transactions require a proposer");var o=function(){if(null===t.sequenceNum)return Promise.resolve(f(t.addr).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===t.keyId})}).then(function(e){return e.sequenceNumber})).then(function(r){e.accounts[t.tempId].sequenceNum=r})}();if(o&&o.then)return o.then(function(){})}}();return o&&o.then?o.then(t):t()}n(e);var o=function(){if(n(e)&&null==e.message.refBlock)return Promise.resolve(s()).then(function(r){e.message.refBlock=r.id})}();return o&&o.then?o.then(t):t()}if(n(e)||t(e))for(var i=function(e){return r(null!=typeof e.xform,"No type specified for argument: "+e.value),ee(e.xform)?e.xform(e.value):ee(e.xform.asArgument)?e.xform.asArgument(e.value):void r(!1,"Invalid Argument",e)},u=0,c=Object.entries(e.arguments);u<c.length;u++){var l=c[u];e.arguments[l[0]].asArgument=i(l[1])}var d=function(){if(n(e)){var r=function(){e.accounts=t},t={},o=function(e,r,n){if("function"==typeof e[X]){var t,o,i,u=e[X]();if(function e(n){try{for(;!(t=u.next()).done;)if((n=r(t.value))&&n.then){if(!$(n))return void n.then(e,i||(i=Y.bind(null,o=new Z,2)));n=n.v}o?Y(o,1,n):o=n}catch(e){Y(o||(o=new Z),2,e)}}(),u.return){var s=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(s,function(e){throw s(e)});s()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],c=0;c<e.length;c++)a.push(e[c]);return function(e,r,n){var t,o,i=-1;return function n(u){try{for(;++i<e.length;)if((u=r(i))&&u.then){if(!$(u))return void u.then(n,o||(o=Y.bind(null,t=new Z,2)));u=u.v}t?Y(t,1,u):t=u}catch(e){Y(t||(t=new Z),2,e)}}(),t}(a,function(e){return r(a[e])})}(Object.entries(e.accounts),function(r){var n=r[0],o=r[1];function i(){t[n]=t[n]||o,t[n].role.proposer=t[n].role.proposer||o.role.proposer,t[n].role.payer=t[n].role.payer||o.role.payer,t[n].role.authorizer=t[n].role.authorizer||o.role.authorizer,e.proposer===u&&(e.proposer=n),e.payer===u&&(e.payer=n),e.authorizations=e.authorizations.map(function(e){return e===u?n:e})}var u=n,s=function(){if(ee(o.resolve))return Promise.resolve(o.resolve(o)).then(function(e){n=(o=e).tempId})}();return s&&s.then?s.then(i):i()});return o&&o.then?o.then(r):r()}}();return d&&d.then?d.then(o):o()}e=i;var c=function(){if(n(e)||t(e)){var i=function(){r(Q(u),"Cadence needs to be a string at this point."),e.message.cadence=u},u=o(e,"ix.cadence");r(ee(u)||Q(u),"Cadence needs to be a function or a string.");var s=function(){if(ee(u))return Promise.resolve(u({})).then(function(e){u=e})}();return s&&s.then?s.then(i):i()}}();return c&&c.then?c.then(u):u()})}catch(e){return Promise.reject(e)}});var ne,te,oe=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{var n=function(){return Promise.resolve(d(r)(e)).then(JSON.stringify)},t=function(){if(Array.isArray(e))return Promise.resolve(i(u(),e)).then(function(r){e=r})}();return Promise.resolve(t&&t.then?t.then(n):n())}catch(e){return Promise.reject(e)}},ie=function(e){try{return Promise.resolve(b([S(e)]).then(E))}catch(e){return Promise.reject(e)}},ue=function(e){return e.status>=4},se=function(e){return e.status>=3},ae=function(e){return e.status>=2},ce=((ne={})[m]=function(e){try{return Promise.resolve(ie(e.self())).then(function(r){ue(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},ne[h]=function(e,r){e.subscribe(r.from),e.send(r.from,p,e.all())},ne[v]=function(e,r){e.unsubscribe(r.from)},ne[y]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},ne.POLL=function(e){try{return Promise.resolve(ie(e.self())).then(function(r){var n,t;ue(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),n=e.all(),t=r,JSON.stringify(n)!==JSON.stringify(t)&&e.broadcast(p,r),e.merge(r)})}catch(e){return Promise.reject(e)}},ne),fe=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},le=function(e){return P(ce,fe(e))};function de(e){function r(r){return g(fe(e),le,r)}function n(e){return function(n){void 0===n&&(n={});var t=n.suppress||!1;return new Promise(function(n,o){var i=r(function(r){r.statusCode&&!t?(o(r.errorMessage),i()):e(r)&&(n(r),i())})})}}return{snapshot:function(){return w(e,le)},subscribe:r,onceFinalized:n(ae),onceExecuted:n(se),onceSealed:n(ue)}}de.isUnknown=function(e){return e.status>=0},de.isPending=function(e){return e.status>=1},de.isFinalized=ae,de.isExecuted=se,de.isSealed=ue,de.isExpired=function(e){return 5===e.status};var me=function(r){try{var n=setTimeout;return Promise.resolve(e().get("fcl.eventPollRate",1e4)).then(function(e){return n(function(){return r.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},he=((te={}).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(s()).then(function(r){n.call(e,"hwm",r);var t=e.put;return Promise.resolve(me(e)).then(function(r){t.call(e,"tick",r)})})}return Promise.resolve(s()).then(function(n){return e.put("hwm",n),Promise.resolve(b([getEvents(e.self(),r.height,n.height-1)]).then(E)).then(function(r){for(var n,t=A(r);!(n=t()).done;)e.broadcast("UPDATED",n.value.data);var o=e.put;return Promise.resolve(me(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)}},te[h]=function(e,r){try{var n=function(){e.subscribe(r.from)},t=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(me(e)).then(function(n){r.call(e,"tick",n)})}}();return Promise.resolve(t&&t.then?t.then(n):n())}catch(e){return Promise.reject(e)}},te[v]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},te),pe=function(e){return P(he,e)};function ve(e){return{subscribe:function(r){return g(e,pe,r)}}}function ye(e){if(!document.getElementById("FCL_IFRAME")){var r=document.createElement("iframe");return r.src=e,r.id="FCL_IFRAME",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.style.zIndex=2147483647,r.frameBorder="0",r.style.boxSizing="border-box",document.body.append(r),[r,function(){document.getElementById("FCL_IFRAME")&&document.getElementById("FCL_IFRAME").remove()}]}}var ge={"@type":"Service","@vsn":"1.0.0"},Pe={"@type":"Identity","@vsn":"1.0.0"},we={"@type":"USER","@vsn":"1.0.0"},ke={authn:function(e){switch(e["@vsn"]){case"1.0.0":return e;default:return x({},ge,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:c(e.addr),name:e.name,icon:e.icon}})}},authz:function(e){switch(e["@vsn"]){case"1.0.0":return e;default:return x({},ge,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:x({},Pe,{address:c(e.addr),keyId:e.keyId}),params:e.params,data:e.data})}},"pre-authz":function(e){switch(e["@vsn"]){case"1.0.0":return e;default:return x({},ge,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:x({},Pe,{address:c(e.addr),keyId:e.keyId}),params:e.params,data:e.data})}}};function be(e){return l([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}function Ee(e,r){return void 0===e&&(e=[]),e.find(function(e){return e.type===r})}function Se(e,r){void 0===r&&(r=!0);var n=new URL(e.endpoint);if(r)for(var t=0,o=Object.entries(e.params||{});t<o.length;t++){var i=o[t];n.searchParams.append(i[0],i[1])}return n}function Ie(e){return ye(Se(e).href)}var xe,Te={"HTTP/GET":"GET","HTTP/POST":"POST"},Ae=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},je=function(e,r){return"Missing "+Ae(e,r)+" in Composite Signature."},Le=function(e,r){return Ae(e,r)+" in Composit Signature did not match the requested "+e+"."},Ne={"HTTP/POST":function(e,r){try{var n=function(){},t=null;return Promise.resolve(function(e,r){try{var n=e()}catch(e){return r()}return n&&n.then?n.then(r,r):r()}(function(){return function(e,r){try{var n=e()}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(function(){return Promise.resolve(fetch(Se(e,!0),{method:"POST",headers:{"Content-Type":"application/json"},body:r?JSON.stringify(r):void 0}).then(function(e){return e.json()})).then(function(e){if(console.log("RESP",e),e.local&&e.local.length>0){var r=Ie(e.local[0]);n=r[1]}return Promise.resolve(function e(r){return new Promise(function(n,t){try{return Promise.resolve(fetch(Se(r),{method:Te[r.method],headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(r){"APPROVED"===r.status?n(r.compositeSignature):"DECLINED"===r.status?t({status:r.status,reason:r.reason}):setTimeout(function(){n(e(r.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){t=e})})},function(t){throw n(),Re(e,r,t),t})},function(){return n(),t}))}catch(e){return Promise.reject(e)}},"IFRAME/RPC":function(e,r){try{return Promise.resolve(new Promise(function(n,t){try{var o=I(),i=Ie(e),u=i[0],s=i[1],a=function(){u.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")};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(),n(u.compositeSignature)):"DECLINED"===u.status?(window.removeEventListener("message",e),s(),t({status:u.status,reason:u.reason})):(window.removeEventListener("message",e),s(),t({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"})),Promise.resolve()}catch(e){return Promise.reject(e)}}),new Promise(function(e){window.addEventListener("message",n);var r=setTimeout(function(){window.removeEventListener("message",n),a(),e()},5e3);function n(t){"FCL::AUTHZ_READY"===t.data.type&&(clearTimeout(r),window.removeEventListener("message",n),a(),e())}})}catch(n){Re(e,r,n),t({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function Re(e,r,n){console.error("["+e.method+"] Trouble talking to Wallet Provider","\n\n",{authz:e,signable:r},n)}function Ce(e,r,n){if(!e.s){if(n instanceof ze){if(!n.s)return void(n.o=Ce.bind(null,e,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(Ce.bind(null,e,r),Ce.bind(null,e,2));e.s=r,e.v=n;var t=e.o;t&&t(e)}}var Oe=function(e){try{return We(),Promise.resolve(De()).then(function(n){Ee(n.services,"authn");var t=Ee(n.services,"authz");return Ee(n.services,"pre-authz"),x({},e,{tempId:"CURRENT_USER",resolve:null,addr:a(t.identity.address),keyId:t.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(function(e,n){try{return Promise.resolve(Ne[e.method](e,n)).then(function(n){return null==n.sig&&(n.sig=n.signature),null==n.signature&&(n.signature=n.sig),n.addr=a(n.addr),function(e,n){try{var t={compSig:e,authz:n};r(e.addr,je("addr","Address"),t),r(e.keyId,je("keyId"),t),r(e.signature,je("signature"),t),r(e.keyId===n.identity.keyId,Le("keyId"),t),r(a(e.addr)===a(n.identity.address),Le("addr","Address"),t)}catch(e){throw new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+e.message)}}(n,e),n})}catch(e){return Promise.reject(e)}}(t,e))}catch(e){return Promise.reject(e)}}})})}catch(e){return Promise.reject(e)}},ze=function(){function e(){}return e.prototype.then=function(r,n){var t=new e,o=this.s;if(o){var i=1&o?r:n;if(i){try{Ce(t,1,i(this.v))}catch(e){Ce(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Ce(t,1,r?r(o):o):n?Ce(t,1,n(o)):Ce(t,2,o)}catch(e){Ce(t,2,e)}},t},e}();function Ue(e){return e instanceof ze&&1&e.s}var De=function(){try{return Promise.resolve(new Promise(function(r){try{return We(),Promise.resolve($e()).then(function(n){return n.loggedIn&&Xe(n)?r(n):Promise.resolve(e().get("challenge.handshake")).then(function(e){var n,t,o,i=(t=(n={handshake:e,l6n:window.location.origin}).l6n,(o=new URL(n.handshake)).searchParams.append("l6n",t),ye(o.href))[1];window.addEventListener("message",function e(n){var t=n.data;try{return t.type===Me||t.type===Je?(i(),window.removeEventListener("message",e),Promise.resolve()):t.type!==qe?Promise.resolve():(i(),window.removeEventListener("message",e),Promise.resolve(function(e){try{var r=(e=function(e){return e.addr=e.addr?c(e.addr):null,e.paddr=e.paddr?c(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,r){try{if(null==e||null==r)return Promise.resolve([]);var n=new URL(e);return n.searchParams.append("code",r),Promise.resolve(fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var r=[];if(Array.isArray(e.authorizations))for(var n,t=A(e.authorizations);!(n=t()).done;)r.push(x({type:"authz",keyId:e.keyId},n.value));return null!=e.provider&&r.push(x({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(n){var t,o,i=(t=r,o=n,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o)).map(function(r){return function(e,r){try{var n=ke[e.type](e,r);return console.log(e.type,{normalized:n,service:e}),n}catch(r){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,r),e}}(r,e)});console.log("BUILD USER",i);var u=function(e,r){return r.find(function(e){return"authn"===e.type})}(0,i);return x({},we,{addr:c(e.addr),cid:be(u),loggedIn:!0,services:i,expiresAt:e.exp})})}catch(e){return Promise.reject(e)}}(t)).then(function(e){return k(Be,_e,e),Promise.resolve($e()).then(function(e){r(e)})}))}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Be="CURRENT_USER",Fe="CURRENT_USER/UPDATED",_e="SET_CURRENT_USER",Je="FCL::CANCEL",qe="FCL::CHALLENGE::RESPONSE",Me="FCL::CHALLENGE::CANCEL",He='{\n "@type": "User",\n "@vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Ke=function(e){try{return sessionStorage.setItem(Be,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},Ge=function(){return e().get("persistSession",!0)},Ve=((xe={})[m]=function(e){try{return e.merge(JSON.parse(He)),Promise.resolve(Ge()).then(function(r){var n=function(){if(r)return Promise.resolve(function(){try{var e=JSON.parse(He),r=JSON.parse(sessionStorage.getItem(Be));return null!=r&&e["@vsn"]!==r["@vsn"]?(sessionStorage.removeItem(Be),Promise.resolve(e)):Promise.resolve(r||e)}catch(e){return Promise.reject(e)}}()).then(function(r){Xe(r)&&e.merge(r)})}();if(n&&n.then)return n.then(function(){})})}catch(e){return Promise.reject(e)}},xe[h]=function(e,r){e.subscribe(r.from),e.send(r.from,Fe,x({},e.all()))},xe[v]=function(e,r){e.unsubscribe(r.from)},xe.SNAPSHOT=function(e,r){try{return r.reply(x({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},xe[_e]=function(e,r,n){try{return e.merge(n),Promise.resolve(Ge()).then(function(r){r&&Ke(e.all()),e.broadcast(Fe,x({},e.all()))})}catch(e){return Promise.reject(e)}},xe.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(He)),Promise.resolve(Ge()).then(function(r){r&&Ke(e.all()),e.broadcast(Fe,x({},e.all()))})}catch(e){return Promise.reject(e)}},xe),We=function(){return P(Ve,Be)};function Xe(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()}function Ye(){We(),k(Be,"DEL_CURRENT_USER")}function Ze(e){We();var r=P(function(r){try{var n;return r.send(Be,h),Promise.resolve(function(e,r,n){for(var t;;){var o=e();if(Ue(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=n();if(i&&i.then){if(!Ue(i)){t=1;break}i=i.s}}var u=new ze,s=Ce.bind(null,u,2);return(0===t?o.then(c):1===t?i.then(a):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):Ce(u,1,i)})).then(void 0,s),u;function a(r){i=r;do{if(!(o=e())||Ue(o)&&!o.v)return void Ce(u,1,i);if(o.then)return void o.then(c).then(void 0,s);Ue(i=n())&&(i=i.v)}while(!i||!i.then);i.then(a).then(void 0,s)}function c(e){e?(i=n())&&i.then?i.then(a).then(void 0,s):a(i):Ce(u,1,i)}}(function(){return!n&&1},0,function(){return Promise.resolve(r.receive()).then(function(t){if("@EXIT"===t.tag)return r.send(Be,v),void(n=1);e(t.data)})}))}catch(e){return Promise.reject(e)}});return function(){return k(r,"@EXIT")}}function $e(){return We(),k(Be,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Qe=function(){return{authenticate:De,unauthenticate:Ye,authorization:Oe,subscribe:Ze,snapshot:$e}},er=function(){return Qe().authenticate()},rr=function(){return Qe().unauthenticate()},nr=function(){Qe().unauthenticate(),Qe().authenticate()},tr=function(){return Qe().authenticate()},or=function(){return Qe().authenticate()},ir=Qe().authorization,ur="0.0.67-alpha.2";export{ur as VERSION,er as authenticate,ir as authz,Qe as currentUser,ve as events,or as logIn,nr as reauthenticate,oe as serialize,tr as signUp,de as tx,rr as unauthenticate};
//# sourceMappingURL=fcl.module.js.map

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@onflow/config"),require("@onflow/interaction"),require("@onflow/sdk-resolve"),require("@onflow/util-actor"),require("@onflow/sdk-send"),require("@onflow/sdk-decode"),require("@onflow/sdk-build-transaction-status"),require("@onflow/sdk-latest-block"),require("@onflow/sdk-build-get-events"),require("@onflow/sdk-account"),require("@onflow/util-address"),require("@onflow/util-uid"),require("@onflow/util-template"),require("@onflow/sdk-build-transaction"),require("@onflow/sdk-build-script"),require("@onflow/sdk-build-ping"),require("@onflow/sdk-build-get-account"),require("@onflow/sdk-build-get-latest-block"),require("@onflow/sdk-build-get-block-by-id"),require("@onflow/sdk-build-get-block-by-height"),require("@onflow/sdk-build-authorizations"),require("@onflow/sdk-build-arguments"),require("@onflow/sdk-build-proposer"),require("@onflow/sdk-build-payer"),require("@onflow/sdk-build-limit"),require("@onflow/sdk-build-ref"),require("@onflow/sdk-build-params")):"function"==typeof define&&define.amd?define(["exports","@onflow/config","@onflow/interaction","@onflow/sdk-resolve","@onflow/util-actor","@onflow/sdk-send","@onflow/sdk-decode","@onflow/sdk-build-transaction-status","@onflow/sdk-latest-block","@onflow/sdk-build-get-events","@onflow/sdk-account","@onflow/util-address","@onflow/util-uid","@onflow/util-template","@onflow/sdk-build-transaction","@onflow/sdk-build-script","@onflow/sdk-build-ping","@onflow/sdk-build-get-account","@onflow/sdk-build-get-latest-block","@onflow/sdk-build-get-block-by-id","@onflow/sdk-build-get-block-by-height","@onflow/sdk-build-authorizations","@onflow/sdk-build-arguments","@onflow/sdk-build-proposer","@onflow/sdk-build-payer","@onflow/sdk-build-limit","@onflow/sdk-build-ref","@onflow/sdk-build-params"],t):t((e=e||self).fcl={},e.config,e.interaction,e.sdkResolve,e.utilActor,e.sdkSend,e.sdkDecode,e.sdkBuildTransactionStatus,e.sdkLatestBlock,e.sdkBuildGetEvents,e.sdkAccount,e.utilAddress,e.utilUid,e.utilTemplate,e.sdkBuildTransaction,e.sdkBuildScript,e.sdkBuildPing,e.sdkBuildGetAccount,e.sdkBuildGetLatestBlock,e.sdkBuildGetBlockById,e.sdkBuildGetBlockByHeight,e.sdkBuildAuthorizations,e.sdkBuildArguments,e.sdkBuildProposer,e.sdkBuildPayer,e.sdkBuildLimit,e.sdkBuildRef,e.sdkBuildParams)}(this,function(e,t,r,n,o,i,u,s,c,a,l,f,d,m,h,v,p,b,g,P,y,w,k,E,S,j,O,I){t.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var B,T,R=function(e){try{return Promise.resolve(i.send([s.getTransactionStatus(e)]).then(u.decode))}catch(e){return Promise.reject(e)}},A=function(e){return e.status>=4},L=function(e){return e.status>=3},C=function(e){return e.status>=2},N=((B={})[o.INIT]=function(e){try{return Promise.resolve(R(e.self())).then(function(t){A(t)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(t)})}catch(e){return Promise.reject(e)}},B[o.SUBSCRIBE]=function(e,t){e.subscribe(t.from),e.send(t.from,o.UPDATED,e.all())},B[o.UNSUBSCRIBE]=function(e,t){e.unsubscribe(t.from)},B[o.SNAPSHOT]=function(e,t){try{return t.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},B.POLL=function(e){try{return Promise.resolve(R(e.self())).then(function(t){var r,n;A(t)||setTimeout(function(){return e.sendSelf("POLL")},2500),r=e.all(),n=t,JSON.stringify(r)!==JSON.stringify(n)&&e.broadcast(o.UPDATED,t),e.merge(t)})}catch(e){return Promise.reject(e)}},B),U=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},q=function(e){return o.spawn(N,U(e))};function x(e){function t(t){return o.subscriber(U(e),q,t)}function r(e){return function(r){void 0===r&&(r={});var n=r.suppress||!1;return new Promise(function(r,o){var i=t(function(t){t.statusCode&&!n?(o(t.errorMessage),i()):e(t)&&(r(t),i())})})}}return{snapshot:function(){return o.snapshoter(e,q)},subscribe:t,onceFinalized:r(C),onceExecuted:r(L),onceSealed:r(A)}}function D(){return(D=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function F(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return z(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?z(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}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)}x.isUnknown=function(e){return e.status>=0},x.isPending=function(e){return e.status>=1},x.isFinalized=C,x.isExecuted=L,x.isSealed=A,x.isExpired=function(e){return 5===e.status};var _=function(e){try{var r=setTimeout;return Promise.resolve(t.config().get("fcl.eventPollRate",1e4)).then(function(t){return r(function(){return e.sendSelf("TICK")},t)})}catch(e){return Promise.reject(e)}},H=((T={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var t=e.get("hwm"),r=function(){if(null==t){var r=e.put;return Promise.resolve(c.latestBlock()).then(function(t){r.call(e,"hwm",t);var n=e.put;return Promise.resolve(_(e)).then(function(t){n.call(e,"tick",t)})})}return Promise.resolve(c.latestBlock()).then(function(r){return e.put("hwm",r),Promise.resolve(i.send([getEvents(e.self(),t.height,r.height-1)]).then(u.decode)).then(function(t){for(var r,n=F(t);!(r=n()).done;)e.broadcast("UPDATED",r.value.data);var o=e.put;return Promise.resolve(_(e)).then(function(t){o.call(e,"tick",t)})})})}();return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},T[o.SUBSCRIBE]=function(e,t){try{var r=function(){e.subscribe(t.from)},n=function(){if(!e.hasSubs()){var t=e.put;return Promise.resolve(_(e)).then(function(r){t.call(e,"tick",r)})}}();return Promise.resolve(n&&n.then?n.then(r):r())}catch(e){return Promise.reject(e)}},T[o.UNSUBSCRIBE]=function(e,t){e.unsubscribe(t.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},T),J=function(e){return o.spawn(H,e)};function G(e){if(!document.getElementById("FCL_IFRAME")){var t=document.createElement("iframe");return t.src=e,t.id="FCL_IFRAME",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.style.zIndex=2147483647,t.frameBorder="0",t.style.boxSizing="border-box",document.body.append(t),[t,function(){document.getElementById("FCL_IFRAME")&&document.getElementById("FCL_IFRAME").remove()}]}}function M(e){return"cid:"+(e.addr||e.name)+":"+e.pid}function V(e,t){void 0===t&&(t=!0);var r=new URL(e.endpoint);if(t)for(var n=0,o=Object.entries(e.params||{});n<o.length;n++){var i=o[n];r.searchParams.append(i[0],i[1])}return r}function W(e){return G(V(e).href)}var K,X={"HTTP/GET":"GET","HTTP/POST":"POST"},Y=function(e,t){return null==t?"'"+e+"'":"'"+e+"' ("+t+")"},Z=function(e,t){return"Missing "+Y(e,t)+" in Composite Signature."},$=function(e,t){return Y(e,t)+" in Composit Signature did not match the requested "+e+"."},Q={"HTTP/POST":function(e,t){try{var r=function(){},n=null;return Promise.resolve(function(e,t){try{var r=e()}catch(e){return t()}return r&&r.then?r.then(t,t):t()}(function(){return function(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(function(){return Promise.resolve(fetch(V(e),{method:"POST",headers:{"Content-Type":"application/json"},body:t?JSON.stringify(t):void 0}).then(function(e){return e.json()})).then(function(e){if(e.local&&e.local.length>0){var t=W(e.local[0]);r=t[1]}return Promise.resolve(function e(t){return new Promise(function(r,n){try{return Promise.resolve(fetch(V(t),{method:X[t.method],headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(t){"APPROVED"===t.status?r(t.compositeSignature):"DECLINED"===t.status?n({status:t.status,reason:t.reason}):setTimeout(function(){r(e(t.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){n=e})})},function(n){throw r(),ee(e,t,n),n})},function(){return r(),n}))}catch(e){return Promise.reject(e)}},"IFRAME/RPC":function(e,t){try{return Promise.resolve(new Promise(function(r,n){try{var o=d.uid(),i=W(e),u=i[0],s=i[1],c=function(){u.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params]})),"*")};window.addEventListener("message",function e(t){var i=t.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(),r(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)}}),new Promise(function(e){window.addEventListener("message",r);var t=setTimeout(function(){window.removeEventListener("message",r),c(),e()},5e3);function r(n){"FCL::AUTHZ_READY"===n.data.type&&(clearTimeout(t),window.removeEventListener("message",r),c(),e())}})}catch(r){ee(e,t,r),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function ee(e,t,r){console.error("["+e.method+"] Trouble talking to Wallet Provider","\n\n",{authz:e,signable:t},r)}function te(e,t,r){if(!e.s){if(r instanceof ne){if(!r.s)return void(r.o=te.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(te.bind(null,e,t),te.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var re=function(e){try{return ve(),Promise.resolve(ie()).then(function(t){function r(){return D({},e,{addr:f.sansPrefix(i.addr),keyId:i.keyId,sequenceNum:o,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(function(e,t){try{return Promise.resolve(Q[e.method](e,t)).then(function(t){return null==t.sig&&(t.sig=t.signature),null==t.signature&&(t.signature=t.sig),t.addr=f.sansPrefix(t.addr),function(e,t){try{if(null==e.addr)throw new Error(Z("addr","Address"));if(null==e.keyId)throw new Error(Z("keyId"));if(null==e.signature)throw new Error(Z("signature"));if(f.sansPrefix(e.addr)!==f.sansPrefix(t.addr))throw new Error($("addr","Address"));if(e.keyId!==t.keyId)throw new Error($("keyId"))}catch(r){throw console.error(r,"\n\n",{"Composite Signature":e,"Authz Service":t}),new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+r.message)}}(t,e),t})}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=t.services)&&(n=[]),n.find(function(e){return"authz"===e.type})),u=function(){if(e.role.proposer)return Promise.resolve(function(){try{return ve(),Promise.resolve(ge()).then(function(e){var t=e.addr;if(null==t)throw new Error("No Flow Address for Current User");return l.account(t)})}catch(e){return Promise.reject(e)}}()).then(function(e){var t=e.keys.find(function(e){return e.index===i.keyId});o=t.sequenceNumber})}();return u&&u.then?u.then(r):r()})}catch(e){return Promise.reject(e)}},ne=function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var i=1&o?t:r;if(i){try{te(n,1,i(this.v))}catch(e){te(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?te(n,1,t?t(o):o):r?te(n,1,r(o)):te(n,2,o)}catch(e){te(n,2,e)}},n},e}();function oe(e){return e instanceof ne&&1&e.s}var ie=function(){try{return Promise.resolve(new Promise(function(e){try{return ve(),Promise.resolve(ge()).then(function(r){return r.loggedIn?e(r):Promise.resolve(t.config().get("challenge.handshake")).then(function(t){var r,n,i,u=(n=(r={handshake:t,l6n:window.location.origin}).l6n,(i=new URL(r.handshake)).searchParams.append("l6n",n),G(i.href))[1];window.addEventListener("message",function t(r){var n=r.data;try{return n.type===le?(u(),window.removeEventListener("message",t),Promise.resolve()):n.type!==ae?Promise.resolve():(u(),window.removeEventListener("message",t),Promise.resolve(function(e){try{var t=e.services||[];return Promise.resolve(function(e,t){try{if(null==e||null==t)return Promise.resolve([]);var r=new URL(e);return r.searchParams.append("code",t),Promise.resolve(fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var t=[];if(Array.isArray(e.authorizations))for(var r,n=F(e.authorizations);!(r=n()).done;)t.push(D({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&t.push(D({type:"authn",id:"wallet-provider#authn"},e.provider)),t})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(r){var n,o,i=(void 0===(n=t)&&(n=[]),void 0===(o=r)&&(o=[]),[].concat(n,o)),u=i.find(function(e){return"authn"===e.type});return console.log("RAWR",{data:e,services:i,authn:u}),{addr:e.addr?f.withPrefix(e.addr):null,cid:M(u),loggedIn:!0,services:i}})}catch(e){return Promise.reject(e)}}(n)).then(function(t){return o.send(ue,ce,t),Promise.resolve(ge()).then(function(t){e(t)})}))}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},ue="CURRENT_USER",se="CURRENT_USER/UPDATED",ce="SET_CURRENT_USER",ae="FCL::CHALLENGE::RESPONSE",le="FCL::CHALLENGE::CANCEL",fe='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',de=function(e){try{return sessionStorage.setItem(ue,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},me=function(){return t.config().get("persistSession",!0)},he=((K={})[o.INIT]=function(e){try{return e.merge(JSON.parse(fe)),Promise.resolve(me()).then(function(t){var r=function(){if(t){var r=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(fe),t=JSON.parse(sessionStorage.getItem(ue));return null!=t&&e.VERSION!==t.VERSION?(sessionStorage.removeItem(ue),Promise.resolve(e)):Promise.resolve(t||e)}catch(e){return Promise.reject(e)}}()).then(function(t){r.call(e,t)})}}();if(r&&r.then)return r.then(function(){})})}catch(e){return Promise.reject(e)}},K[o.SUBSCRIBE]=function(e,t){e.subscribe(t.from),e.send(t.from,se,D({},e.all()))},K[o.UNSUBSCRIBE]=function(e,t){e.unsubscribe(t.from)},K.SNAPSHOT=function(e,t){try{return t.reply(D({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},K[ce]=function(e,t,r){try{return e.merge(r),Promise.resolve(me()).then(function(t){t&&de(e.all()),e.broadcast(se,D({},e.all()))})}catch(e){return Promise.reject(e)}},K.DEL_CURRENT_USER=function(e,t){try{return e.merge(JSON.parse(fe)),Promise.resolve(me()).then(function(t){t&&de(e.all()),e.broadcast(se,D({},e.all()))})}catch(e){return Promise.reject(e)}},K),ve=function(){return o.spawn(he,ue)};function pe(){ve(),o.send(ue,"DEL_CURRENT_USER")}function be(e){ve();var t=o.spawn(function(t){try{var r;return t.send(ue,o.SUBSCRIBE),Promise.resolve(function(e,t,r){for(var n;;){var o=e();if(oe(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(!oe(i)){n=1;break}i=i.s}}var u=new ne,s=te.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):te(u,1,i)})).then(void 0,s),u;function c(t){i=t;do{if(!(o=e())||oe(o)&&!o.v)return void te(u,1,i);if(o.then)return void o.then(a).then(void 0,s);oe(i=r())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,s)}function a(e){e?(i=r())&&i.then?i.then(c).then(void 0,s):c(i):te(u,1,i)}}(function(){return!r&&1},0,function(){return Promise.resolve(t.receive()).then(function(n){if("@EXIT"===n.tag)return t.send(ue,o.UNSUBSCRIBE),void(r=1);e(n.data)})}))}catch(e){return Promise.reject(e)}});return function(){return o.send(t,"@EXIT")}}function ge(){return ve(),o.send(ue,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Pe=function(){return{authenticate:ie,unauthenticate:pe,authorization:re,subscribe:be,snapshot:ge}},ye=Pe().authorization;Object.defineProperty(e,"config",{enumerable:!0,get:function(){return t.config}}),Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return r.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return r.isOk}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return r.pipe}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return r.why}}),Object.defineProperty(e,"send",{enumerable:!0,get:function(){return i.send}}),Object.defineProperty(e,"decode",{enumerable:!0,get:function(){return u.decode}}),Object.defineProperty(e,"getTransactionStatus",{enumerable:!0,get:function(){return s.getTransactionStatus}}),Object.defineProperty(e,"latestBlock",{enumerable:!0,get:function(){return c.latestBlock}}),Object.defineProperty(e,"getEvents",{enumerable:!0,get:function(){return a.getEvents}}),Object.defineProperty(e,"account",{enumerable:!0,get:function(){return l.account}}),Object.defineProperty(e,"display",{enumerable:!0,get:function(){return f.display}}),Object.defineProperty(e,"sansPrefix",{enumerable:!0,get:function(){return f.sansPrefix}}),Object.defineProperty(e,"withPrefix",{enumerable:!0,get:function(){return f.withPrefix}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return m.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return m.template}}),Object.defineProperty(e,"transaction",{enumerable:!0,get:function(){return h.transaction}}),Object.defineProperty(e,"script",{enumerable:!0,get:function(){return v.script}}),Object.defineProperty(e,"ping",{enumerable:!0,get:function(){return p.ping}}),Object.defineProperty(e,"getAccount",{enumerable:!0,get:function(){return b.getAccount}}),Object.defineProperty(e,"getLatestBlock",{enumerable:!0,get:function(){return g.getLatestBlock}}),Object.defineProperty(e,"getBlockById",{enumerable:!0,get:function(){return P.getBlockById}}),Object.defineProperty(e,"getBlockByHeight",{enumerable:!0,get:function(){return y.getBlockByHeight}}),Object.defineProperty(e,"authorization",{enumerable:!0,get:function(){return w.authorization}}),Object.defineProperty(e,"authorizations",{enumerable:!0,get:function(){return w.authorizations}}),Object.defineProperty(e,"arg",{enumerable:!0,get:function(){return k.arg}}),Object.defineProperty(e,"args",{enumerable:!0,get:function(){return k.args}}),Object.defineProperty(e,"proposer",{enumerable:!0,get:function(){return E.proposer}}),Object.defineProperty(e,"payer",{enumerable:!0,get:function(){return S.payer}}),Object.defineProperty(e,"limit",{enumerable:!0,get:function(){return j.limit}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return O.ref}}),Object.defineProperty(e,"param",{enumerable:!0,get:function(){return I.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return I.params}}),e.VERSION="0.0.67-alpha.1",e.authenticate=function(){return Pe().authenticate()},e.authz=ye,e.currentUser=Pe,e.events=function(e){return{subscribe:function(t){return o.subscriber(e,J,t)}}},e.logIn=function(){return Pe().authenticate()},e.reauthenticate=function(){Pe().unauthenticate(),Pe().authenticate()},e.serialize=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});try{var o=function(){return Promise.resolve(n.resolve(t)(e)).then(JSON.stringify)},i=function(){if(Array.isArray(e))return Promise.resolve(r.pipe(r.interaction(),e)).then(function(t){e=t})}();return Promise.resolve(i&&i.then?i.then(o):o())}catch(e){return Promise.reject(e)}},e.signUp=function(){return Pe().authenticate()},e.tx=x,e.unauthenticate=function(){return Pe().unauthenticate()}});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/config"),require("@onflow/util-invariant"),require("@onflow/interaction"),require("@onflow/sdk-latest-block"),require("@onflow/util-address"),require("@onflow/sdk-account"),require("@onflow/rlp"),require("@onflow/sdk-resolve"),require("@onflow/util-actor"),require("@onflow/sdk-send"),require("@onflow/sdk-decode"),require("@onflow/sdk-build-transaction-status"),require("@onflow/sdk-build-get-events"),require("@onflow/util-uid"),require("@onflow/util-template"),require("@onflow/sdk-build-transaction"),require("@onflow/sdk-build-script"),require("@onflow/sdk-build-ping"),require("@onflow/sdk-build-get-account"),require("@onflow/sdk-build-get-latest-block"),require("@onflow/sdk-build-get-block-by-id"),require("@onflow/sdk-build-get-block-by-height"),require("@onflow/sdk-build-authorizations"),require("@onflow/sdk-build-arguments"),require("@onflow/sdk-build-proposer"),require("@onflow/sdk-build-payer"),require("@onflow/sdk-build-limit"),require("@onflow/sdk-build-ref"),require("@onflow/sdk-build-params")):"function"==typeof define&&define.amd?define(["exports","@onflow/config","@onflow/util-invariant","@onflow/interaction","@onflow/sdk-latest-block","@onflow/util-address","@onflow/sdk-account","@onflow/rlp","@onflow/sdk-resolve","@onflow/util-actor","@onflow/sdk-send","@onflow/sdk-decode","@onflow/sdk-build-transaction-status","@onflow/sdk-build-get-events","@onflow/util-uid","@onflow/util-template","@onflow/sdk-build-transaction","@onflow/sdk-build-script","@onflow/sdk-build-ping","@onflow/sdk-build-get-account","@onflow/sdk-build-get-latest-block","@onflow/sdk-build-get-block-by-id","@onflow/sdk-build-get-block-by-height","@onflow/sdk-build-authorizations","@onflow/sdk-build-arguments","@onflow/sdk-build-proposer","@onflow/sdk-build-payer","@onflow/sdk-build-limit","@onflow/sdk-build-ref","@onflow/sdk-build-params"],n):n((e=e||self).fcl={},e.config,e.utilInvariant,e.interaction,e.sdkLatestBlock,e.utilAddress,e.sdkAccount,e.rlp,e.sdkResolve,e.utilActor,e.sdkSend,e.sdkDecode,e.sdkBuildTransactionStatus,e.sdkBuildGetEvents,e.utilUid,e.utilTemplate,e.sdkBuildTransaction,e.sdkBuildScript,e.sdkBuildPing,e.sdkBuildGetAccount,e.sdkBuildGetLatestBlock,e.sdkBuildGetBlockById,e.sdkBuildGetBlockByHeight,e.sdkBuildAuthorizations,e.sdkBuildArguments,e.sdkBuildProposer,e.sdkBuildPayer,e.sdkBuildLimit,e.sdkBuildRef,e.sdkBuildParams)}(this,function(e,n,t,r,o,i,u,s,a,c,f,l,d,h,m,p,v,y,g,b,P,k,w,S,E,I,j,O,B,T){function x(){return(x=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function A(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function R(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return A(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(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?A(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}n.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var L=function(e,n){return Buffer.from(e.padStart(2*n,0),"hex")},N=function(e){return L(e,8)},C=function(e){return Buffer.from(JSON.stringify(e),"utf8")},U=function(e){return s.encode(e).toString("hex")},q=function(e){return F(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(C),(n=e.refBlock,L(n,32)),e.gasLimit,N(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,N(e.payer),e.authorizers.map(N)];var n,t},z=function(e){var n=D(e);return e.payloadSigs.map(function(e){return{signerIndex:n.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(n=e.sig,Buffer.from(n,"hex"))];var n})},D=function(e){var n=new Map,t=0,r=function(e){n.has(e)||(n.set(e,t),t++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),n},F=function(e){M.forEach(function(n){return X(e,n)}),K.forEach(function(n){return X(e.proposalKey,n,"proposalKey")})},_=function(e){return"number"==typeof e},G=function(e){return"string"==typeof e},H=function(e){return null!==e&&"object"==typeof e},J=function(e){return H(e)&&e instanceof Array},M=[{name:"script",check:G},{name:"arguments",check:J},{name:"refBlock",check:G,defaultVal:"0"},{name:"gasLimit",check:_},{name:"proposalKey",check:H},{name:"payer",check:G},{name:"authorizers",check:J}],K=[{name:"address",check:G},{name:"keyId",check:_},{name:"sequenceNum",check:_}],V=[{name:"payloadSigs",check:J}],W=[{name:"address",check:G},{name:"keyId",check:_},{name:"sig",check:G}],X=function(e,n,t,r){var o=n.name,i=n.check,u=n.defaultVal;if(null==e[o]&&null!=u&&(e[o]=u),null==e[o])throw Z(o,t,r);if(!i(e[o]))throw $(o,t,r)},Y=function(e,n,t){return n?null==t?n+"."+e:n+"."+t+"."+e:e},Z=function(e,n,t){return new Error("Missing field "+Y(e,n,t))},$=function(e,n,t){return new Error("Invalid field "+Y(e,n,t))},Q="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function ee(e,n,t){if(!e.s){if(t instanceof ne){if(!t.s)return void(t.o=ee.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(ee.bind(null,e,n),ee.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var ne=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{ee(r,1,i(this.v))}catch(e){ee(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?ee(r,1,n?n(o):o):t?ee(r,1,t(o)):ee(r,2,o)}catch(e){ee(r,2,e)}},r},e}();function te(e){return e instanceof ne&&1&e.s}var re=function(e){return"string"==typeof e},oe=function(e){return"function"==typeof e};function ie(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:i.sansPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:i.sansPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return i.sansPrefix(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}n.config().put("sdk.resolve",function(e){try{return Promise.resolve(e).then(function(n){function s(){function n(){function n(){function n(){var n=function(){if(r.isTransaction(e)){console.log("RESOLVE SIGNATURES START",e);var n=new Set(e.authorizations);n.add(e.proposer),n.delete(e.payer),n=Array.from(n);var t=new Set([e.payer]);t=Array.from(t),console.log("SIGNATORIES",{insideSigners:n,outsideSigners:t});var o=(u=ie(e),U(q(u)));return Promise.resolve(Promise.all(n.map(function(n){try{var t=e.accounts[n];return null!=t.signature?Promise.resolve():Promise.resolve(t.signingFunction({message:o,addr:i.sansPrefix(t.addr),keyId:t.keyId,roles:t.role,interaction:e})).then(function(t){e.accounts[n].signature=t.signature})}catch(e){return Promise.reject(e)}}))).then(function(){var r=function(e){return U(function(e){return function(e){V.forEach(function(n){return X(e,n)}),e.payloadSigs.forEach(function(e,n){W.forEach(function(t){return X(e,t,"payloadSigs",n)})})}(e),[q(e),z(e)]}(e))}(x({},ie(e),{payloadSigs:n.map(function(n){return e.accounts[n].signature})}));return Promise.resolve(Promise.all(t.map(function(n){try{var t=e.accounts[n];return null!=t.signature?Promise.resolve():Promise.resolve(t.signingFunction({message:r,addr:i.sansPrefix(t.addr),keyId:t.keyId,roles:t.role,interaction:e})).then(function(t){e.accounts[n].signature=t.signature})}catch(e){return Promise.reject(e)}}))).then(function(){console.log("RESOLVE SIGNATURES END",e)})})}var u}();return n&&n.then?n.then(function(){return e}):e}var o=function(){if(r.isTransaction(e)){var n=Object.values(e.accounts).find(function(e){return e.role.proposer});t.invariant(n,"Transactions require a proposer");var o=function(){if(null===n.sequenceNum)return Promise.resolve(u.account(n.addr).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===n.keyId})}).then(function(e){return e.sequenceNumber})).then(function(t){e.accounts[n.tempId].sequenceNum=t})}();if(o&&o.then)return o.then(function(){})}}();return o&&o.then?o.then(n):n()}r.isTransaction(e);var s=function(){if(r.isTransaction(e)&&null==e.message.refBlock)return Promise.resolve(o.latestBlock()).then(function(n){e.message.refBlock=n.id})}();return s&&s.then?s.then(n):n()}if(r.isTransaction(e)||r.isScript(e))for(var s=0,a=Object.entries(e.arguments);s<a.length;s++){var c=a[s];e.arguments[c[0]].asArgument=(t.invariant(null!=typeof(f=c[1]).xform,"No type specified for argument: "+f.value),oe(f.xform)?f.xform(f.value):oe(f.xform.asArgument)?f.xform.asArgument(f.value):void t.invariant(!1,"Invalid Argument",f))}var f,l=function(){if(r.isTransaction(e)){var n=function(){e.accounts=t},t={},o=function(e,n,t){if("function"==typeof e[Q]){var r,o,i,u=e[Q]();if(function e(t){try{for(;!(r=u.next()).done;)if((t=n(r.value))&&t.then){if(!te(t))return void t.then(e,i||(i=ee.bind(null,o=new ne,2)));t=t.v}o?ee(o,1,t):o=t}catch(e){ee(o||(o=new ne),2,e)}}(),u.return){var s=function(e){try{r.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(s,function(e){throw s(e)});s()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],c=0;c<e.length;c++)a.push(e[c]);return function(e,n,t){var r,o,i=-1;return function t(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!te(u))return void u.then(t,o||(o=ee.bind(null,r=new ne,2)));u=u.v}r?ee(r,1,u):r=u}catch(e){ee(r||(r=new ne),2,e)}}(),r}(a,function(e){return n(a[e])})}(Object.entries(e.accounts),function(n){var r=n[0],o=n[1];function i(){t[r]=t[r]||o,t[r].role.proposer=t[r].role.proposer||o.role.proposer,t[r].role.payer=t[r].role.payer||o.role.payer,t[r].role.authorizer=t[r].role.authorizer||o.role.authorizer,e.proposer===u&&(e.proposer=r),e.payer===u&&(e.payer=r),e.authorizations=e.authorizations.map(function(e){return e===u?r:e})}var u=r,s=function(){if(oe(o.resolve))return Promise.resolve(o.resolve(o)).then(function(e){r=(o=e).tempId})}();return s&&s.then?s.then(i):i()});return o&&o.then?o.then(n):n()}}();return l&&l.then?l.then(n):n()}e=n;var a=function(){if(r.isTransaction(e)||r.isScript(e)){var n=function(){t.invariant(re(o),"Cadence needs to be a string at this point."),e.message.cadence=o},o=r.get(e,"ix.cadence");t.invariant(oe(o)||re(o),"Cadence needs to be a function or a string.");var i=function(){if(oe(o))return Promise.resolve(o({})).then(function(e){o=e})}();return i&&i.then?i.then(n):n()}}();return a&&a.then?a.then(s):s()})}catch(e){return Promise.reject(e)}});var ue,se,ae=function(e){try{return Promise.resolve(f.send([d.getTransactionStatus(e)]).then(l.decode))}catch(e){return Promise.reject(e)}},ce=function(e){return e.status>=4},fe=function(e){return e.status>=3},le=function(e){return e.status>=2},de=((ue={})[c.INIT]=function(e){try{return Promise.resolve(ae(e.self())).then(function(n){ce(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},ue[c.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,c.UPDATED,e.all())},ue[c.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},ue[c.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},ue.POLL=function(e){try{return Promise.resolve(ae(e.self())).then(function(n){var t,r;ce(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),t=e.all(),r=n,JSON.stringify(t)!==JSON.stringify(r)&&e.broadcast(c.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},ue),he=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},me=function(e){return c.spawn(de,he(e))};function pe(e){function n(n){return c.subscriber(he(e),me,n)}function t(e){return function(t){void 0===t&&(t={});var r=t.suppress||!1;return new Promise(function(t,o){var i=n(function(n){n.statusCode&&!r?(o(n.errorMessage),i()):e(n)&&(t(n),i())})})}}return{snapshot:function(){return c.snapshoter(e,me)},subscribe:n,onceFinalized:t(le),onceExecuted:t(fe),onceSealed:t(ce)}}pe.isUnknown=function(e){return e.status>=0},pe.isPending=function(e){return e.status>=1},pe.isFinalized=le,pe.isExecuted=fe,pe.isSealed=ce,pe.isExpired=function(e){return 5===e.status};var ve=function(e){try{var t=setTimeout;return Promise.resolve(n.config().get("fcl.eventPollRate",1e4)).then(function(n){return t(function(){return e.sendSelf("TICK")},n)})}catch(e){return Promise.reject(e)}},ye=((se={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var n=e.get("hwm"),t=function(){if(null==n){var t=e.put;return Promise.resolve(o.latestBlock()).then(function(n){t.call(e,"hwm",n);var r=e.put;return Promise.resolve(ve(e)).then(function(n){r.call(e,"tick",n)})})}return Promise.resolve(o.latestBlock()).then(function(t){return e.put("hwm",t),Promise.resolve(f.send([getEvents(e.self(),n.height,t.height-1)]).then(l.decode)).then(function(n){for(var t,r=R(n);!(t=r()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(ve(e)).then(function(n){o.call(e,"tick",n)})})})}();return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},se[c.SUBSCRIBE]=function(e,n){try{var t=function(){e.subscribe(n.from)},r=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(ve(e)).then(function(t){n.call(e,"tick",t)})}}();return Promise.resolve(r&&r.then?r.then(t):t())}catch(e){return Promise.reject(e)}},se[c.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},se),ge=function(e){return c.spawn(ye,e)};function be(e){if(!document.getElementById("FCL_IFRAME")){var n=document.createElement("iframe");return n.src=e,n.id="FCL_IFRAME",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.style.zIndex=2147483647,n.frameBorder="0",n.style.boxSizing="border-box",document.body.append(n),[n,function(){document.getElementById("FCL_IFRAME")&&document.getElementById("FCL_IFRAME").remove()}]}}var Pe={"@type":"Service","@vsn":"1.0.0"},ke={"@type":"Identity","@vsn":"1.0.0"},we={"@type":"USER","@vsn":"1.0.0"},Se={authn:function(e){switch(e["@vsn"]){case"1.0.0":return e;default:return x({},Pe,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:i.withPrefix(e.addr),name:e.name,icon:e.icon}})}},authz:function(e){switch(e["@vsn"]){case"1.0.0":return e;default:return x({},Pe,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:x({},ke,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})}},"pre-authz":function(e){switch(e["@vsn"]){case"1.0.0":return e;default:return x({},Pe,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:x({},ke,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})}}};function Ee(e){return s.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}function Ie(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function je(e,n){void 0===n&&(n=!0);var t=new URL(e.endpoint);if(n)for(var r=0,o=Object.entries(e.params||{});r<o.length;r++){var i=o[r];t.searchParams.append(i[0],i[1])}return t}function Oe(e){return be(je(e).href)}var Be,Te={"HTTP/GET":"GET","HTTP/POST":"POST"},xe=function(e,n){return null==n?"'"+e+"'":"'"+e+"' ("+n+")"},Ae=function(e,n){return"Missing "+xe(e,n)+" in Composite Signature."},Re=function(e,n){return xe(e,n)+" in Composit Signature did not match the requested "+e+"."},Le={"HTTP/POST":function(e,n){try{var t=function(){},r=null;return Promise.resolve(function(e,n){try{var t=e()}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(function(){return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return Promise.resolve(fetch(je(e,!0),{method:"POST",headers:{"Content-Type":"application/json"},body:n?JSON.stringify(n):void 0}).then(function(e){return e.json()})).then(function(e){if(console.log("RESP",e),e.local&&e.local.length>0){var n=Oe(e.local[0]);t=n[1]}return Promise.resolve(function e(n){return new Promise(function(t,r){try{return Promise.resolve(fetch(je(n),{method:Te[n.method],headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(n){"APPROVED"===n.status?t(n.compositeSignature):"DECLINED"===n.status?r({status:n.status,reason:n.reason}):setTimeout(function(){t(e(n.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){r=e})})},function(r){throw t(),Ne(e,n,r),r})},function(){return t(),r}))}catch(e){return Promise.reject(e)}},"IFRAME/RPC":function(e,n){try{return Promise.resolve(new Promise(function(t,r){try{var o=m.uid(),i=Oe(e),u=i[0],s=i[1],a=function(){u.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[n,e.params]})),"*")};window.addEventListener("message",function e(n){var i=n.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(),r({status:u.status,reason:u.reason})):(window.removeEventListener("message",e),s(),r({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"})),Promise.resolve()}catch(e){return Promise.reject(e)}}),new Promise(function(e){window.addEventListener("message",t);var n=setTimeout(function(){window.removeEventListener("message",t),a(),e()},5e3);function t(r){"FCL::AUTHZ_READY"===r.data.type&&(clearTimeout(n),window.removeEventListener("message",t),a(),e())}})}catch(t){Ne(e,n,t),r({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function Ne(e,n,t){console.error("["+e.method+"] Trouble talking to Wallet Provider","\n\n",{authz:e,signable:n},t)}function Ce(e,n,t){if(!e.s){if(t instanceof qe){if(!t.s)return void(t.o=Ce.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(Ce.bind(null,e,n),Ce.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var Ue=function(e){try{return Ye(),Promise.resolve(De()).then(function(n){Ie(n.services,"authn");var r=Ie(n.services,"authz");return Ie(n.services,"pre-authz"),x({},e,{tempId:"CURRENT_USER",resolve:null,addr:i.sansPrefix(r.identity.address),keyId:r.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(function(e,n){try{return Promise.resolve(Le[e.method](e,n)).then(function(n){return null==n.sig&&(n.sig=n.signature),null==n.signature&&(n.signature=n.sig),n.addr=i.sansPrefix(n.addr),function(e,n){try{var r={compSig:e,authz:n};t.invariant(e.addr,Ae("addr","Address"),r),t.invariant(e.keyId,Ae("keyId"),r),t.invariant(e.signature,Ae("signature"),r),t.invariant(e.keyId===n.identity.keyId,Re("keyId"),r),t.invariant(i.sansPrefix(e.addr)===i.sansPrefix(n.identity.address),Re("addr","Address"),r)}catch(e){throw new Error("Composite Signature from Wallet Provider failed Validation/Sanitation.\nReason: "+e.message)}}(n,e),n})}catch(e){return Promise.reject(e)}}(r,e))}catch(e){return Promise.reject(e)}}})})}catch(e){return Promise.reject(e)}},qe=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{Ce(r,1,i(this.v))}catch(e){Ce(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Ce(r,1,n?n(o):o):t?Ce(r,1,t(o)):Ce(r,2,o)}catch(e){Ce(r,2,e)}},r},e}();function ze(e){return e instanceof qe&&1&e.s}var De=function(){try{return Promise.resolve(new Promise(function(e){try{return Ye(),Promise.resolve(en()).then(function(t){return t.loggedIn&&Ze(t)?e(t):Promise.resolve(n.config().get("challenge.handshake")).then(function(n){var t,r,o,u=(r=(t={handshake:n,l6n:window.location.origin}).l6n,(o=new URL(t.handshake)).searchParams.append("l6n",r),be(o.href))[1];window.addEventListener("message",function n(t){var r=t.data;try{return r.type===Me||r.type===He?(u(),window.removeEventListener("message",n),Promise.resolve()):r.type!==Je?Promise.resolve():(u(),window.removeEventListener("message",n),Promise.resolve(function(e){try{var n=(e=function(e){return e.addr=e.addr?i.withPrefix(e.addr):null,e.paddr=e.paddr?i.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",n),Promise.resolve(fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var t,r=R(e.authorizations);!(t=r()).done;)n.push(x({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&n.push(x({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(t){var r,o,u=(r=n,o=t,void 0===r&&(r=[]),void 0===o&&(o=[]),[].concat(r,o)).map(function(n){return function(e,n){try{var t=Se[e.type](e,n);return console.log(e.type,{normalized:t,service:e}),t}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)});console.log("BUILD USER",u);var s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,u);return x({},we,{addr:i.withPrefix(e.addr),cid:Ee(s),loggedIn:!0,services:u,expiresAt:e.exp})})}catch(e){return Promise.reject(e)}}(r)).then(function(n){return c.send(Fe,Ge,n),Promise.resolve(en()).then(function(n){e(n)})}))}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Fe="CURRENT_USER",_e="CURRENT_USER/UPDATED",Ge="SET_CURRENT_USER",He="FCL::CANCEL",Je="FCL::CHALLENGE::RESPONSE",Me="FCL::CHALLENGE::CANCEL",Ke='{\n "@type": "User",\n "@vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Ve=function(e){try{return sessionStorage.setItem(Fe,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},We=function(){return n.config().get("persistSession",!0)},Xe=((Be={})[c.INIT]=function(e){try{return e.merge(JSON.parse(Ke)),Promise.resolve(We()).then(function(n){var t=function(){if(n)return Promise.resolve(function(){try{var e=JSON.parse(Ke),n=JSON.parse(sessionStorage.getItem(Fe));return null!=n&&e["@vsn"]!==n["@vsn"]?(sessionStorage.removeItem(Fe),Promise.resolve(e)):Promise.resolve(n||e)}catch(e){return Promise.reject(e)}}()).then(function(n){Ze(n)&&e.merge(n)})}();if(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}},Be[c.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,_e,x({},e.all()))},Be[c.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Be.SNAPSHOT=function(e,n){try{return n.reply(x({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},Be[Ge]=function(e,n,t){try{return e.merge(t),Promise.resolve(We()).then(function(n){n&&Ve(e.all()),e.broadcast(_e,x({},e.all()))})}catch(e){return Promise.reject(e)}},Be.DEL_CURRENT_USER=function(e,n){try{return e.merge(JSON.parse(Ke)),Promise.resolve(We()).then(function(n){n&&Ve(e.all()),e.broadcast(_e,x({},e.all()))})}catch(e){return Promise.reject(e)}},Be),Ye=function(){return c.spawn(Xe,Fe)};function Ze(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()}function $e(){Ye(),c.send(Fe,"DEL_CURRENT_USER")}function Qe(e){Ye();var n=c.spawn(function(n){try{var t;return n.send(Fe,c.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(ze(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!ze(i)){r=1;break}i=i.s}}var u=new qe,s=Ce.bind(null,u,2);return(0===r?o.then(c):1===r?i.then(a):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):Ce(u,1,i)})).then(void 0,s),u;function a(n){i=n;do{if(!(o=e())||ze(o)&&!o.v)return void Ce(u,1,i);if(o.then)return void o.then(c).then(void 0,s);ze(i=t())&&(i=i.v)}while(!i||!i.then);i.then(a).then(void 0,s)}function c(e){e?(i=t())&&i.then?i.then(a).then(void 0,s):a(i):Ce(u,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(n.receive()).then(function(r){if("@EXIT"===r.tag)return n.send(Fe,c.UNSUBSCRIBE),void(t=1);e(r.data)})}))}catch(e){return Promise.reject(e)}});return function(){return c.send(n,"@EXIT")}}function en(){return Ye(),c.send(Fe,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var nn=function(){return{authenticate:De,unauthenticate:$e,authorization:Ue,subscribe:Qe,snapshot:en}},tn=nn().authorization;Object.defineProperty(e,"config",{enumerable:!0,get:function(){return n.config}}),Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return r.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return r.isOk}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return r.pipe}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return r.why}}),Object.defineProperty(e,"latestBlock",{enumerable:!0,get:function(){return o.latestBlock}}),Object.defineProperty(e,"display",{enumerable:!0,get:function(){return i.display}}),Object.defineProperty(e,"sansPrefix",{enumerable:!0,get:function(){return i.sansPrefix}}),Object.defineProperty(e,"withPrefix",{enumerable:!0,get:function(){return i.withPrefix}}),Object.defineProperty(e,"account",{enumerable:!0,get:function(){return u.account}}),Object.defineProperty(e,"send",{enumerable:!0,get:function(){return f.send}}),Object.defineProperty(e,"decode",{enumerable:!0,get:function(){return l.decode}}),Object.defineProperty(e,"getTransactionStatus",{enumerable:!0,get:function(){return d.getTransactionStatus}}),Object.defineProperty(e,"getEvents",{enumerable:!0,get:function(){return h.getEvents}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return p.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return p.template}}),Object.defineProperty(e,"transaction",{enumerable:!0,get:function(){return v.transaction}}),Object.defineProperty(e,"script",{enumerable:!0,get:function(){return y.script}}),Object.defineProperty(e,"ping",{enumerable:!0,get:function(){return g.ping}}),Object.defineProperty(e,"getAccount",{enumerable:!0,get:function(){return b.getAccount}}),Object.defineProperty(e,"getLatestBlock",{enumerable:!0,get:function(){return P.getLatestBlock}}),Object.defineProperty(e,"getBlockById",{enumerable:!0,get:function(){return k.getBlockById}}),Object.defineProperty(e,"getBlockByHeight",{enumerable:!0,get:function(){return w.getBlockByHeight}}),Object.defineProperty(e,"authorization",{enumerable:!0,get:function(){return S.authorization}}),Object.defineProperty(e,"authorizations",{enumerable:!0,get:function(){return S.authorizations}}),Object.defineProperty(e,"arg",{enumerable:!0,get:function(){return E.arg}}),Object.defineProperty(e,"args",{enumerable:!0,get:function(){return E.args}}),Object.defineProperty(e,"proposer",{enumerable:!0,get:function(){return I.proposer}}),Object.defineProperty(e,"payer",{enumerable:!0,get:function(){return j.payer}}),Object.defineProperty(e,"limit",{enumerable:!0,get:function(){return O.limit}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return B.ref}}),Object.defineProperty(e,"param",{enumerable:!0,get:function(){return T.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return T.params}}),e.VERSION="0.0.67-alpha.2",e.authenticate=function(){return nn().authenticate()},e.authz=tn,e.currentUser=nn,e.events=function(e){return{subscribe:function(n){return c.subscriber(e,ge,n)}}},e.logIn=function(){return nn().authenticate()},e.reauthenticate=function(){nn().unauthenticate(),nn().authenticate()},e.serialize=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{var t=function(){return Promise.resolve(a.resolve(n)(e)).then(JSON.stringify)},o=function(){if(Array.isArray(e))return Promise.resolve(r.pipe(r.interaction(),e)).then(function(n){e=n})}();return Promise.resolve(o&&o.then?o.then(t):t())}catch(e){return Promise.reject(e)}},e.signUp=function(){return nn().authenticate()},e.tx=pe,e.unauthenticate=function(){return nn().unauthenticate()}});
//# sourceMappingURL=fcl.umd.js.map
{
"name": "@onflow/fcl",
"version": "0.0.67-alpha.1",
"version": "0.0.67-alpha.2",
"description": "Flow Client Library",

@@ -38,4 +38,4 @@ "license": "Apache-2.0",

"@onflow/config": "0.0.2",
"@onflow/sdk-decode": "0.0.1",
"@onflow/interaction": "0.0.10",
"@onflow/rlp": "0.0.3",
"@onflow/sdk-account": "0.0.3",

@@ -60,2 +60,3 @@ "@onflow/sdk-build-arguments": "0.0.0",

"@onflow/sdk-build-validator": "0.0.0",
"@onflow/sdk-decode": "0.0.1",
"@onflow/sdk-latest-block": "0.0.3",

@@ -62,0 +63,0 @@ "@onflow/sdk-resolve": "0.0.4",

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