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.61-alpha.5 to 0.0.61

10

CHANGELOG.md

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

### 0.0.61 - 2020-10-28
- 2020-10-28 -- VSN `@onflow/sdk-decode` 0.0.0 -> 0.0.1
- 2020-10-28 -- VSN `@onflow/sdk-build-authorizations` 0.0.0 -> 0.0.1
- 2020-10-28 -- VSN `@onflow/sdk-latest-block` 0.0.0 -> 0.0.2
- 2020-10-28 -- VSN `@onflow/sdk-account` 0.0.0 -> 0.0.2
- 2020-10-28 -- VSN `@onflow/sdk-send` 0.0.0 -> 0.0.2
- 2020-10-28 -- VSN `@onflow/sdk-resolve` 0.0.0 -> 0.0.3
- 2020-10-28 -- Added in `persistSession` config flag (defaults to true)
### 0.0.61-alpha.5 - 2020-10-08

@@ -7,0 +17,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-uid"),f=require("@onflow/util-address"),d=require("@onflow/util-template"),m=require("@onflow/sdk-build-transaction"),h=require("@onflow/sdk-build-script"),p=require("@onflow/sdk-build-ping"),v=require("@onflow/sdk-build-get-account"),P=require("@onflow/sdk-build-get-latest-block"),y=require("@onflow/sdk-build-get-block-by-id"),b=require("@onflow/sdk-build-get-block-by-height"),g=require("@onflow/sdk-build-authorizations"),w=require("@onflow/sdk-build-arguments"),E=require("@onflow/sdk-build-proposer"),j=require("@onflow/sdk-build-payer"),S=require("@onflow/sdk-build-limit"),O=require("@onflow/sdk-build-ref"),I=require("@onflow/sdk-build-params");e.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var k,x,T=function(e){try{return Promise.resolve(o.send([getTransactionStatus(e)]).then(i.decode))}catch(e){return Promise.reject(e)}},R=function(e){return e.status>=4},U=function(e){return e.status>=3},N=function(e){return e.status>=2},C=((k={})[n.INIT]=function(e){try{return Promise.resolve(T(e.self())).then(function(r){R(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},k[n.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,n.UPDATED,e.all())},k[n.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},k[n.SNAPSHOT]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},k.POLL=function(e){try{return Promise.resolve(T(e.self())).then(function(r){var t,o;R(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),t=e.all(),o=r,JSON.stringify(t)!==JSON.stringify(o)&&e.broadcast(n.UPDATED,r),e.merge(r)})}catch(e){return Promise.reject(e)}},k),A=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},B=function(e){return n.spawn(C,A(e))};function L(e){function r(r){return n.subscriber(A(e),B,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,B)},subscribe:r,onceFinalized:t(N),onceExecuted:t(U),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){var r=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,r){if(e){if("string"==typeof e)return 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(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?D(e,void 0):void 0}}(e)))return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}L.isUnknown=function(e){return e.status>=0},L.isPending=function(e){return e.status>=1},L.isFinalized=N,L.isExecuted=U,L.isSealed=R,L.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)}},_=((x={}).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)}},x[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)}},x[n.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},x),H=function(e){return n.spawn(_,e)};function J(e){if(!document.getElementById("FCL_IFRAME")){var r=document.createElement("iframe");return r.src=e,r.id="FCL_IFRAME",r.allow="usb *",r.style.position="fixed",r.style.top="0px",r.style.right="0px",r.style.left="0px",r.style.bottom="0px",r.style.height="100vh",r.style.width="100vw",r.style.display="block",r.style.background="rgba(0,0,0,0.25)",r.style.zIndex=2147483647,r.frameBorder="0",r.style.boxSizing="border-box",document.body.append(r),[r,function(){document.getElementById("FCL_IFRAME")&&document.getElementById("FCL_IFRAME").remove()}]}}function M(e,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 V(e){return J(M(e).href)}var W,G={"HTTP/GET":"GET","HTTP/POST":"POST"},K=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},X=function(e,r){return"Missing "+K(e,r)+" in Composite Signature."},$=function(e,r){return K(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(M(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=V(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(M(r),{method:G[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(),Y(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=l.uid(),i=V(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){Y(e,r,t),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function Y(e,r,t){console.error("["+e.method+"] Trouble talking to Wallet Provider","\n\n",{authz:e,signable:r},t)}function Z(e,r,t){if(!e.s){if(t instanceof re){if(!t.s)return void(t.o=Z.bind(null,e,r));1&r&&(r=t.s),t=t.v}if(t&&t.then)return void t.then(Z.bind(null,e,r),Z.bind(null,e,2));e.s=r,e.v=t;var n=e.o;n&&n(e)}}var ee=function(e){try{return de(),Promise.resolve(ne()).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(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(X("addr","Address"));if(null==e.keyId)throw new Error(X("keyId"));if(null==e.signature)throw new Error(X("signature"));if(e.addr!==r.addr)throw new Error($("addr","Address"));if(e.keyId!==r.keyId)throw new Error($("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 de(),Promise.resolve(pe()).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)}},re=function(){function e(){}return e.prototype.then=function(r,t){var n=new e,o=this.s;if(o){var i=1&o?r:t;if(i){try{Z(n,1,i(this.v))}catch(e){Z(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?Z(n,1,r?r(o):o):t?Z(n,1,t(o)):Z(n,2,o)}catch(e){Z(n,2,e)}},n},e}();function te(e){return e instanceof re&&1&e.s}var ne=function(){try{return Promise.resolve(new Promise(function(r){try{return de(),Promise.resolve(pe()).then(function(t){return t.loggedIn?r(t):Promise.resolve(e.config().get("challenge.handshake")).then(function(e){var t,o,i,u=(o=(t={handshake:e,l6n:window.location.origin}).l6n,(i=new URL(t.handshake)).searchParams.append("l6n",o),J(i.href))[1];window.addEventListener("message",function e(t){var o=t.data;try{if(o.type===ce)return u(),window.removeEventListener("message",e),Promise.resolve();if(o.type!==se)return Promise.resolve();u(),window.removeEventListener("message",e);var i="did:fcl:"+o.addr,s=o.addr,c=o.services||[];return Promise.resolve(function(e,r){try{if(null==e||null==r)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",r),Promise.resolve(fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var r=[];if(Array.isArray(e.authorizations))for(var t,n=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)}}(o.hks,o.code)).then(function(e){var t,o,u={addr:s,cid:i,loggedIn:!0,services:(t=c,o=e,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o))};return n.send(oe,ue,u),Promise.resolve(pe()).then(function(e){r(e)})})}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},oe="CURRENT_USER",ie="CURRENT_USER/UPDATED",ue="SET_CURRENT_USER",se="FCL::CHALLENGE::RESPONSE",ce="FCL::CHALLENGE::CANCEL",ae='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',le=function(e){try{return sessionStorage.setItem(oe,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},fe=((W={})[n.INIT]=function(e){try{var r=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(ae),r=JSON.parse(sessionStorage.getItem(oe));return null!=r&&e.VERSION!==r.VERSION?(sessionStorage.removeItem(oe),Promise.resolve(e)):Promise.resolve(r||e)}catch(e){return Promise.reject(e)}}()).then(function(t){r.call(e,t)})}catch(e){return Promise.reject(e)}},W[n.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,ie,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[ue]=function(e,r,t){try{return e.merge(t),le(e.all()),e.broadcast(ie,q({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},W.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(ae)),le(e.all()),e.broadcast(ie,q({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},W),de=function(){return n.spawn(fe,oe)};function me(){de(),n.send(oe,"DEL_CURRENT_USER")}function he(e){de();var r=n.spawn(function(r){try{var t;return r.send(oe,n.SUBSCRIBE),Promise.resolve(function(e,r,t){for(var n;;){var o=e();if(te(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=t();if(i&&i.then){if(!te(i)){n=1;break}i=i.s}}var u=new re,s=Z.bind(null,u,2);return(0===n?o.then(a):1===n?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,s):a(o):Z(u,1,i)})).then(void 0,s),u;function c(r){i=r;do{if(!(o=e())||te(o)&&!o.v)return void Z(u,1,i);if(o.then)return void o.then(a).then(void 0,s);te(i=t())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,s)}function a(e){e?(i=t())&&i.then?i.then(c).then(void 0,s):c(i):Z(u,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(o){if("@EXIT"===o.tag)return r.send(oe,n.UNSUBSCRIBE),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return n.send(r,"@EXIT")}}function pe(){return de(),n.send(oe,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var ve=function(){return{authenticate:ne,unauthenticate:me,authorization:ee,subscribe:he,snapshot:pe}};function Pe(){return(Pe=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)}var ye=function(e,r,t){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+t.join("."))}}catch(e){return Promise.reject(e)}},be=function(e){return Promise.resolve(e)},ge=function(e,r,t){try{return Promise.resolve(e.fields.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(je(n.value,r,[].concat(t,[n.name]))).then(function(r){return e[n.name]=r,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(t){var n=e.id&&Ee(r,e.id);return n?Promise.resolve(n(t)):t})}catch(e){return Promise.reject(e)}},we={UInt:ye,Int:ye,UInt8:ye,Int8:ye,UInt16:ye,Int16:ye,UInt32:ye,Int32:ye,UInt64:ye,Int64:ye,UInt128:ye,Int128:ye,UInt256:ye,Int256:ye,Word8:ye,Word16:ye,Word32:ye,Word64:ye,UFix64:be,Fix64:be,String:be,Character:be,Bool:be,Address:be,Void:function(){return Promise.resolve(null)},Optional:function(e,r,t){return Promise.resolve(e?je(e,r,t):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,r,t){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(n){try{return Promise.resolve(je(e,r,[].concat(t,[e.type]))).then(n)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,r,t){try{return Promise.resolve(e.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(je(n.key,r,[].concat(t,[n.key]))).then(function(o){return Promise.resolve(je(n.value,r,[].concat(t,[n.key]))).then(function(r){return e[o]=r,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:ge,Resource:ge,Struct:ge},Ee=function(e,r){var t=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(r):e===r});return r&&t&&e[t]},je=function(e,r,t){try{var n=Ee(r,e.type);if(!n)throw new Error("Undefined Decoder Error: "+e.type+"@"+t.join("."));return Promise.resolve(n(e.value,r,t))}catch(e){return Promise.reject(e)}};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,"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 f.display}}),Object.defineProperty(exports,"sansPrefix",{enumerable:!0,get:function(){return f.sansPrefix}}),Object.defineProperty(exports,"withPrefix",{enumerable:!0,get:function(){return f.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 m.transaction}}),Object.defineProperty(exports,"script",{enumerable:!0,get:function(){return h.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 P.getLatestBlock}}),Object.defineProperty(exports,"getBlockById",{enumerable:!0,get:function(){return y.getBlockById}}),Object.defineProperty(exports,"getBlockByHeight",{enumerable:!0,get:function(){return b.getBlockByHeight}}),Object.defineProperty(exports,"authorization",{enumerable:!0,get:function(){return g.authorization}}),Object.defineProperty(exports,"authorizations",{enumerable:!0,get:function(){return g.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 j.payer}}),Object.defineProperty(exports,"limit",{enumerable:!0,get:function(){return S.limit}}),Object.defineProperty(exports,"ref",{enumerable:!0,get:function(){return O.ref}}),Object.defineProperty(exports,"param",{enumerable:!0,get:function(){return I.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return I.params}}),exports.VERSION="0.0.61-alpha.5",exports.authenticate=function(){return ve().authenticate()},exports.currentUser=ve,exports.decode=function(e,r,t){void 0===r&&(r={}),void 0===t&&(t=[]);var n=Pe({},we,{},r);return Promise.resolve(je(e,n,t))},exports.events=function(e){return{subscribe:function(r){return n.subscriber(e,H,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=L,exports.unauthenticate=function(){return ve().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([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.61",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 e}from"@onflow/config";export{config}from"@onflow/config";import{pipe as t,interaction as r}from"@onflow/interaction";export{isBad,isOk,pipe,why}from"@onflow/interaction";import{resolve as n}from"@onflow/sdk-resolve";import{subscriber as o,spawn as s,snapshoter as a,INIT as i,SUBSCRIBE as c,UPDATED as u,UNSUBSCRIBE as l,SNAPSHOT as d,send as f}from"@onflow/util-actor";import{send as m}from"@onflow/sdk-send";export{send}from"@onflow/sdk-send";import{decode as p}from"@onflow/sdk-decode";export{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 w}from"@onflow/sdk-account";export{account}from"@onflow/sdk-account";import{uid as y}from"@onflow/util-uid";export{display,sansPrefix,withPrefix}from"@onflow/util-address";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");const g=async(e=[],o={})=>(Array.isArray(e)&&(e=await t(r(),e)),JSON.stringify(await n(o)(e))),E=async e=>m([getTransactionStatus(e)]).then(p),v=e=>e.status>=4,b=e=>e.status>=3,P=e=>e.status>=2,k={[i]:async e=>{const t=await E(e.self());v(t)||setTimeout(()=>e.sendSelf("POLL"),2500),e.merge(t)},[c]:(e,t)=>{e.subscribe(t.from),e.send(t.from,u,e.all())},[l]:(e,t)=>{e.unsubscribe(t.from)},[d]:async(e,t)=>{t.reply(e.all())},POLL:async e=>{const t=await E(e.self());var r,n;v(t)||setTimeout(()=>e.sendSelf("POLL"),2500),r=e.all(),n=t,JSON.stringify(r)!==JSON.stringify(n)&&e.broadcast(u,t),e.merge(t)}},S=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},I=e=>s(k,S(e));function T(e){function t(t){return o(S(e),I,t)}function r(e){return function(r={}){const n=r.suppress||!1;return new Promise((r,o)=>{const s=t(t=>{t.statusCode&&!n?(o(t.errorMessage),s()):e(t)&&(r(t),s())})})}}return{snapshot:function(){return a(e,I)},subscribe:t,onceFinalized:r(P),onceExecuted:r(b),onceSealed:r(v)}}T.isUnknown=e=>e.status>=0,T.isPending=e=>e.status>=1,T.isFinalized=P,T.isExecuted=b,T.isSealed=v,T.isExpired=e=>5===e.status;const x=async t=>setTimeout(()=>t.sendSelf("TICK"),await e().get("fcl.eventPollRate",1e4)),R={TICK:async e=>{if(!e.hasSubs())return;let t=e.get("hwm");if(null==t)e.put("hwm",await h()),e.put("tick",await x(e));else{let r=await h();e.put("hwm",r);const n=await m([getEvents(e.self(),t.height,r.height-1)]).then(p);for(let t of n)e.broadcast("UPDATED",t.data);e.put("tick",await x(e))}},[c]:async(e,t)=>{e.hasSubs()||e.put("tick",await x(e)),e.subscribe(t.from)},[l]:(e,t)=>{e.unsubscribe(t.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))}},N=e=>s(R,e);function O(e){return{subscribe:t=>o(e,N,t)}}function L(){return(L=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 C(e){if(document.getElementById("FCL_IFRAME"))return;const t=document.createElement("iframe");return t.src=e,t.id="FCL_IFRAME",t.allow="usb *",t.style.position="fixed",t.style.top="0px",t.style.right="0px",t.style.left="0px",t.style.bottom="0px",t.style.height="100vh",t.style.width="100vw",t.style.display="block",t.style.background="rgba(0,0,0,0.25)",t.style.zIndex=2147483647,t.frameBorder="0",t.style.boxSizing="border-box",document.body.append(t),[t,()=>{document.getElementById("FCL_IFRAME")&&document.getElementById("FCL_IFRAME").remove()}]}async function U(e,t){if(null==e||null==t)return[];const r=new URL(e);r.searchParams.append("code",t);const n=await fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json());if(Array.isArray(n))return n;const o=[];if(Array.isArray(n.authorizations))for(let e of n.authorizations)o.push(L({type:"authz",keyId:n.keyId},e));return null!=n.provider&&o.push(L({type:"authn",id:"wallet-provider#authn"},n.provider)),o}function A(e=[],t=[]){return[...e,...t]}function j(e,t=!0){const r=new URL(e.endpoint);if(t)for(let[t,n]of Object.entries(e.params||{}))r.searchParams.append(t,n);return r}function D(e){return C(j(e).href)}const F={"HTTP/GET":"GET","HTTP/POST":"POST"},z=e=>new Promise(async(t,r)=>{const n=await fetch(j(e),{method:F[e.method],headers:{"Content-Type":"application/json"}}).then(e=>e.json());"APPROVED"===n.status?t(n.compositeSignature):"DECLINED"===n.status?r({status:n.status,reason:n.reason}):setTimeout(()=>{t(z(n.authorizationUpdates))},500)}),_=(e,t)=>null==t?`'${e}'`:`'${e}' (${t})`,B=(e,t)=>`Missing ${_(e,t)} in Composite Signature.`,J=(e,t)=>`${_(e,t)} in Composit Signature did not match the requested ${e}.`,H={"HTTP/POST":async function(e,t){var r=()=>{},n=null;try{const o=await fetch(j(e),{method:"POST",headers:{"Content-Type":"application/json"},body:t?JSON.stringify(t):void 0}).then(e=>e.json());if(o.local&&o.local.length>0){const[e,t]=D(o.local[0]);r=t}n=await z(o.authorizationUpdates)}catch(n){throw r(),M(e,t,n),n}finally{return r(),n}},"IFRAME/RPC":async function(e,t){return new Promise((r,n)=>{try{const o=y(),[s,a]=D(e);setTimeout(()=>{s.contentWindow.postMessage(JSON.parse(JSON.stringify({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params]})),"*")},500);const i=async({data:e})=>{if("object"!=typeof e)return;if("2.0"!==e.jsonrpc)return;if(e.id!==o)return;const t=e.result;"APPROVED"===t.status?(window.removeEventListener("message",i),a(),r(t.compositeSignature)):"DECLINED"===t.status?(window.removeEventListener("message",i),a(),n({status:t.status,reason:t.reason})):(window.removeEventListener("message",i),a(),n({status:"DECLINED",reason:"Status was neither APPROVED nor DECLINED"}))};window.addEventListener("message",i)}catch(r){M(e,t,r),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}})}};function M(e,t,r){console.error(`[${e.method}] Trouble talking to Wallet Provider`,"\n\n",{authz:e,signable:t},r)}const V="CURRENT_USER",W="CURRENT_USER/UPDATED",$='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',G=async e=>(sessionStorage.setItem(V,JSON.stringify(e)),e),q={[i]:async e=>{e.merge(await(async()=>{const e=JSON.parse($),t=JSON.parse(sessionStorage.getItem(V));return null!=t&&e.VERSION!==t.VERSION?(sessionStorage.removeItem(V),e):t||e})())},[c]:(e,t)=>{e.subscribe(t.from),e.send(t.from,W,L({},e.all()))},[l]:(e,t)=>{e.unsubscribe(t.from)},SNAPSHOT:async(e,t)=>{t.reply(L({},e.all()))},SET_CURRENT_USER:async(e,t,r)=>{e.merge(r),G(e.all()),e.broadcast(W,L({},e.all()))},DEL_CURRENT_USER:async(e,t)=>{e.merge(JSON.parse($)),G(e.all()),e.broadcast(W,L({},e.all()))}},K=()=>s(q,V);async function X(){return new Promise(async t=>{K();const r=await ee();if(r.loggedIn)return t(r);const[n,o]=function({handshake:e,l6n:t}){var r=new URL(e);return r.searchParams.append("l6n",t),C(r.href)}({handshake:await e().get("challenge.handshake"),l6n:window.location.origin}),s=async({data:e})=>{if("FCL::CHALLENGE::CANCEL"===e.type)return o(),void window.removeEventListener("message",s);if("FCL::CHALLENGE::RESPONSE"!==e.type)return;o(),window.removeEventListener("message",s);const r={addr:e.addr,cid:"did:fcl:"+e.addr,loggedIn:!0,services:A(e.services||[],await U(e.hks,e.code))};f(V,"SET_CURRENT_USER",r),t(await ee())};window.addEventListener("message",s)})}function Q(){K(),f(V,"DEL_CURRENT_USER")}async function Y(e){K();const t=function(e=[],t){return e.find(e=>e.type===t)}((await X()).services,"authz");let r;return e.role.proposer&&(r=(await te()).keys.find(e=>e.index===t.keyId).sequenceNumber),L({},e,{addr:t.addr,keyId:t.keyId,sequenceNum:r,signature:e.signature||null,signingFunction:async e=>async function(e,t){const r=await H[e.method](e,t);return null==r.sig&&(r.sig=r.signature),null==r.signature&&(r.signature=r.sig),function(e,t){try{if(null==e.addr)throw new Error(B("addr","Address"));if(null==e.keyId)throw new Error(B("keyId"));if(null==e.signature)throw new Error(B("signature"));if(e.addr!==t.addr)throw new Error(J("addr","Address"));if(e.keyId!==t.keyId)throw new Error(J("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)}}(r,e),r}(t,e),resolve:null,roles:e.roles})}function Z(e){K();const t=s(async t=>{for(t.send(V,c);;){const r=await t.receive();if("@EXIT"===r.tag)return void t.send(V,l);e(r.data)}});return()=>f(t,"@EXIT")}function ee(){return K(),f(V,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function te(){K();const{addr:e}=await ee();if(null==e)throw new Error("No Flow Address for Current User");return w(e)}const re=()=>({authenticate:X,unauthenticate:Q,authorization:Y,subscribe:Z,snapshot:ee});function ne(){return(ne=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)}var oe=function(e,t,r){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+r.join("."))}}catch(e){return Promise.reject(e)}},se=function(e){return Promise.resolve(e)},ae=function(e,t,r){try{return Promise.resolve(e.fields.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(ue(n.value,t,[].concat(r,[n.name]))).then(function(t){return e[n.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(r){var n=e.id&&ce(t,e.id);return n?Promise.resolve(n(r)):r})}catch(e){return Promise.reject(e)}},ie={UInt:oe,Int:oe,UInt8:oe,Int8:oe,UInt16:oe,Int16:oe,UInt32:oe,Int32:oe,UInt64:oe,Int64:oe,UInt128:oe,Int128:oe,UInt256:oe,Int256:oe,Word8:oe,Word16:oe,Word32:oe,Word64:oe,UFix64:se,Fix64:se,String:se,Character:se,Bool:se,Address:se,Void:function(){return Promise.resolve(null)},Optional:function(e,t,r){return Promise.resolve(e?ue(e,t,r):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,t,r){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(n){try{return Promise.resolve(ue(e,t,[].concat(r,[e.type]))).then(n)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,t,r){try{return Promise.resolve(e.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(ue(n.key,t,[].concat(r,[n.key]))).then(function(o){return Promise.resolve(ue(n.value,t,[].concat(r,[n.key]))).then(function(t){return e[o]=t,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:ae,Resource:ae,Struct:ae},ce=function(e,t){var r=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(t):e===t});return t&&r&&e[r]},ue=function(e,t,r){try{var n=ce(t,e.type);if(!n)throw new Error("Undefined Decoder Error: "+e.type+"@"+r.join("."));return Promise.resolve(n(e.value,t,r))}catch(e){return Promise.reject(e)}},le=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r=[]);var n=ne({},ie,{},t);return Promise.resolve(ue(e,n,r))};const de=()=>re().authenticate(),fe=()=>re().unauthenticate(),me="0.0.61-alpha.5";export{me as VERSION,de as authenticate,re as currentUser,le as decode,O as events,g as serialize,T as tx,fe 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";export{getTransactionStatus}from"@onflow/sdk-build-transaction-status";import{latestBlock as w}from"@onflow/sdk-latest-block";export{latestBlock}from"@onflow/sdk-latest-block";export{getEvents}from"@onflow/sdk-build-get-events";import{account as h}from"@onflow/sdk-account";export{account}from"@onflow/sdk-account";import{withPrefix as g}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import{uid as y}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 E=async(t=[],r={})=>(Array.isArray(t)&&(t=await e(n(),t)),JSON.stringify(await o(r)(t))),b=async t=>p([getTransactionStatus(t)]).then(m),k=t=>t.status>=4,S=t=>t.status>=3,v=t=>t.status>=2,T={[i]:async t=>{const e=await b(t.self());k(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 b(t.self());var n,o;k(e)||setTimeout(()=>t.sendSelf("POLL"),2500),n=t.all(),o=e,JSON.stringify(n)!==JSON.stringify(o)&&t.broadcast(u,e),t.merge(e)}},x=t=>{if("object"==typeof t&&(t=t.transactionId),null==t)throw new Error("transactionId required");return t},I=t=>s(T,x(t));function P(t){function e(e){return r(x(t),I,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,I)},subscribe:e,onceFinalized:n(v),onceExecuted:n(S),onceSealed:n(k)}}P.isUnknown=t=>t.status>=0,P.isPending=t=>t.status>=1,P.isFinalized=v,P.isExecuted=S,P.isSealed=k,P.isExpired=t=>5===t.status;const R=async e=>setTimeout(()=>e.sendSelf("TICK"),await t().get("fcl.eventPollRate",1e4)),N={TICK:async t=>{if(!t.hasSubs())return;let e=t.get("hwm");if(null==e)t.put("hwm",await w()),t.put("tick",await R(t));else{let n=await w();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 R(t))}},[l]:async(t,e)=>{t.hasSubs()||t.put("tick",await R(t)),t.subscribe(e.from)},[c]:(t,e)=>{t.unsubscribe(e.from),t.hasSubs()||(clearTimeout(t.get("tick")),t.delete("tick"),t.delete("hwm"))}},L=t=>s(N,t);function C(t){return{subscribe:e=>r(t,L,e)}}function O(){return(O=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 A(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 U(t){return`cid:${t.addr||t.name}:${t.pid}`}function D(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 z(t){return A(D(t).href)}const F={"HTTP/GET":"GET","HTTP/POST":"POST"},_=t=>new Promise(async(e,n)=>{const o=await fetch(D(t),{method:F[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(_(o.authorizationUpdates))},500)}),j=(t,e)=>null==e?`'${t}'`:`'${t}' (${e})`,B=(t,e)=>`Missing ${j(t,e)} in Composite Signature.`,J=(t,e)=>`${j(t,e)} in Composit Signature did not match the requested ${t}.`,H={"HTTP/POST":async function(t,e){var n=()=>{},o=null;try{const r=await fetch(D(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]=z(r.local[0]);n=e}o=await _(r.authorizationUpdates)}catch(o){throw n(),$(t,e,o),o}finally{return n(),o}},"IFRAME/RPC":async function(t,e){return new Promise((n,o)=>{try{const r=y(),[s,a]=z(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){$(t,e,n),o({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}})}};function $(t,e,n){console.error(`[${t.method}] Trouble talking to Wallet Provider`,"\n\n",{authz:t,signable:e},n)}const M="CURRENT_USER",V="CURRENT_USER/UPDATED",G='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',W=async t=>(sessionStorage.setItem(M,JSON.stringify(t)),t),q=()=>t().get("persistSession",!0),K={[i]:async t=>{t.merge(JSON.parse(G)),await q()&&t.merge(await(async()=>{const t=JSON.parse(G),e=JSON.parse(sessionStorage.getItem(M));return null!=e&&t.VERSION!==e.VERSION?(sessionStorage.removeItem(M),t):e||t})())},[l]:(t,e)=>{t.subscribe(e.from),t.send(e.from,V,O({},t.all()))},[c]:(t,e)=>{t.unsubscribe(e.from)},SNAPSHOT:async(t,e)=>{e.reply(O({},t.all()))},SET_CURRENT_USER:async(t,e,n)=>{t.merge(n),await q()&&W(t.all()),t.broadcast(V,O({},t.all()))},DEL_CURRENT_USER:async(t,e)=>{t.merge(JSON.parse(G)),await q()&&W(t.all()),t.broadcast(V,O({},t.all()))}},X=()=>s(K,M);async function Q(){return new Promise(async e=>{X();const n=await et();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),A(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(M,"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(O({type:"authz",keyId:o.keyId},t));return null!=o.provider&&r.push(O({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?g(t.addr):null,cid:U(n),loggedIn:!0,services:e}}(t)),e(await et()))};window.addEventListener("message",s)})}function Y(){X(),f(M,"DEL_CURRENT_USER")}async function Z(t){X();const e=function(t=[],e){return t.find(t=>t.type===e)}((await Q()).services,"authz");let n;return t.role.proposer&&(n=(await nt()).keys.find(t=>t.index===e.keyId).sequenceNumber),O({},t,{addr:e.addr,keyId:e.keyId,sequenceNum:n,signature:t.signature||null,signingFunction:async t=>async function(t,e){const n=await H[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(B("addr","Address"));if(null==t.keyId)throw new Error(B("keyId"));if(null==t.signature)throw new Error(B("signature"));if(t.addr!==e.addr)throw new Error(J("addr","Address"));if(t.keyId!==e.keyId)throw new Error(J("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 tt(t){X();const e=s(async e=>{for(e.send(M,l);;){const n=await e.receive();if("@EXIT"===n.tag)return void e.send(M,c);t(n.data)}});return()=>f(e,"@EXIT")}function et(){return X(),f(M,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function nt(){X();const{addr:t}=await et();if(null==t)throw new Error("No Flow Address for Current User");return h(t)}const ot=()=>({authenticate:Q,unauthenticate:Y,authorization:Z,subscribe:tt,snapshot:et}),rt=()=>ot().authenticate(),st=()=>ot().unauthenticate(),at="0.0.61";export{at as VERSION,rt as authenticate,ot as currentUser,C as events,E as serialize,P as tx,st 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 c,subscriber as a,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{getTransactionStatus}from"@onflow/sdk-build-transaction-status";import{latestBlock as v}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{uid as P}from"@onflow/util-uid";export{display,sansPrefix,withPrefix}from"@onflow/util-address";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 y,g,w=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)}},b=function(e){try{return Promise.resolve(m([getTransactionStatus(e)]).then(h))}catch(e){return Promise.reject(e)}},E=function(e){return e.status>=4},k=function(e){return e.status>=3},S=function(e){return e.status>=2},j=((y={})[o]=function(e){try{return Promise.resolve(b(e.self())).then(function(r){E(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},y[i]=function(e,r){e.subscribe(r.from),e.send(r.from,s,e.all())},y[u]=function(e,r){e.unsubscribe(r.from)},y[c]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},y.POLL=function(e){try{return Promise.resolve(b(e.self())).then(function(r){var t,n;E(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)}},y),I=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},x=function(e){return l(j,I(e))};function T(e){function r(r){return a(I(e),x,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,x)},subscribe:r,onceFinalized:t(S),onceExecuted:t(k),onceSealed:t(E)}}function O(){return(O=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 R(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 A(e){var r=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,r){if(e){if("string"==typeof e)return R(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?R(e,void 0):void 0}}(e)))return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}T.isUnknown=function(e){return e.status>=0},T.isPending=function(e){return e.status>=1},T.isFinalized=S,T.isExecuted=k,T.isSealed=E,T.isExpired=function(e){return 5===e.status};var N=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)}},L=((g={}).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(v()).then(function(r){t.call(e,"hwm",r);var n=e.put;return Promise.resolve(N(e)).then(function(r){n.call(e,"tick",r)})})}return Promise.resolve(v()).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=A(r);!(t=n()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(N(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)}},g[i]=function(e,r){try{var t=function(){e.subscribe(r.from)},n=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(N(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)}},g[u]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},g),C=function(e){return l(L,e)};function U(e){return{subscribe:function(r){return a(e,C,r)}}}function D(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 F(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 z(e){return D(F(e).href)}var B,_={"HTTP/GET":"GET","HTTP/POST":"POST"},J=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},H=function(e,r){return"Missing "+J(e,r)+" in Composite Signature."},M=function(e,r){return J(e,r)+" in Composit Signature did not match the requested "+e+"."},V={"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(F(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=z(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(F(r),{method:_[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(),W(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=P(),i=z(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){W(e,r,t),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function W(e,r,t){console.error("["+e.method+"] Trouble talking to Wallet Provider","\n\n",{authz:e,signable:r},t)}function G(e,r,t){if(!e.s){if(t instanceof X){if(!t.s)return void(t.o=G.bind(null,e,r));1&r&&(r=t.s),t=t.v}if(t&&t.then)return void t.then(G.bind(null,e,r),G.bind(null,e,2));e.s=r,e.v=t;var n=e.o;n&&n(e)}}var q=function(){try{return se(),Promise.resolve(ae()).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)}},K=function(e){try{return se(),Promise.resolve(Q()).then(function(r){function t(){return O({},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(V[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(H("addr","Address"));if(null==e.keyId)throw new Error(H("keyId"));if(null==e.signature)throw new Error(H("signature"));if(e.addr!==r.addr)throw new Error(M("addr","Address"));if(e.keyId!==r.keyId)throw new Error(M("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(q()).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)}},X=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{G(n,1,i(this.v))}catch(e){G(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?G(n,1,r?r(o):o):t?G(n,1,t(o)):G(n,2,o)}catch(e){G(n,2,e)}},n},e}();function $(e){return e instanceof X&&1&e.s}var Q=function(){try{return Promise.resolve(new Promise(function(r){try{return se(),Promise.resolve(ae()).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),D(o.href))[1];window.addEventListener("message",function e(t){var n=t.data;try{if(n.type===te)return i(),window.removeEventListener("message",e),Promise.resolve();if(n.type!==re)return Promise.resolve();i(),window.removeEventListener("message",e);var o="did:fcl:"+n.addr,s=n.addr,u=n.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=A(e.authorizations);!(t=n()).done;)r.push(O({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&r.push(O({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(n.hks,n.code)).then(function(e){var t,n,i={addr:s,cid:o,loggedIn:!0,services:(t=u,n=e,void 0===t&&(t=[]),void 0===n&&(n=[]),[].concat(t,n))};return d(Y,ee,i),Promise.resolve(ae()).then(function(e){r(e)})})}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Y="CURRENT_USER",Z="CURRENT_USER/UPDATED",ee="SET_CURRENT_USER",re="FCL::CHALLENGE::RESPONSE",te="FCL::CHALLENGE::CANCEL",ne='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',oe=function(e){try{return sessionStorage.setItem(Y,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},ie=((B={})[o]=function(e){try{var r=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(ne),r=JSON.parse(sessionStorage.getItem(Y));return null!=r&&e.VERSION!==r.VERSION?(sessionStorage.removeItem(Y),Promise.resolve(e)):Promise.resolve(r||e)}catch(e){return Promise.reject(e)}}()).then(function(t){r.call(e,t)})}catch(e){return Promise.reject(e)}},B[i]=function(e,r){e.subscribe(r.from),e.send(r.from,Z,O({},e.all()))},B[u]=function(e,r){e.unsubscribe(r.from)},B.SNAPSHOT=function(e,r){try{return r.reply(O({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},B[ee]=function(e,r,t){try{return e.merge(t),oe(e.all()),e.broadcast(Z,O({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},B.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(ne)),oe(e.all()),e.broadcast(Z,O({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},B),se=function(){return l(ie,Y)};function ue(){se(),d(Y,"DEL_CURRENT_USER")}function ce(e){se();var r=l(function(r){try{var t;return r.send(Y,i),Promise.resolve(function(e,r,t){for(var n;;){var o=e();if($(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=t();if(i&&i.then){if(!$(i)){n=1;break}i=i.s}}var s=new X,u=G.bind(null,s,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,u):a(o):G(s,1,i)})).then(void 0,u),s;function c(r){i=r;do{if(!(o=e())||$(o)&&!o.v)return void G(s,1,i);if(o.then)return void o.then(a).then(void 0,u);$(i=t())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,u)}function a(e){e?(i=t())&&i.then?i.then(c).then(void 0,u):c(i):G(s,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(n){if("@EXIT"===n.tag)return r.send(Y,u),void(t=1);e(n.data)})}))}catch(e){return Promise.reject(e)}});return function(){return d(r,"@EXIT")}}function ae(){return se(),d(Y,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var le=function(){return{authenticate:Q,unauthenticate:ue,authorization:K,subscribe:ce,snapshot:ae}};function fe(){return(fe=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)}var de=function(e,r,t){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+t.join("."))}}catch(e){return Promise.reject(e)}},me=function(e){return Promise.resolve(e)},he=function(e,r,t){try{return Promise.resolve(e.fields.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Pe(n.value,r,[].concat(t,[n.name]))).then(function(r){return e[n.name]=r,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(t){var n=e.id&&pe(r,e.id);return n?Promise.resolve(n(t)):t})}catch(e){return Promise.reject(e)}},ve={UInt:de,Int:de,UInt8:de,Int8:de,UInt16:de,Int16:de,UInt32:de,Int32:de,UInt64:de,Int64:de,UInt128:de,Int128:de,UInt256:de,Int256:de,Word8:de,Word16:de,Word32:de,Word64:de,UFix64:me,Fix64:me,String:me,Character:me,Bool:me,Address:me,Void:function(){return Promise.resolve(null)},Optional:function(e,r,t){return Promise.resolve(e?Pe(e,r,t):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,r,t){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(n){try{return Promise.resolve(Pe(e,r,[].concat(t,[e.type]))).then(n)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,r,t){try{return Promise.resolve(e.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Pe(n.key,r,[].concat(t,[n.key]))).then(function(o){return Promise.resolve(Pe(n.value,r,[].concat(t,[n.key]))).then(function(r){return e[o]=r,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:he,Resource:he,Struct:he},pe=function(e,r){var t=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(r):e===r});return r&&t&&e[t]},Pe=function(e,r,t){try{var n=pe(r,e.type);if(!n)throw new Error("Undefined Decoder Error: "+e.type+"@"+t.join("."));return Promise.resolve(n(e.value,r,t))}catch(e){return Promise.reject(e)}},ye=function(e,r,t){void 0===r&&(r={}),void 0===t&&(t=[]);var n=fe({},ve,{},r);return Promise.resolve(Pe(e,n,t))},ge=function(){return le().authenticate()},we=function(){return le().unauthenticate()},be="0.0.61-alpha.5";export{be as VERSION,ge as authenticate,le as currentUser,ye as decode,U as events,w as serialize,T as tx,we 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";export{getTransactionStatus}from"@onflow/sdk-build-transaction-status";import{latestBlock as v}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 P}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import{uid as y}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 g,w,b=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)}},E=function(e){try{return Promise.resolve(m([getTransactionStatus(e)]).then(h))}catch(e){return Promise.reject(e)}},k=function(e){return e.status>=4},S=function(e){return e.status>=3},j=function(e){return e.status>=2},I=((g={})[o]=function(e){try{return Promise.resolve(E(e.self())).then(function(r){k(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},g[i]=function(e,r){e.subscribe(r.from),e.send(r.from,s,e.all())},g[u]=function(e,r){e.unsubscribe(r.from)},g[a]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},g.POLL=function(e){try{return Promise.resolve(E(e.self())).then(function(r){var t,n;k(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)}},g),T=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},x=function(e){return l(I,T(e))};function R(e){function r(r){return c(T(e),x,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,x)},subscribe:r,onceFinalized:t(j),onceExecuted:t(S),onceSealed:t(k)}}function A(){return(A=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 L(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 N(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 L(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)?L(e,void 0):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}R.isUnknown=function(e){return e.status>=0},R.isPending=function(e){return e.status>=1},R.isFinalized=j,R.isExecuted=S,R.isSealed=k,R.isExpired=function(e){return 5===e.status};var O=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)}},C=((w={}).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(v()).then(function(r){t.call(e,"hwm",r);var n=e.put;return Promise.resolve(O(e)).then(function(r){n.call(e,"tick",r)})})}return Promise.resolve(v()).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=N(r);!(t=n()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(O(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)}},w[i]=function(e,r){try{var t=function(){e.subscribe(r.from)},n=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(O(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)}},w[u]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},w),D=function(e){return l(C,e)};function U(e){return{subscribe:function(r){return c(e,D,r)}}}function z(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 F(e){return"cid:"+(e.addr||e.name)+":"+e.pid}function _(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 B(e){return z(_(e).href)}var J,H={"HTTP/GET":"GET","HTTP/POST":"POST"},M=function(e,r){return null==r?"'"+e+"'":"'"+e+"' ("+r+")"},V=function(e,r){return"Missing "+M(e,r)+" in Composite Signature."},G=function(e,r){return M(e,r)+" in Composit Signature did not match the requested "+e+"."},W={"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(_(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=B(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(_(r),{method:H[r.method],headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(r){"APPROVED"===r.status?t(r.compositeSignature):"DECLINED"===r.status?n({status:r.status,reason:r.reason}):setTimeout(function(){t(e(r.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){n=e})})},function(n){throw t(),q(e,r,n),n})},function(){return t(),n}))}catch(e){return Promise.reject(e)}},"IFRAME/RPC":function(e,r){try{return Promise.resolve(new Promise(function(t,n){try{var o=y(),i=B(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){q(e,r,t),n({status:"DECLINED",reason:"Trouble talking to Wallet Provider"})}}))}catch(e){return Promise.reject(e)}}};function q(e,r,t){console.error("["+e.method+"] Trouble talking to Wallet Provider","\n\n",{authz:e,signable:r},t)}function K(e,r,t){if(!e.s){if(t instanceof Q){if(!t.s)return void(t.o=K.bind(null,e,r));1&r&&(r=t.s),t=t.v}if(t&&t.then)return void t.then(K.bind(null,e,r),K.bind(null,e,2));e.s=r,e.v=t;var n=e.o;n&&n(e)}}var X=function(){try{return ce(),Promise.resolve(de()).then(function(e){var r=e.addr;if(null==r)throw new Error("No Flow Address for Current User");return p(r)})}catch(e){return Promise.reject(e)}},$=function(e){try{return ce(),Promise.resolve(Z()).then(function(r){function t(){return A({},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(W[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(V("addr","Address"));if(null==e.keyId)throw new Error(V("keyId"));if(null==e.signature)throw new Error(V("signature"));if(e.addr!==r.addr)throw new Error(G("addr","Address"));if(e.keyId!==r.keyId)throw new Error(G("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(X()).then(function(e){var r=e.keys.find(function(e){return e.index===i.keyId});o=r.sequenceNumber})}();return s&&s.then?s.then(t):t()})}catch(e){return Promise.reject(e)}},Q=function(){function e(){}return e.prototype.then=function(r,t){var n=new e,o=this.s;if(o){var i=1&o?r:t;if(i){try{K(n,1,i(this.v))}catch(e){K(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?K(n,1,r?r(o):o):t?K(n,1,t(o)):K(n,2,o)}catch(e){K(n,2,e)}},n},e}();function Y(e){return e instanceof Q&&1&e.s}var Z=function(){try{return Promise.resolve(new Promise(function(r){try{return ce(),Promise.resolve(de()).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),z(o.href))[1];window.addEventListener("message",function e(t){var n=t.data;try{return n.type===oe?(i(),window.removeEventListener("message",e),Promise.resolve()):n.type!==ne?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=N(e.authorizations);!(t=n()).done;)r.push(A({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&r.push(A({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?P(e.addr):null,cid:F(s),loggedIn:!0,services:i}})}catch(e){return Promise.reject(e)}}(n)).then(function(e){return d(ee,te,e),Promise.resolve(de()).then(function(e){r(e)})}))}catch(e){return Promise.reject(e)}})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},ee="CURRENT_USER",re="CURRENT_USER/UPDATED",te="SET_CURRENT_USER",ne="FCL::CHALLENGE::RESPONSE",oe="FCL::CHALLENGE::CANCEL",ie='{\n "VERSION": "0.2.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "services":[]\n}',se=function(e){try{return sessionStorage.setItem(ee,JSON.stringify(e)),Promise.resolve(e)}catch(e){return Promise.reject(e)}},ue=function(){return e().get("persistSession",!0)},ae=((J={})[o]=function(e){try{return e.merge(JSON.parse(ie)),Promise.resolve(ue()).then(function(r){var t=function(){if(r){var t=e.merge;return Promise.resolve(function(){try{var e=JSON.parse(ie),r=JSON.parse(sessionStorage.getItem(ee));return null!=r&&e.VERSION!==r.VERSION?(sessionStorage.removeItem(ee),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)}},J[i]=function(e,r){e.subscribe(r.from),e.send(r.from,re,A({},e.all()))},J[u]=function(e,r){e.unsubscribe(r.from)},J.SNAPSHOT=function(e,r){try{return r.reply(A({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},J[te]=function(e,r,t){try{return e.merge(t),Promise.resolve(ue()).then(function(r){r&&se(e.all()),e.broadcast(re,A({},e.all()))})}catch(e){return Promise.reject(e)}},J.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(ie)),Promise.resolve(ue()).then(function(r){r&&se(e.all()),e.broadcast(re,A({},e.all()))})}catch(e){return Promise.reject(e)}},J),ce=function(){return l(ae,ee)};function le(){ce(),d(ee,"DEL_CURRENT_USER")}function fe(e){ce();var r=l(function(r){try{var t;return r.send(ee,i),Promise.resolve(function(e,r,t){for(var n;;){var o=e();if(Y(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=t();if(i&&i.then){if(!Y(i)){n=1;break}i=i.s}}var s=new Q,u=K.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):K(s,1,i)})).then(void 0,u),s;function a(r){i=r;do{if(!(o=e())||Y(o)&&!o.v)return void K(s,1,i);if(o.then)return void o.then(c).then(void 0,u);Y(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):K(s,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(n){if("@EXIT"===n.tag)return r.send(ee,u),void(t=1);e(n.data)})}))}catch(e){return Promise.reject(e)}});return function(){return d(r,"@EXIT")}}function de(){return ce(),d(ee,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var me=function(){return{authenticate:Z,unauthenticate:le,authorization:$,subscribe:fe,snapshot:de}},he=function(){return me().authenticate()},ve=function(){return me().unauthenticate()},pe="0.0.61";export{pe as VERSION,he as authenticate,me as currentUser,U as events,b as serialize,R as tx,ve as unauthenticate};
//# sourceMappingURL=fcl.module.js.map

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@onflow/config"),require("@onflow/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-uid"),require("@onflow/util-address"),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-uid","@onflow/util-address","@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"],r):r((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.utilUid,e.utilAddress,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,r,t,n,o,i,u,s,c,a,l,f,d,m,h,v,p,P,y,b,g,w,k,E,j,S,O,I){r.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var B,T,R=function(e){try{return Promise.resolve(i.send([getTransactionStatus(e)]).then(u.decode))}catch(e){return Promise.reject(e)}},U=function(e){return e.status>=4},A=function(e){return e.status>=3},N=function(e){return e.status>=2},C=((B={})[o.INIT]=function(e){try{return Promise.resolve(R(e.self())).then(function(r){U(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},B[o.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,o.UPDATED,e.all())},B[o.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},B[o.SNAPSHOT]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},B.POLL=function(e){try{return Promise.resolve(R(e.self())).then(function(r){var t,n;U(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),t=e.all(),n=r,JSON.stringify(t)!==JSON.stringify(n)&&e.broadcast(o.UPDATED,r),e.merge(r)})}catch(e){return Promise.reject(e)}},B),L=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},q=function(e){return o.spawn(C,L(e))};function D(e){function r(r){return o.subscriber(L(e),q,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 o.snapshoter(e,q)},subscribe:r,onceFinalized:t(N),onceExecuted:t(A),onceSealed:t(U)}}function x(){return(x=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 z(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function F(e){var r=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,r){if(e){if("string"==typeof e)return z(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?z(e,void 0):void 0}}(e)))return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}D.isUnknown=function(e){return e.status>=0},D.isPending=function(e){return e.status>=1},D.isFinalized=N,D.isExecuted=A,D.isSealed=U,D.isExpired=function(e){return 5===e.status};var _=function(e){try{var t=setTimeout;return Promise.resolve(r.config().get("fcl.eventPollRate",1e4)).then(function(r){return t(function(){return e.sendSelf("TICK")},r)})}catch(e){return Promise.reject(e)}},H=((T={}).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(c.latestBlock()).then(function(r){t.call(e,"hwm",r);var n=e.put;return Promise.resolve(_(e)).then(function(r){n.call(e,"tick",r)})})}return Promise.resolve(c.latestBlock()).then(function(t){return e.put("hwm",t),Promise.resolve(i.send([getEvents(e.self(),r.height,t.height-1)]).then(u.decode)).then(function(r){for(var t,n=F(r);!(t=n()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(_(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)}},T[o.SUBSCRIBE]=function(e,r){try{var t=function(){e.subscribe(r.from)},n=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(_(e)).then(function(t){r.call(e,"tick",t)})}}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},T[o.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},T),G=function(e){return o.spawn(H,e)};function J(e){if(!document.getElementById("FCL_IFRAME")){var r=document.createElement("iframe");return r.src=e,r.id="FCL_IFRAME",r.allow="usb *",r.style.position="fixed",r.style.top="0px",r.style.right="0px",r.style.left="0px",r.style.bottom="0px",r.style.height="100vh",r.style.width="100vw",r.style.display="block",r.style.background="rgba(0,0,0,0.25)",r.style.zIndex=2147483647,r.frameBorder="0",r.style.boxSizing="border-box",document.body.append(r),[r,function(){document.getElementById("FCL_IFRAME")&&document.getElementById("FCL_IFRAME").remove()}]}}function M(e,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 V(e){return J(M(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(M(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=V(e.local[0]);t=r[1]}return Promise.resolve(function e(r){return new Promise(function(t,n){try{return Promise.resolve(fetch(M(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=V(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 x({},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(pe()).then(function(e){var r=e.addr;if(null==r)throw new Error("No Flow Address for Current User");return l.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(e){try{return me(),Promise.resolve(pe()).then(function(t){return t.loggedIn?e(t):Promise.resolve(r.config().get("challenge.handshake")).then(function(r){var t,n,i,u=(n=(t={handshake:r,l6n:window.location.origin}).l6n,(i=new URL(t.handshake)).searchParams.append("l6n",n),J(i.href))[1];window.addEventListener("message",function r(t){var n=t.data;try{if(n.type===ae)return u(),window.removeEventListener("message",r),Promise.resolve();if(n.type!==ce)return Promise.resolve();u(),window.removeEventListener("message",r);var i="did:fcl:"+n.addr,s=n.addr,c=n.services||[];return Promise.resolve(function(e,r){try{if(null==e||null==r)return Promise.resolve([]);var t=new URL(e);return t.searchParams.append("code",r),Promise.resolve(fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var r=[];if(Array.isArray(e.authorizations))for(var t,n=F(e.authorizations);!(t=n()).done;)r.push(x({type:"authz",keyId:e.keyId},t.value));return null!=e.provider&&r.push(x({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(n.hks,n.code)).then(function(r){var t,n,u={addr:s,cid:i,loggedIn:!0,services:(t=c,n=r,void 0===t&&(t=[]),void 0===n&&(n=[]),[].concat(t,n))};return o.send(ie,se,u),Promise.resolve(pe()).then(function(r){e(r)})})}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=((W={})[o.INIT]=function(e){try{var r=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(t){r.call(e,t)})}catch(e){return Promise.reject(e)}},W[o.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,ue,x({},e.all()))},W[o.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},W.SNAPSHOT=function(e,r){try{return r.reply(x({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},W[se]=function(e,r,t){try{return e.merge(t),fe(e.all()),e.broadcast(ue,x({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},W.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(le)),fe(e.all()),e.broadcast(ue,x({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},W),me=function(){return o.spawn(de,ie)};function he(){me(),o.send(ie,"DEL_CURRENT_USER")}function ve(e){me();var r=o.spawn(function(r){try{var t;return r.send(ie,o.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(n){if("@EXIT"===n.tag)return r.send(ie,o.UNSUBSCRIBE),void(t=1);e(n.data)})}))}catch(e){return Promise.reject(e)}});return function(){return o.send(r,"@EXIT")}}function pe(){return me(),o.send(ie,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Pe=function(){return{authenticate:oe,unauthenticate:he,authorization:re,subscribe:ve,snapshot:pe}};function ye(){return(ye=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)}var be=function(e,r,t){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+t.join("."))}}catch(e){return Promise.reject(e)}},ge=function(e){return Promise.resolve(e)},we=function(e,r,t){try{return Promise.resolve(e.fields.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(je(n.value,r,[].concat(t,[n.name]))).then(function(r){return e[n.name]=r,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(t){var n=e.id&&Ee(r,e.id);return n?Promise.resolve(n(t)):t})}catch(e){return Promise.reject(e)}},ke={UInt:be,Int:be,UInt8:be,Int8:be,UInt16:be,Int16:be,UInt32:be,Int32:be,UInt64:be,Int64:be,UInt128:be,Int128:be,UInt256:be,Int256:be,Word8:be,Word16:be,Word32:be,Word64:be,UFix64:ge,Fix64:ge,String:ge,Character:ge,Bool:ge,Address:ge,Void:function(){return Promise.resolve(null)},Optional:function(e,r,t){return Promise.resolve(e?je(e,r,t):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,r,t){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(n){try{return Promise.resolve(je(e,r,[].concat(t,[e.type]))).then(n)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,r,t){try{return Promise.resolve(e.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(je(n.key,r,[].concat(t,[n.key]))).then(function(o){return Promise.resolve(je(n.value,r,[].concat(t,[n.key]))).then(function(r){return e[o]=r,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:we,Resource:we,Struct:we},Ee=function(e,r){var t=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(r):e===r});return r&&t&&e[t]},je=function(e,r,t){try{var n=Ee(r,e.type);if(!n)throw new Error("Undefined Decoder Error: "+e.type+"@"+t.join("."));return Promise.resolve(n(e.value,r,t))}catch(e){return Promise.reject(e)}};Object.defineProperty(e,"config",{enumerable:!0,get:function(){return r.config}}),Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return t.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return t.isOk}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return t.pipe}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return t.why}}),Object.defineProperty(e,"send",{enumerable:!0,get:function(){return i.send}}),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 d.display}}),Object.defineProperty(e,"sansPrefix",{enumerable:!0,get:function(){return d.sansPrefix}}),Object.defineProperty(e,"withPrefix",{enumerable:!0,get:function(){return d.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 P.getAccount}}),Object.defineProperty(e,"getLatestBlock",{enumerable:!0,get:function(){return y.getLatestBlock}}),Object.defineProperty(e,"getBlockById",{enumerable:!0,get:function(){return b.getBlockById}}),Object.defineProperty(e,"getBlockByHeight",{enumerable:!0,get:function(){return g.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 j.payer}}),Object.defineProperty(e,"limit",{enumerable:!0,get:function(){return S.limit}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return O.ref}}),Object.defineProperty(e,"param",{enumerable:!0,get:function(){return I.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return I.params}}),e.VERSION="0.0.61-alpha.5",e.authenticate=function(){return Pe().authenticate()},e.currentUser=Pe,e.decode=function(e,r,t){void 0===r&&(r={}),void 0===t&&(t=[]);var n=ye({},ke,{},r);return Promise.resolve(je(e,n,t))},e.events=function(e){return{subscribe:function(r){return o.subscriber(e,G,r)}}},e.serialize=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{var o=function(){return Promise.resolve(n.resolve(r)(e)).then(JSON.stringify)},i=function(){if(Array.isArray(e))return Promise.resolve(t.pipe(t.interaction(),e)).then(function(r){e=r})}();return Promise.resolve(i&&i.then?i.then(o):o())}catch(e){return Promise.reject(e)}},e.tx=D,e.unauthenticate=function(){return Pe().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([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.61",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.61-alpha.5",
"version": "0.0.61",
"description": "Flow Client Library",

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

"@onflow/config": "0.0.2",
"@onflow/sdk-decode": "0.0.0",
"@onflow/sdk-decode": "0.0.1",
"@onflow/interaction": "0.0.10",
"@onflow/sdk-account": "0.0.0",
"@onflow/sdk-account": "0.0.2",
"@onflow/sdk-build-arguments": "0.0.0",
"@onflow/sdk-build-authorizations": "0.0.0",
"@onflow/sdk-build-authorizations": "0.0.1",
"@onflow/sdk-build-get-account": "0.0.1",

@@ -60,5 +60,5 @@ "@onflow/sdk-build-get-block-by-height": "0.0.0",

"@onflow/sdk-build-validator": "0.0.0",
"@onflow/sdk-latest-block": "0.0.0",
"@onflow/sdk-resolve": "0.0.0",
"@onflow/sdk-send": "0.0.0",
"@onflow/sdk-latest-block": "0.0.2",
"@onflow/sdk-resolve": "0.0.3",
"@onflow/sdk-send": "0.0.2",
"@onflow/util-actor": "0.0.2",

@@ -65,0 +65,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