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.63 to 0.0.64

4

CHANGELOG.md

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

### 0.0.64 - 2020-11-04
- 2020-11-04 -- VSN `@onflow/sdk-send` 0.0.2 -> 0.0.3
### 0.0.63 - 2020-11-04

@@ -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"),c=require("@onflow/sdk-build-get-events"),a=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"),k=require("@onflow/sdk-build-params");e.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var x,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},N=function(e){return e.status>=3},C=function(e){return e.status>=2},A=((x={})[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)}},x[n.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,n.UPDATED,e.all())},x[n.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},x[n.SNAPSHOT]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},x.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)}},x),B=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},L=function(e){return n.spawn(A,B(e))};function U(e){function r(r){return n.subscriber(B(e),L,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,L)},subscribe:r,onceFinalized:t(C),onceExecuted:t(N),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)}U.isUnknown=function(e){return e.status>=0},U.isPending=function(e){return e.status>=1},U.isFinalized=C,U.isExecuted=N,U.isSealed=R,U.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),J=function(e){return n.spawn(_,e)};function H(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 H(V(e).href)}var W,K={"HTTP/GET":"GET","HTTP/POST":"POST"},X=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},$=function(e,r){return"Missing "+X(e,r)+" in Composite Signature."},Q=function(e,r){return X(e,r)+" in Composit Signature did not match the requested "+e+"."},Y={"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(),Z(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];setTimeout(function(){u.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")},500),window.addEventListener("message",function e(r){var i=r.data;try{if("object"!=typeof i)return Promise.resolve();if("2.0"!==i.jsonrpc)return Promise.resolve();if(i.id!==o)return Promise.resolve();var u=i.result;return"APPROVED"===u.status?(window.removeEventListener("message",e),s(),t(u.compositeSignature)):"DECLINED"===u.status?(window.removeEventListener("message",e),s(),n({status:u.status,reason:u.reason})):(window.removeEventListener("message",e),s(),n({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"})),Promise.resolve()}catch(e){return Promise.reject(e)}})}catch(t){Z(e,r,t),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function Z(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: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(Y[e.method](e,r)).then(function(r){return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),function(e,r){try{if(null==e.addr)throw new Error($("addr","Address"));if(null==e.keyId)throw new Error($("keyId"));if(null==e.signature)throw new Error($("signature"));if(e.addr!==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})),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 a.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),H(i.href))[1];window.addEventListener("message",function e(t){var o=t.data;try{return o.type===ae?(u(),window.removeEventListener("message",e),Promise.resolve()):o.type!==ce?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",ce="FCL::CHALLENGE::RESPONSE",ae="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(a):1===n?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,s):a(o):ee(u,1,i)})).then(void 0,s),u;function c(r){i=r;do{if(!(o=e())||ne(o)&&!o.v)return void ee(u,1,i);if(o.then)return void o.then(a).then(void 0,s);ne(i=t())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,s)}function a(e){e?(i=t())&&i.then?i.then(c).then(void 0,s):c(i):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}};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 c.getEvents}}),Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return a.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 k.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return k.params}}),exports.VERSION="0.0.63",exports.authenticate=function(){return Pe().authenticate()},exports.currentUser=Pe,exports.events=function(e){return{subscribe:function(r){return n.subscriber(e,J,r)}}},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.tx=U,exports.unauthenticate=function(){return Pe().unauthenticate()};
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"),c=require("@onflow/sdk-build-get-events"),a=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"),k=require("@onflow/sdk-build-params");e.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var x,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},N=function(e){return e.status>=3},C=function(e){return e.status>=2},A=((x={})[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)}},x[n.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,n.UPDATED,e.all())},x[n.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},x[n.SNAPSHOT]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},x.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)}},x),B=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},L=function(e){return n.spawn(A,B(e))};function U(e){function r(r){return n.subscriber(B(e),L,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,L)},subscribe:r,onceFinalized:t(C),onceExecuted:t(N),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)}U.isUnknown=function(e){return e.status>=0},U.isPending=function(e){return e.status>=1},U.isFinalized=C,U.isExecuted=N,U.isSealed=R,U.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),J=function(e){return n.spawn(_,e)};function H(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 H(V(e).href)}var W,K={"HTTP/GET":"GET","HTTP/POST":"POST"},X=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},$=function(e,r){return"Missing "+X(e,r)+" in Composite Signature."},Q=function(e,r){return X(e,r)+" in Composit Signature did not match the requested "+e+"."},Y={"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(),Z(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];setTimeout(function(){u.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")},500),window.addEventListener("message",function e(r){var i=r.data;try{if("object"!=typeof i)return Promise.resolve();if("2.0"!==i.jsonrpc)return Promise.resolve();if(i.id!==o)return Promise.resolve();var u=i.result;return"APPROVED"===u.status?(window.removeEventListener("message",e),s(),t(u.compositeSignature)):"DECLINED"===u.status?(window.removeEventListener("message",e),s(),n({status:u.status,reason:u.reason})):(window.removeEventListener("message",e),s(),n({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"})),Promise.resolve()}catch(e){return Promise.reject(e)}})}catch(t){Z(e,r,t),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function Z(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: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(Y[e.method](e,r)).then(function(r){return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),function(e,r){try{if(null==e.addr)throw new Error($("addr","Address"));if(null==e.keyId)throw new Error($("keyId"));if(null==e.signature)throw new Error($("signature"));if(e.addr!==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})),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 a.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),H(i.href))[1];window.addEventListener("message",function e(t){var o=t.data;try{return o.type===ae?(u(),window.removeEventListener("message",e),Promise.resolve()):o.type!==ce?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",ce="FCL::CHALLENGE::RESPONSE",ae="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(a):1===n?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,s):a(o):ee(u,1,i)})).then(void 0,s),u;function c(r){i=r;do{if(!(o=e())||ne(o)&&!o.v)return void ee(u,1,i);if(o.then)return void o.then(a).then(void 0,s);ne(i=t())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,s)}function a(e){e?(i=t())&&i.then?i.then(c).then(void 0,s):c(i):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}};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 c.getEvents}}),Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return a.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 k.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return k.params}}),exports.VERSION="0.0.64",exports.authenticate=function(){return Pe().authenticate()},exports.currentUser=Pe,exports.events=function(e){return{subscribe:function(r){return n.subscriber(e,J,r)}}},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.tx=U,exports.unauthenticate=function(){return Pe().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 p}from"@onflow/sdk-send";export{send}from"@onflow/sdk-send";import{decode as m}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}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import{uid as E}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 b=async(t=[],r={})=>(Array.isArray(t)&&(t=await e(n(),t)),JSON.stringify(await o(r)(t))),k=async t=>p([w(t)]).then(m),S=t=>t.status>=4,v=t=>t.status>=3,T=t=>t.status>=2,x={[i]:async t=>{const e=await k(t.self());S(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 k(t.self());var n,o;S(e)||setTimeout(()=>t.sendSelf("POLL"),2500),n=t.all(),o=e,JSON.stringify(n)!==JSON.stringify(o)&&t.broadcast(u,e),t.merge(e)}},I=t=>{if("object"==typeof t&&(t=t.transactionId),null==t)throw new Error("transactionId required");return t},P=t=>s(x,I(t));function R(t){function e(e){return r(I(t),P,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,P)},subscribe:e,onceFinalized:n(T),onceExecuted:n(v),onceSealed:n(S)}}R.isUnknown=t=>t.status>=0,R.isPending=t=>t.status>=1,R.isFinalized=T,R.isExecuted=v,R.isSealed=S,R.isExpired=t=>5===t.status;const N=async e=>setTimeout(()=>e.sendSelf("TICK"),await t().get("fcl.eventPollRate",1e4)),L={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 p([getEvents(t.self(),e.height,n.height-1)]).then(m);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"))}},C=t=>s(L,t);function O(t){return{subscribe:e=>r(t,C,e)}}function A(){return(A=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 U(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 D(t){return`cid:${t.addr||t.name}:${t.pid}`}function z(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 F(t){return U(z(t).href)}const _={"HTTP/GET":"GET","HTTP/POST":"POST"},j=t=>new Promise(async(e,n)=>{const o=await fetch(z(t),{method:_[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(j(o.authorizationUpdates))},500)}),B=(t,e)=>null==e?`'${t}'`:`'${t}' (${e})`,J=(t,e)=>`Missing ${B(t,e)} in Composite Signature.`,H=(t,e)=>`${B(t,e)} in Composit Signature did not match the requested ${t}.`,$={"HTTP/POST":async function(t,e){var n=()=>{},o=null;try{const r=await fetch(z(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]=F(r.local[0]);n=e}o=await j(r.authorizationUpdates)}catch(o){throw n(),M(t,e,o),o}finally{return n(),o}},"IFRAME/RPC":async function(t,e){return new Promise((n,o)=>{try{const r=E(),[s,a]=F(t);setTimeout(()=>{s.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:r,method:"fcl:sign",params:[e,t.params]})),"*")},500);const i=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",i),a(),n(e.compositeSignature)):"DECLINED"===e.status?(window.removeEventListener("message",i),a(),o({status:e.status,reason:e.reason})):(window.removeEventListener("message",i),a(),o({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"}))};window.addEventListener("message",i)}catch(n){M(t,e,n),o({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}})}};function M(t,e,n){console.error(`[${t.method}] Trouble talking to Wallet Provider`,"\n\n",{authz:t,signable:e},n)}const V="CURRENT_USER",G="CURRENT_USER/UPDATED",W='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',q=async t=>(sessionStorage.setItem(V,JSON.stringify(t)),t),K=()=>t().get("persistSession",!0),X={[i]:async t=>{t.merge(JSON.parse(W)),await K()&&t.merge(await(async()=>{const t=JSON.parse(W),e=JSON.parse(sessionStorage.getItem(V));return null!=e&&t.VERSION!==e.VERSION?(sessionStorage.removeItem(V),t):e||t})())},[l]:(t,e)=>{t.subscribe(e.from),t.send(e.from,G,A({},t.all()))},[c]:(t,e)=>{t.unsubscribe(e.from)},SNAPSHOT:async(t,e)=>{e.reply(A({},t.all()))},SET_CURRENT_USER:async(t,e,n)=>{t.merge(n),await K()&&q(t.all()),t.broadcast(G,A({},t.all()))},DEL_CURRENT_USER:async(t,e)=>{t.merge(JSON.parse(W)),await K()&&q(t.all()),t.broadcast(G,A({},t.all()))}},Q=()=>s(X,V);async function Y(){return new Promise(async e=>{Q();const n=await nt();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),U(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(V,"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(A({type:"authz",keyId:o.keyId},t));return null!=o.provider&&r.push(A({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:D(n),loggedIn:!0,services:e}}(t)),e(await nt()))};window.addEventListener("message",s)})}function Z(){Q(),f(V,"DEL_CURRENT_USER")}async function tt(t){Q();const e=function(t=[],e){return t.find(t=>t.type===e)}((await Y()).services,"authz");let n;return t.role.proposer&&(n=(await ot()).keys.find(t=>t.index===e.keyId).sequenceNumber),A({},t,{addr:e.addr,keyId:e.keyId,sequenceNum:n,signature:t.signature||null,signingFunction:async t=>async function(t,e){const n=await $[t.method](t,e);return null==n.sig&&(n.sig=n.signature),null==n.signature&&(n.signature=n.sig),function(t,e){try{if(null==t.addr)throw new Error(J("addr","Address"));if(null==t.keyId)throw new Error(J("keyId"));if(null==t.signature)throw new Error(J("signature"));if(t.addr!==e.addr)throw new Error(H("addr","Address"));if(t.keyId!==e.keyId)throw new Error(H("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 et(t){Q();const e=s(async e=>{for(e.send(V,l);;){const n=await e.receive();if("@EXIT"===n.tag)return void e.send(V,c);t(n.data)}});return()=>f(e,"@EXIT")}function nt(){return Q(),f(V,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function ot(){Q();const{addr:t}=await nt();if(null==t)throw new Error("No Flow Address for Current User");return g(t)}const rt=()=>({authenticate:Y,unauthenticate:Z,authorization:tt,subscribe:et,snapshot:nt}),st=()=>rt().authenticate(),at=()=>rt().unauthenticate(),it="0.0.63";export{it as VERSION,st as authenticate,rt as currentUser,O as events,b as serialize,R as tx,at as unauthenticate};
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 p}from"@onflow/sdk-send";export{send}from"@onflow/sdk-send";import{decode as m}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}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import{uid as E}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 b=async(t=[],r={})=>(Array.isArray(t)&&(t=await e(n(),t)),JSON.stringify(await o(r)(t))),k=async t=>p([w(t)]).then(m),S=t=>t.status>=4,v=t=>t.status>=3,T=t=>t.status>=2,x={[i]:async t=>{const e=await k(t.self());S(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 k(t.self());var n,o;S(e)||setTimeout(()=>t.sendSelf("POLL"),2500),n=t.all(),o=e,JSON.stringify(n)!==JSON.stringify(o)&&t.broadcast(u,e),t.merge(e)}},I=t=>{if("object"==typeof t&&(t=t.transactionId),null==t)throw new Error("transactionId required");return t},P=t=>s(x,I(t));function R(t){function e(e){return r(I(t),P,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,P)},subscribe:e,onceFinalized:n(T),onceExecuted:n(v),onceSealed:n(S)}}R.isUnknown=t=>t.status>=0,R.isPending=t=>t.status>=1,R.isFinalized=T,R.isExecuted=v,R.isSealed=S,R.isExpired=t=>5===t.status;const N=async e=>setTimeout(()=>e.sendSelf("TICK"),await t().get("fcl.eventPollRate",1e4)),L={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 p([getEvents(t.self(),e.height,n.height-1)]).then(m);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"))}},C=t=>s(L,t);function O(t){return{subscribe:e=>r(t,C,e)}}function A(){return(A=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 U(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 D(t){return`cid:${t.addr||t.name}:${t.pid}`}function z(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 F(t){return U(z(t).href)}const _={"HTTP/GET":"GET","HTTP/POST":"POST"},j=t=>new Promise(async(e,n)=>{const o=await fetch(z(t),{method:_[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(j(o.authorizationUpdates))},500)}),B=(t,e)=>null==e?`'${t}'`:`'${t}' (${e})`,J=(t,e)=>`Missing ${B(t,e)} in Composite Signature.`,H=(t,e)=>`${B(t,e)} in Composit Signature did not match the requested ${t}.`,$={"HTTP/POST":async function(t,e){var n=()=>{},o=null;try{const r=await fetch(z(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]=F(r.local[0]);n=e}o=await j(r.authorizationUpdates)}catch(o){throw n(),M(t,e,o),o}finally{return n(),o}},"IFRAME/RPC":async function(t,e){return new Promise((n,o)=>{try{const r=E(),[s,a]=F(t);setTimeout(()=>{s.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:r,method:"fcl:sign",params:[e,t.params]})),"*")},500);const i=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",i),a(),n(e.compositeSignature)):"DECLINED"===e.status?(window.removeEventListener("message",i),a(),o({status:e.status,reason:e.reason})):(window.removeEventListener("message",i),a(),o({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"}))};window.addEventListener("message",i)}catch(n){M(t,e,n),o({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}})}};function M(t,e,n){console.error(`[${t.method}] Trouble talking to Wallet Provider`,"\n\n",{authz:t,signable:e},n)}const V="CURRENT_USER",G="CURRENT_USER/UPDATED",W='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',q=async t=>(sessionStorage.setItem(V,JSON.stringify(t)),t),K=()=>t().get("persistSession",!0),X={[i]:async t=>{t.merge(JSON.parse(W)),await K()&&t.merge(await(async()=>{const t=JSON.parse(W),e=JSON.parse(sessionStorage.getItem(V));return null!=e&&t.VERSION!==e.VERSION?(sessionStorage.removeItem(V),t):e||t})())},[l]:(t,e)=>{t.subscribe(e.from),t.send(e.from,G,A({},t.all()))},[c]:(t,e)=>{t.unsubscribe(e.from)},SNAPSHOT:async(t,e)=>{e.reply(A({},t.all()))},SET_CURRENT_USER:async(t,e,n)=>{t.merge(n),await K()&&q(t.all()),t.broadcast(G,A({},t.all()))},DEL_CURRENT_USER:async(t,e)=>{t.merge(JSON.parse(W)),await K()&&q(t.all()),t.broadcast(G,A({},t.all()))}},Q=()=>s(X,V);async function Y(){return new Promise(async e=>{Q();const n=await nt();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),U(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(V,"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(A({type:"authz",keyId:o.keyId},t));return null!=o.provider&&r.push(A({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:D(n),loggedIn:!0,services:e}}(t)),e(await nt()))};window.addEventListener("message",s)})}function Z(){Q(),f(V,"DEL_CURRENT_USER")}async function tt(t){Q();const e=function(t=[],e){return t.find(t=>t.type===e)}((await Y()).services,"authz");let n;return t.role.proposer&&(n=(await ot()).keys.find(t=>t.index===e.keyId).sequenceNumber),A({},t,{addr:e.addr,keyId:e.keyId,sequenceNum:n,signature:t.signature||null,signingFunction:async t=>async function(t,e){const n=await $[t.method](t,e);return null==n.sig&&(n.sig=n.signature),null==n.signature&&(n.signature=n.sig),function(t,e){try{if(null==t.addr)throw new Error(J("addr","Address"));if(null==t.keyId)throw new Error(J("keyId"));if(null==t.signature)throw new Error(J("signature"));if(t.addr!==e.addr)throw new Error(H("addr","Address"));if(t.keyId!==e.keyId)throw new Error(H("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 et(t){Q();const e=s(async e=>{for(e.send(V,l);;){const n=await e.receive();if("@EXIT"===n.tag)return void e.send(V,c);t(n.data)}});return()=>f(e,"@EXIT")}function nt(){return Q(),f(V,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function ot(){Q();const{addr:t}=await nt();if(null==t)throw new Error("No Flow Address for Current User");return g(t)}const rt=()=>({authenticate:Y,unauthenticate:Z,authorization:tt,subscribe:et,snapshot:nt}),st=()=>rt().authenticate(),at=()=>rt().unauthenticate(),it="0.0.64";export{it as VERSION,st as authenticate,rt as currentUser,O as events,b as serialize,R as tx,at 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}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import{uid as g}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 w,b,E=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)}},k=function(e){try{return Promise.resolve(m([v(e)]).then(h))}catch(e){return Promise.reject(e)}},S=function(e){return e.status>=4},j=function(e){return e.status>=3},I=function(e){return e.status>=2},x=((w={})[o]=function(e){try{return Promise.resolve(k(e.self())).then(function(r){S(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},w[i]=function(e,r){e.subscribe(r.from),e.send(r.from,s,e.all())},w[u]=function(e,r){e.unsubscribe(r.from)},w[a]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},w.POLL=function(e){try{return Promise.resolve(k(e.self())).then(function(r){var t,n;S(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)}},w),T=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},R=function(e){return l(x,T(e))};function A(e){function r(r){return c(T(e),R,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,R)},subscribe:r,onceFinalized:t(I),onceExecuted:t(j),onceSealed:t(S)}}function L(){return(L=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 N(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 O(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 N(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)?N(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)}A.isUnknown=function(e){return e.status>=0},A.isPending=function(e){return e.status>=1},A.isFinalized=I,A.isExecuted=j,A.isSealed=S,A.isExpired=function(e){return 5===e.status};var C=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)}},D=((b={}).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(C(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=O(r);!(t=n()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(C(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)}},b[i]=function(e,r){try{var t=function(){e.subscribe(r.from)},n=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(C(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)}},b[u]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},b),U=function(e){return l(D,e)};function z(e){return{subscribe:function(r){return c(e,U,r)}}}function F(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 _(e){return"cid:"+(e.addr||e.name)+":"+e.pid}function B(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 J(e){return F(B(e).href)}var H,M={"HTTP/GET":"GET","HTTP/POST":"POST"},V=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},G=function(e,r){return"Missing "+V(e,r)+" in Composite Signature."},W=function(e,r){return V(e,r)+" in Composit Signature did not match the requested "+e+"."},q={"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(B(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=J(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(B(r),{method:M[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(),K(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=g(),i=J(e),s=i[0],u=i[1];setTimeout(function(){s.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")},500),window.addEventListener("message",function e(r){var i=r.data;try{if("object"!=typeof i)return Promise.resolve();if("2.0"!==i.jsonrpc)return Promise.resolve();if(i.id!==o)return Promise.resolve();var 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)}})}catch(t){K(e,r,t),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function K(e,r,t){console.error("["+e.method+"] Trouble talking to Wallet Provider","\n\n",{authz:e,signable:r},t)}function X(e,r,t){if(!e.s){if(t instanceof Y){if(!t.s)return void(t.o=X.bind(null,e,r));1&r&&(r=t.s),t=t.v}if(t&&t.then)return void t.then(X.bind(null,e,r),X.bind(null,e,2));e.s=r,e.v=t;var n=e.o;n&&n(e)}}var $=function(){try{return le(),Promise.resolve(me()).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)}},Q=function(e){try{return le(),Promise.resolve(ee()).then(function(r){function t(){return L({},e,{addr:i.addr,keyId:i.keyId,sequenceNum:o,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(function(e,r){try{return Promise.resolve(q[e.method](e,r)).then(function(r){return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),function(e,r){try{if(null==e.addr)throw new Error(G("addr","Address"));if(null==e.keyId)throw new Error(G("keyId"));if(null==e.signature)throw new Error(G("signature"));if(e.addr!==r.addr)throw new Error(W("addr","Address"));if(e.keyId!==r.keyId)throw new Error(W("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($()).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)}},Y=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{X(n,1,i(this.v))}catch(e){X(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?X(n,1,r?r(o):o):t?X(n,1,t(o)):X(n,2,o)}catch(e){X(n,2,e)}},n},e}();function Z(e){return e instanceof Y&&1&e.s}var ee=function(){try{return Promise.resolve(new Promise(function(r){try{return le(),Promise.resolve(me()).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),F(o.href))[1];window.addEventListener("message",function e(t){var n=t.data;try{return n.type===ie?(i(),window.removeEventListener("message",e),Promise.resolve()):n.type!==oe?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=O(e.authorizations);!(t=n()).done;)r.push(L({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&r.push(L({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:_(s),loggedIn:!0,services:i}})}catch(e){return Promise.reject(e)}}(n)).then(function(e){return d(re,ne,e),Promise.resolve(me()).then(function(e){r(e)})}))}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},re="CURRENT_USER",te="CURRENT_USER/UPDATED",ne="SET_CURRENT_USER",oe="FCL::CHALLENGE::RESPONSE",ie="FCL::CHALLENGE::CANCEL",se='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',ue=function(e){try{return sessionStorage.setItem(re,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},ae=function(){return e().get("persistSession",!0)},ce=((H={})[o]=function(e){try{return e.merge(JSON.parse(se)),Promise.resolve(ae()).then(function(r){var t=function(){if(r){var t=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(se),r=JSON.parse(sessionStorage.getItem(re));return null!=r&&e.VERSION!==r.VERSION?(sessionStorage.removeItem(re),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)}},H[i]=function(e,r){e.subscribe(r.from),e.send(r.from,te,L({},e.all()))},H[u]=function(e,r){e.unsubscribe(r.from)},H.SNAPSHOT=function(e,r){try{return r.reply(L({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},H[ne]=function(e,r,t){try{return e.merge(t),Promise.resolve(ae()).then(function(r){r&&ue(e.all()),e.broadcast(te,L({},e.all()))})}catch(e){return Promise.reject(e)}},H.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(se)),Promise.resolve(ae()).then(function(r){r&&ue(e.all()),e.broadcast(te,L({},e.all()))})}catch(e){return Promise.reject(e)}},H),le=function(){return l(ce,re)};function fe(){le(),d(re,"DEL_CURRENT_USER")}function de(e){le();var r=l(function(r){try{var t;return r.send(re,i),Promise.resolve(function(e,r,t){for(var n;;){var o=e();if(Z(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=t();if(i&&i.then){if(!Z(i)){n=1;break}i=i.s}}var s=new Y,u=X.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):X(s,1,i)})).then(void 0,u),s;function a(r){i=r;do{if(!(o=e())||Z(o)&&!o.v)return void X(s,1,i);if(o.then)return void o.then(c).then(void 0,u);Z(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):X(s,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(n){if("@EXIT"===n.tag)return r.send(re,u),void(t=1);e(n.data)})}))}catch(e){return Promise.reject(e)}});return function(){return d(r,"@EXIT")}}function me(){return le(),d(re,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var he=function(){return{authenticate:ee,unauthenticate:fe,authorization:Q,subscribe:de,snapshot:me}},ve=function(){return he().authenticate()},pe=function(){return he().unauthenticate()},Pe="0.0.63";export{Pe as VERSION,ve as authenticate,he as currentUser,z as events,E as serialize,A as tx,pe as unauthenticate};
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}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import{uid as g}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 w,b,E=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)}},k=function(e){try{return Promise.resolve(m([v(e)]).then(h))}catch(e){return Promise.reject(e)}},S=function(e){return e.status>=4},j=function(e){return e.status>=3},I=function(e){return e.status>=2},x=((w={})[o]=function(e){try{return Promise.resolve(k(e.self())).then(function(r){S(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},w[i]=function(e,r){e.subscribe(r.from),e.send(r.from,s,e.all())},w[u]=function(e,r){e.unsubscribe(r.from)},w[a]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},w.POLL=function(e){try{return Promise.resolve(k(e.self())).then(function(r){var t,n;S(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)}},w),T=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},R=function(e){return l(x,T(e))};function A(e){function r(r){return c(T(e),R,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,R)},subscribe:r,onceFinalized:t(I),onceExecuted:t(j),onceSealed:t(S)}}function L(){return(L=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 N(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 O(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 N(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)?N(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)}A.isUnknown=function(e){return e.status>=0},A.isPending=function(e){return e.status>=1},A.isFinalized=I,A.isExecuted=j,A.isSealed=S,A.isExpired=function(e){return 5===e.status};var C=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)}},D=((b={}).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(C(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=O(r);!(t=n()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(C(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)}},b[i]=function(e,r){try{var t=function(){e.subscribe(r.from)},n=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(C(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)}},b[u]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},b),U=function(e){return l(D,e)};function z(e){return{subscribe:function(r){return c(e,U,r)}}}function F(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 _(e){return"cid:"+(e.addr||e.name)+":"+e.pid}function B(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 J(e){return F(B(e).href)}var H,M={"HTTP/GET":"GET","HTTP/POST":"POST"},V=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},G=function(e,r){return"Missing "+V(e,r)+" in Composite Signature."},W=function(e,r){return V(e,r)+" in Composit Signature did not match the requested "+e+"."},q={"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(B(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=J(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(B(r),{method:M[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(),K(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=g(),i=J(e),s=i[0],u=i[1];setTimeout(function(){s.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[r,e.params]})),"*")},500),window.addEventListener("message",function e(r){var i=r.data;try{if("object"!=typeof i)return Promise.resolve();if("2.0"!==i.jsonrpc)return Promise.resolve();if(i.id!==o)return Promise.resolve();var 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)}})}catch(t){K(e,r,t),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function K(e,r,t){console.error("["+e.method+"] Trouble talking to Wallet Provider","\n\n",{authz:e,signable:r},t)}function X(e,r,t){if(!e.s){if(t instanceof Y){if(!t.s)return void(t.o=X.bind(null,e,r));1&r&&(r=t.s),t=t.v}if(t&&t.then)return void t.then(X.bind(null,e,r),X.bind(null,e,2));e.s=r,e.v=t;var n=e.o;n&&n(e)}}var $=function(){try{return le(),Promise.resolve(me()).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)}},Q=function(e){try{return le(),Promise.resolve(ee()).then(function(r){function t(){return L({},e,{addr:i.addr,keyId:i.keyId,sequenceNum:o,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(function(e,r){try{return Promise.resolve(q[e.method](e,r)).then(function(r){return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),function(e,r){try{if(null==e.addr)throw new Error(G("addr","Address"));if(null==e.keyId)throw new Error(G("keyId"));if(null==e.signature)throw new Error(G("signature"));if(e.addr!==r.addr)throw new Error(W("addr","Address"));if(e.keyId!==r.keyId)throw new Error(W("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($()).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)}},Y=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{X(n,1,i(this.v))}catch(e){X(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?X(n,1,r?r(o):o):t?X(n,1,t(o)):X(n,2,o)}catch(e){X(n,2,e)}},n},e}();function Z(e){return e instanceof Y&&1&e.s}var ee=function(){try{return Promise.resolve(new Promise(function(r){try{return le(),Promise.resolve(me()).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),F(o.href))[1];window.addEventListener("message",function e(t){var n=t.data;try{return n.type===ie?(i(),window.removeEventListener("message",e),Promise.resolve()):n.type!==oe?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=O(e.authorizations);!(t=n()).done;)r.push(L({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&r.push(L({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:_(s),loggedIn:!0,services:i}})}catch(e){return Promise.reject(e)}}(n)).then(function(e){return d(re,ne,e),Promise.resolve(me()).then(function(e){r(e)})}))}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},re="CURRENT_USER",te="CURRENT_USER/UPDATED",ne="SET_CURRENT_USER",oe="FCL::CHALLENGE::RESPONSE",ie="FCL::CHALLENGE::CANCEL",se='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',ue=function(e){try{return sessionStorage.setItem(re,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},ae=function(){return e().get("persistSession",!0)},ce=((H={})[o]=function(e){try{return e.merge(JSON.parse(se)),Promise.resolve(ae()).then(function(r){var t=function(){if(r){var t=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(se),r=JSON.parse(sessionStorage.getItem(re));return null!=r&&e.VERSION!==r.VERSION?(sessionStorage.removeItem(re),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)}},H[i]=function(e,r){e.subscribe(r.from),e.send(r.from,te,L({},e.all()))},H[u]=function(e,r){e.unsubscribe(r.from)},H.SNAPSHOT=function(e,r){try{return r.reply(L({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},H[ne]=function(e,r,t){try{return e.merge(t),Promise.resolve(ae()).then(function(r){r&&ue(e.all()),e.broadcast(te,L({},e.all()))})}catch(e){return Promise.reject(e)}},H.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(se)),Promise.resolve(ae()).then(function(r){r&&ue(e.all()),e.broadcast(te,L({},e.all()))})}catch(e){return Promise.reject(e)}},H),le=function(){return l(ce,re)};function fe(){le(),d(re,"DEL_CURRENT_USER")}function de(e){le();var r=l(function(r){try{var t;return r.send(re,i),Promise.resolve(function(e,r,t){for(var n;;){var o=e();if(Z(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=t();if(i&&i.then){if(!Z(i)){n=1;break}i=i.s}}var s=new Y,u=X.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):X(s,1,i)})).then(void 0,u),s;function a(r){i=r;do{if(!(o=e())||Z(o)&&!o.v)return void X(s,1,i);if(o.then)return void o.then(c).then(void 0,u);Z(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):X(s,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(n){if("@EXIT"===n.tag)return r.send(re,u),void(t=1);e(n.data)})}))}catch(e){return Promise.reject(e)}});return function(){return d(r,"@EXIT")}}function me(){return le(),d(re,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var he=function(){return{authenticate:ee,unauthenticate:fe,authorization:Q,subscribe:de,snapshot:me}},ve=function(){return he().authenticate()},pe=function(){return he().unauthenticate()},Pe="0.0.64";export{Pe as VERSION,ve as authenticate,he as currentUser,z as events,E as serialize,A as tx,pe 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,y,P,w,k,E,S,j,O,B){t.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var I,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},N=function(e){return e.status>=3},C=function(e){return e.status>=2},L=((I={})[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)}},I[o.SUBSCRIBE]=function(e,t){e.subscribe(t.from),e.send(t.from,o.UPDATED,e.all())},I[o.UNSUBSCRIBE]=function(e,t){e.unsubscribe(t.from)},I[o.SNAPSHOT]=function(e,t){try{return t.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},I.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)}},I),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(L,U(e))};function D(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(N),onceSealed:r(A)}}function x(){return(x=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)}D.isUnknown=function(e){return e.status>=0},D.isPending=function(e){return e.status>=1},D.isFinalized=C,D.isExecuted=N,D.isSealed=A,D.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"},$=function(e,t){return null==t?"'"+e+"'":"'"+e+"' ("+t+")"},Q=function(e,t){return"Missing "+$(e,t)+" in Composite Signature."},Y=function(e,t){return $(e,t)+" in Composit Signature did not match the requested "+e+"."},Z={"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];setTimeout(function(){u.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params]})),"*")},500),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)}})}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 x({},e,{addr: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(Z[e.method](e,t)).then(function(t){return null==t.sig&&(t.sig=t.signature),null==t.signature&&(t.signature=t.sig),function(e,t){try{if(null==e.addr)throw new Error(Q("addr","Address"));if(null==e.keyId)throw new Error(Q("keyId"));if(null==e.signature)throw new Error(Q("signature"));if(e.addr!==t.addr)throw new Error(Y("addr","Address"));if(e.keyId!==t.keyId)throw new Error(Y("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(x({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&t.push(x({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,x({},e.all()))},K[o.UNSUBSCRIBE]=function(e,t){e.unsubscribe(t.from)},K.SNAPSHOT=function(e,t){try{return t.reply(x({},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,x({},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,x({},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 ye=function(){return{authenticate:ie,unauthenticate:pe,authorization:re,subscribe:be,snapshot:ge}};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 y.getBlockById}}),Object.defineProperty(e,"getBlockByHeight",{enumerable:!0,get:function(){return P.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 B.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return B.params}}),e.VERSION="0.0.63",e.authenticate=function(){return ye().authenticate()},e.currentUser=ye,e.events=function(e){return{subscribe:function(t){return o.subscriber(e,J,t)}}},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.tx=D,e.unauthenticate=function(){return ye().unauthenticate()}});
!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,y,P,w,k,E,S,j,O,B){t.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var I,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},N=function(e){return e.status>=3},C=function(e){return e.status>=2},L=((I={})[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)}},I[o.SUBSCRIBE]=function(e,t){e.subscribe(t.from),e.send(t.from,o.UPDATED,e.all())},I[o.UNSUBSCRIBE]=function(e,t){e.unsubscribe(t.from)},I[o.SNAPSHOT]=function(e,t){try{return t.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},I.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)}},I),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(L,U(e))};function D(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(N),onceSealed:r(A)}}function x(){return(x=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)}D.isUnknown=function(e){return e.status>=0},D.isPending=function(e){return e.status>=1},D.isFinalized=C,D.isExecuted=N,D.isSealed=A,D.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"},$=function(e,t){return null==t?"'"+e+"'":"'"+e+"' ("+t+")"},Q=function(e,t){return"Missing "+$(e,t)+" in Composite Signature."},Y=function(e,t){return $(e,t)+" in Composit Signature did not match the requested "+e+"."},Z={"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];setTimeout(function(){u.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params]})),"*")},500),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)}})}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 x({},e,{addr: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(Z[e.method](e,t)).then(function(t){return null==t.sig&&(t.sig=t.signature),null==t.signature&&(t.signature=t.sig),function(e,t){try{if(null==e.addr)throw new Error(Q("addr","Address"));if(null==e.keyId)throw new Error(Q("keyId"));if(null==e.signature)throw new Error(Q("signature"));if(e.addr!==t.addr)throw new Error(Y("addr","Address"));if(e.keyId!==t.keyId)throw new Error(Y("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(x({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&t.push(x({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,x({},e.all()))},K[o.UNSUBSCRIBE]=function(e,t){e.unsubscribe(t.from)},K.SNAPSHOT=function(e,t){try{return t.reply(x({},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,x({},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,x({},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 ye=function(){return{authenticate:ie,unauthenticate:pe,authorization:re,subscribe:be,snapshot:ge}};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 y.getBlockById}}),Object.defineProperty(e,"getBlockByHeight",{enumerable:!0,get:function(){return P.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 B.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return B.params}}),e.VERSION="0.0.64",e.authenticate=function(){return ye().authenticate()},e.currentUser=ye,e.events=function(e){return{subscribe:function(t){return o.subscriber(e,J,t)}}},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.tx=D,e.unauthenticate=function(){return ye().unauthenticate()}});
//# sourceMappingURL=fcl.umd.js.map
{
"name": "@onflow/fcl",
"version": "0.0.63",
"version": "0.0.64",
"description": "Flow Client Library",

@@ -61,3 +61,3 @@ "license": "Apache-2.0",

"@onflow/sdk-resolve": "0.0.4",
"@onflow/sdk-send": "0.0.2",
"@onflow/sdk-send": "0.0.3",
"@onflow/util-actor": "0.0.2",

@@ -64,0 +64,0 @@ "@onflow/util-address": "0.0.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc