@onflow/fcl
Advanced tools
Comparing version 0.0.47 to 0.0.48
@@ -5,2 +5,6 @@ ### Unreleased | ||
### 0.0.48 -- 2020-08-13 | ||
- 2020-08-13 -- Removed `resolveSequenceNumber` from default resolver | ||
### 0.0.47 -- 2020-08-13 | ||
@@ -7,0 +11,0 @@ |
@@ -1,2 +0,2 @@ | ||
var e=require("@onflow/config"),n=require("@onflow/sdk"),t=require("@onflow/util-actor"),r=require("@onflow/types");e.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var o,i=function(t){try{return Promise.resolve(e.config().get("accessNode.api")).then(function(r){var o=n.resolveRefBlockId({node:r});return Promise.resolve(e.config().get("accessNode.api")).then(function(e){return n.resolve(t,[o,n.resolveProposerSequenceNumber({node:e}),n.resolveParams,n.resolveArguments,n.resolveAccounts,n.resolveSignatures,n.resolveValidators])})})}catch(e){return Promise.reject(e)}},u=function(t,r){void 0===t&&(t=[]),void 0===r&&(r={});try{var o=function(e){return r.node=e,Array.isArray(t)&&(t=n.build(t)),Promise.resolve(i(t)).then(function(e){return n.send(e,r)})},u=r.node;return Promise.resolve(u?o(u):Promise.resolve(e.config().get("accessNode.api")).then(o))}catch(e){return Promise.reject(e)}},c=function(t){try{return Promise.resolve(e.config().where(/^decoder\./)).then(function(e){var r=Object.fromEntries(Object.entries(e).map(function(e){var n=e[0],t=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",t]}));return n.decodeResponse(t,r)})}catch(e){return Promise.reject(e)}};function s(e,n,t){if(!e.s){if(t instanceof a){if(!t.s)return void(t.o=s.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(s.bind(null,e,n),s.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var a=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{s(r,1,i(this.v))}catch(e){s(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?s(r,1,n?n(o):o):t?s(r,1,t(o)):s(r,2,o)}catch(e){s(r,2,e)}},r},e}();function f(e){return e instanceof a&&1&e.s}var l=function(e){try{return Promise.resolve(u([n.getTransactionStatus(e)])).then(c)}catch(e){return Promise.reject(e)}},d=function(e){return 4===e.status},h=function(e){return 3===e.status||d(e)},p=function(e){return 2===e.status||h(e)},m=function(e){return 1===e.status||p(e)},v=((o={})[t.INIT]=function(e){try{return Promise.resolve(l(e.self())).then(function(n){d(n)||setTimeout(function(){return t.send(e.self(),"POLL")},1e3),e.merge(n)})}catch(e){return Promise.reject(e)}},o[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"TRANSACTION/UPDATED",e.all())},o[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},o.SNAPSHOT=function(e,n){try{return n.replay(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},o.POLL=function(e){try{return Promise.resolve(l(e.self())).then(function(n){d(n)||setTimeout(function(){return t.send(e.self(),"POLL")},1e3),e.merge(n),e.broadcast("TRANSACTION/UPDATED",e.all())})}catch(e){return Promise.reject(e)}},o),y=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return t.spawn(v,e)};function P(e){function n(n){var r=y(e),o=t.spawn(function(e){try{var o;return e.send(r,t.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(f(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!f(i)){r=1;break}i=i.s}}var u=new a,c=s.bind(null,u,2);return(0===r?o.then(d):1===r?i.then(l):(void 0).then(function(){(o=e())?o.then?o.then(d).then(void 0,c):d(o):s(u,1,i)})).then(void 0,c),u;function l(n){i=n;do{if(!(o=e())||f(o)&&!o.v)return void s(u,1,i);if(o.then)return void o.then(d).then(void 0,c);f(i=t())&&(i=i.v)}while(!i||!i.then);i.then(l).then(void 0,c)}function d(e){e?(i=t())&&i.then?i.then(l).then(void 0,c):l(i):s(u,1,i)}}(function(){return!o&&1},0,function(){return Promise.resolve(e.receive()).then(function(i){if("@EXIT"===i.tag)return e.send(r,t.UNSUBSCRIBE),void(o=1);n(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return t.send(o,"@EXIT")}}function r(e){return function(){return new Promise(function(t){var r=n(function(n){e(n)&&(t(n),r())})})}}return{snapshot:function(){var n=y(e);return t.send(n,"SNAPSHOT",null,{expectReply:!0,timeout:10})},subscribe:n,oncePending:r(m),onceFinalized:r(p),onceExecuted:r(h),onceSealed:r(d)}}function g(){return(g=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}P.isUnknown=function(e){return 0===e.status||m(e)},P.isPending=m,P.isFinalized=p,P.isExecuted=h,P.isSealed=d;var b,j="FCL_IFRAME_CHALLENGE",x="FCL_IFRAME_AUTHZ",E=function(e){void 0===e&&(e={});var n=e.addr,t=e.pid;return null==n||null==t?null:n+"/"+t},S={"HTTP/POST":"POST","HTTP/GET":"GET"},w=function(e,n){try{for(var t=new URL(e.endpoint),r=0,o=Object.entries(e.params||{});r<o.length;r++){var i=o[r];t.searchParams.append(i[0],i[1])}return n=n?JSON.stringify(n):void 0,Promise.resolve(fetch(t,{method:S[e.method],headers:{"Content-Type":"application/json"},body:n}).then(function(e){return e.json()}))}catch(e){return Promise.reject(e)}};function O(e,n,t){if(!e.s){if(t instanceof I){if(!t.s)return void(t.o=O.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(O.bind(null,e,n),O.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var T=function(){try{return F(),Promise.resolve(X()).then(function(e){var t=e.addr;if(null==t)throw new Error("No Flow Address for Current User");return Promise.resolve(u([n.getAccount(t)])).then(function(e){return e.account})})}catch(e){return Promise.reject(e)}},R=function(e){try{return F(),Promise.resolve(U()).then(function(){return Promise.resolve(X()).then(function(n){function t(){return g({},e,{addr:n.addr,keyId:n.keyId,sequenceNum:r,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(X()).then(function(n){return Promise.resolve(T()).then(function(t){return Promise.resolve(w(n.authorizations[0],e)).then(function(e){var n=function(){};e.local&&e.local.length>0&&(n=function(e){if(!document.getElementById(x)){for(var n=new URL(e.endpoint),t=0,r=Object.entries(e.params||{});t<r.length;t++){var o=r[t];n.searchParams.append(o[0],o[1])}var i=document.createElement("iframe");return i.src=n.href,i.id=x,i.style.height=e.height||"500px",i.style.maxHeight="90vh",i.style.width=e.width||"400px",i.style.maxWidth="90vw",i.style.display="block",i.style.background=e.background||"#fff",i.style.position="fixed",i.style.top="5vh",i.style.right="calc(50vw)",i.style.transform="translateX(50%)",i.style.boxShadow="0 4px 8px -4px black",i.frameBorder="0",document.body.append(i),function(){document.getElementById(x)&&document.getElementById(x).remove()}}}(e.local[0]));var t=null;return function(e,n){try{var t=e()}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(function(){return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return Promise.resolve(function e(n){return new Promise(function(t,r){try{return Promise.resolve(w(n)).then(function(n){"APPROVED"===n.status?t(n.compositeSignature):"DECLINED"===n.status?r({status:n.status,reason:n.reason}):setTimeout(function(){t(e(n.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){t=e})},function(e){throw console.error(e),e})},function(){return n(),t})})})})}catch(e){return Promise.reject(e)}},resolve:null,roles:e.roles})}var r,o=function(){if(e.role.proposer)return Promise.resolve(T()).then(function(e){var t=e.keys.find(function(e){return e.index===n.keyId});r=t.sequenceNumber})}();return o&&o.then?o.then(t):t()})})}catch(e){return Promise.reject(e)}},I=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{O(r,1,i(this.v))}catch(e){O(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?O(r,1,n?n(o):o):t?O(r,1,t(o)):O(r,2,o)}catch(e){O(r,2,e)}},r},e}();function N(e){return e instanceof I&&1&e.s}var U=function(){try{return Promise.resolve(new Promise(function(n){try{return F(),Promise.resolve(X()).then(function(r){return r.loggedIn?n(r):Promise.resolve(e.config().get("challenge.handshake")).then(function(r){return Promise.resolve(e.config().get("challenge.scope")).then(function(e){var o=function(e){var n=e.handshake,t=e.scope,r=e.nonce,o=e.l6n;if(!document.getElementById(j)){var i=new URL(n);i.searchParams.append("l6n",o),i.searchParams.append("nonce",r),t&&i.searchParams.append("scope",t.split(" ").join("+"));var u=document.createElement("iframe");return u.src=i.href,u.id=j,u.style.height="500px",u.style.maxHeight="90vh",u.style.width="400px",u.style.maxWidth="90vw",u.style.display="block",u.style.background="#fff",u.style.position="fixed",u.style.top="5vh",u.style.right="calc(50vw)",u.style.transform="translateX(50%)",u.style.boxShadow="0 4px 8px -4px black",u.frameBorder="0",document.body.append(u),function(){document.getElementById(j)&&document.getElementById(j).remove()}}}({handshake:r,scope:e,nonce:"asdf",l6n:window.location.origin});window.addEventListener("message",function(e){var r=e.data;try{if(r.type!==C)return Promise.resolve();o();var i=new URL(r.hks);return i.searchParams.append("code",r.code),Promise.resolve(fetch(i,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){return t.send(A,B,g({},e,{cid:E(e.provider),loggedIn:!0,verified:!0})),Promise.resolve(X()).then(function(e){n(e)})})}catch(e){return Promise.reject(e)}})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},A="CURRENT_USER",k="CURRENT_USER/UPDATED",B="SET_CURRENT_USER",C="FCL::CHALLENGE::RESPONSE",L='{\n "cid":null,\n "loggedIn":null,\n "verified":null,\n "identity":{\n "name":null,\n "addr":null,\n "avatar":null,\n "cover":null,\n "color":null,\n "bio":null\n },\n "scoped":{},\n "provider":{\n "addr":null,\n "pid":null,\n "name":null,\n "icon":null\n },\n "authorizations":[]\n}',_=new Set(["verified","identity","scoped","provider"]),z=function(e){return"undefined"!=typeof Proxy&&(e=new Proxy(e,{get:function(e,n){return _.has(n)&&function(e){console.warn(('\n %cFCL Deprecation Notice\n ========================\n\n Access to field "'+e+'" on "CurrentUser" is deprecated and will cease to work in future releases of FCL.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/WARNINGS.md#0001-current-user-data\n\n =======================\n ').replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")}(n),e[n]}})),e},D=((b={})[t.INIT]=function(e){e.merge(JSON.parse(L))},b[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,k,z(e.all()))},b[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},b.SNAPSHOT=function(e,n){try{return n.reply(z(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},b[B]=function(e,n,t){try{return e.merge(t),e.broadcast(k,z(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},b.DEL_CURRENT_USER=function(e,n){try{return e.merge(JSON.parse(L)),e.broadcast(k,z(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},b.GET_AS_PARAM=function(e,n,t){var o=t.key;try{return n.reply({key:o,value:e.get("addr",null),xform:r.Identity}),Promise.resolve()}catch(e){return Promise.reject(e)}},b),F=function(){return t.spawn(D,A)};function H(){F(),t.send(A,"DEL_CURRENT_USER")}function q(e){return function(){try{return F(),Promise.resolve(U()).then(function(){return t.send(A,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})})}catch(e){return Promise.reject(e)}}}function G(e){F();var n=t.spawn(function(n){try{var r;return n.send(A,t.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(N(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!N(i)){r=1;break}i=i.s}}var u=new I,c=O.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(s):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,c):a(o):O(u,1,i)})).then(void 0,c),u;function s(n){i=n;do{if(!(o=e())||N(o)&&!o.v)return void O(u,1,i);if(o.then)return void o.then(a).then(void 0,c);N(i=t())&&(i=i.v)}while(!i||!i.then);i.then(s).then(void 0,c)}function a(e){e?(i=t())&&i.then?i.then(s).then(void 0,c):s(i):O(u,1,i)}}(function(){return!r&&1},0,function(){return Promise.resolve(n.receive()).then(function(o){if("@EXIT"===o.tag)return n.send(A,t.UNSUBSCRIBE),void(r=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return t.send(n,"@EXIT")}}function X(){return F(),t.send(A,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var J=function(){return{authenticate:U,unauthenticate:H,authorization:R,param:q,subscribe:G,snapshot:X}};Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return e.config}}),Object.defineProperty(exports,"arg",{enumerable:!0,get:function(){return n.arg}}),Object.defineProperty(exports,"args",{enumerable:!0,get:function(){return n.args}}),Object.defineProperty(exports,"authorization",{enumerable:!0,get:function(){return n.authorization}}),Object.defineProperty(exports,"authorizations",{enumerable:!0,get:function(){return n.authorizations}}),Object.defineProperty(exports,"build",{enumerable:!0,get:function(){return n.build}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return n.cadence}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return n.cdc}}),Object.defineProperty(exports,"getAccount",{enumerable:!0,get:function(){return n.getAccount}}),Object.defineProperty(exports,"getEvents",{enumerable:!0,get:function(){return n.getEvents}}),Object.defineProperty(exports,"getLatestBlock",{enumerable:!0,get:function(){return n.getLatestBlock}}),Object.defineProperty(exports,"getTransactionStatus",{enumerable:!0,get:function(){return n.getTransactionStatus}}),Object.defineProperty(exports,"isBad",{enumerable:!0,get:function(){return n.isBad}}),Object.defineProperty(exports,"isOk",{enumerable:!0,get:function(){return n.isOk}}),Object.defineProperty(exports,"limit",{enumerable:!0,get:function(){return n.limit}}),Object.defineProperty(exports,"param",{enumerable:!0,get:function(){return n.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return n.params}}),Object.defineProperty(exports,"payer",{enumerable:!0,get:function(){return n.payer}}),Object.defineProperty(exports,"ping",{enumerable:!0,get:function(){return n.ping}}),Object.defineProperty(exports,"pipe",{enumerable:!0,get:function(){return n.pipe}}),Object.defineProperty(exports,"proposer",{enumerable:!0,get:function(){return n.proposer}}),Object.defineProperty(exports,"ref",{enumerable:!0,get:function(){return n.ref}}),Object.defineProperty(exports,"script",{enumerable:!0,get:function(){return n.script}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return n.transaction}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return n.why}}),exports.authenticate=function(){return J().authenticate()},exports.currentUser=J,exports.decode=c,exports.resolve=i,exports.send=u,exports.serialize=function(e){void 0===e&&(e=[]);try{var t=function(){return Promise.resolve(i(e)).then(JSON.stringify)},r=function(){if(Array.isArray(e))return Promise.resolve(n.build(e)).then(function(n){e=n})}();return Promise.resolve(r&&r.then?r.then(t):t())}catch(e){return Promise.reject(e)}},exports.tx=P,exports.unauthenticate=function(){return J().unauthenticate()}; | ||
var e=require("@onflow/config"),n=require("@onflow/sdk"),t=require("@onflow/util-actor"),r=require("@onflow/types");e.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var o,i=function(t){try{return Promise.resolve(e.config().get("accessNode.api")).then(function(e){return n.resolve(t,[n.resolveRefBlockId({node:e}),n.resolveParams,n.resolveArguments,n.resolveAccounts,n.resolveSignatures,n.resolveValidators])})}catch(e){return Promise.reject(e)}},u=function(t,r){void 0===t&&(t=[]),void 0===r&&(r={});try{var o=function(e){return r.node=e,Array.isArray(t)&&(t=n.build(t)),Promise.resolve(i(t)).then(function(e){return n.send(e,r)})},u=r.node;return Promise.resolve(u?o(u):Promise.resolve(e.config().get("accessNode.api")).then(o))}catch(e){return Promise.reject(e)}},c=function(t){try{return Promise.resolve(e.config().where(/^decoder\./)).then(function(e){var r=Object.fromEntries(Object.entries(e).map(function(e){var n=e[0],t=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",t]}));return n.decodeResponse(t,r)})}catch(e){return Promise.reject(e)}};function s(e,n,t){if(!e.s){if(t instanceof a){if(!t.s)return void(t.o=s.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(s.bind(null,e,n),s.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var a=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{s(r,1,i(this.v))}catch(e){s(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?s(r,1,n?n(o):o):t?s(r,1,t(o)):s(r,2,o)}catch(e){s(r,2,e)}},r},e}();function f(e){return e instanceof a&&1&e.s}var l=function(e){try{return Promise.resolve(u([n.getTransactionStatus(e)])).then(c)}catch(e){return Promise.reject(e)}},d=function(e){return 4===e.status},h=function(e){return 3===e.status||d(e)},p=function(e){return 2===e.status||h(e)},m=function(e){return 1===e.status||p(e)},v=((o={})[t.INIT]=function(e){try{return Promise.resolve(l(e.self())).then(function(n){d(n)||setTimeout(function(){return t.send(e.self(),"POLL")},1e3),e.merge(n)})}catch(e){return Promise.reject(e)}},o[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"TRANSACTION/UPDATED",e.all())},o[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},o.SNAPSHOT=function(e,n){try{return n.replay(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},o.POLL=function(e){try{return Promise.resolve(l(e.self())).then(function(n){d(n)||setTimeout(function(){return t.send(e.self(),"POLL")},1e3),e.merge(n),e.broadcast("TRANSACTION/UPDATED",e.all())})}catch(e){return Promise.reject(e)}},o),y=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return t.spawn(v,e)};function P(e){function n(n){var r=y(e),o=t.spawn(function(e){try{var o;return e.send(r,t.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(f(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!f(i)){r=1;break}i=i.s}}var u=new a,c=s.bind(null,u,2);return(0===r?o.then(d):1===r?i.then(l):(void 0).then(function(){(o=e())?o.then?o.then(d).then(void 0,c):d(o):s(u,1,i)})).then(void 0,c),u;function l(n){i=n;do{if(!(o=e())||f(o)&&!o.v)return void s(u,1,i);if(o.then)return void o.then(d).then(void 0,c);f(i=t())&&(i=i.v)}while(!i||!i.then);i.then(l).then(void 0,c)}function d(e){e?(i=t())&&i.then?i.then(l).then(void 0,c):l(i):s(u,1,i)}}(function(){return!o&&1},0,function(){return Promise.resolve(e.receive()).then(function(i){if("@EXIT"===i.tag)return e.send(r,t.UNSUBSCRIBE),void(o=1);n(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return t.send(o,"@EXIT")}}function r(e){return function(){return new Promise(function(t){var r=n(function(n){e(n)&&(t(n),r())})})}}return{snapshot:function(){var n=y(e);return t.send(n,"SNAPSHOT",null,{expectReply:!0,timeout:10})},subscribe:n,oncePending:r(m),onceFinalized:r(p),onceExecuted:r(h),onceSealed:r(d)}}function g(){return(g=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}P.isUnknown=function(e){return 0===e.status||m(e)},P.isPending=m,P.isFinalized=p,P.isExecuted=h,P.isSealed=d;var b,j="FCL_IFRAME_CHALLENGE",x="FCL_IFRAME_AUTHZ",E=function(e){void 0===e&&(e={});var n=e.addr,t=e.pid;return null==n||null==t?null:n+"/"+t},w={"HTTP/POST":"POST","HTTP/GET":"GET"},S=function(e,n){try{for(var t=new URL(e.endpoint),r=0,o=Object.entries(e.params||{});r<o.length;r++){var i=o[r];t.searchParams.append(i[0],i[1])}return n=n?JSON.stringify(n):void 0,Promise.resolve(fetch(t,{method:w[e.method],headers:{"Content-Type":"application/json"},body:n}).then(function(e){return e.json()}))}catch(e){return Promise.reject(e)}};function O(e,n,t){if(!e.s){if(t instanceof I){if(!t.s)return void(t.o=O.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(O.bind(null,e,n),O.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var T=function(){try{return F(),Promise.resolve(X()).then(function(e){var t=e.addr;if(null==t)throw new Error("No Flow Address for Current User");return Promise.resolve(u([n.getAccount(t)])).then(function(e){return e.account})})}catch(e){return Promise.reject(e)}},R=function(e){try{return F(),Promise.resolve(U()).then(function(){return Promise.resolve(X()).then(function(n){function t(){return g({},e,{addr:n.addr,keyId:n.keyId,sequenceNum:r,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(X()).then(function(n){return Promise.resolve(T()).then(function(t){return Promise.resolve(S(n.authorizations[0],e)).then(function(e){var n=function(){};e.local&&e.local.length>0&&(n=function(e){if(!document.getElementById(x)){for(var n=new URL(e.endpoint),t=0,r=Object.entries(e.params||{});t<r.length;t++){var o=r[t];n.searchParams.append(o[0],o[1])}var i=document.createElement("iframe");return i.src=n.href,i.id=x,i.style.height=e.height||"500px",i.style.maxHeight="90vh",i.style.width=e.width||"400px",i.style.maxWidth="90vw",i.style.display="block",i.style.background=e.background||"#fff",i.style.position="fixed",i.style.top="5vh",i.style.right="calc(50vw)",i.style.transform="translateX(50%)",i.style.boxShadow="0 4px 8px -4px black",i.frameBorder="0",document.body.append(i),function(){document.getElementById(x)&&document.getElementById(x).remove()}}}(e.local[0]));var t=null;return function(e,n){try{var t=e()}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(function(){return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return Promise.resolve(function e(n){return new Promise(function(t,r){try{return Promise.resolve(S(n)).then(function(n){"APPROVED"===n.status?t(n.compositeSignature):"DECLINED"===n.status?r({status:n.status,reason:n.reason}):setTimeout(function(){t(e(n.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){t=e})},function(e){throw console.error(e),e})},function(){return n(),t})})})})}catch(e){return Promise.reject(e)}},resolve:null,roles:e.roles})}var r,o=function(){if(e.role.proposer)return Promise.resolve(T()).then(function(e){var t=e.keys.find(function(e){return e.index===n.keyId});r=t.sequenceNumber})}();return o&&o.then?o.then(t):t()})})}catch(e){return Promise.reject(e)}},I=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{O(r,1,i(this.v))}catch(e){O(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?O(r,1,n?n(o):o):t?O(r,1,t(o)):O(r,2,o)}catch(e){O(r,2,e)}},r},e}();function N(e){return e instanceof I&&1&e.s}var U=function(){try{return Promise.resolve(new Promise(function(n){try{return F(),Promise.resolve(X()).then(function(r){return r.loggedIn?n(r):Promise.resolve(e.config().get("challenge.handshake")).then(function(r){return Promise.resolve(e.config().get("challenge.scope")).then(function(e){var o=function(e){var n=e.handshake,t=e.scope,r=e.nonce,o=e.l6n;if(!document.getElementById(j)){var i=new URL(n);i.searchParams.append("l6n",o),i.searchParams.append("nonce",r),t&&i.searchParams.append("scope",t.split(" ").join("+"));var u=document.createElement("iframe");return u.src=i.href,u.id=j,u.style.height="500px",u.style.maxHeight="90vh",u.style.width="400px",u.style.maxWidth="90vw",u.style.display="block",u.style.background="#fff",u.style.position="fixed",u.style.top="5vh",u.style.right="calc(50vw)",u.style.transform="translateX(50%)",u.style.boxShadow="0 4px 8px -4px black",u.frameBorder="0",document.body.append(u),function(){document.getElementById(j)&&document.getElementById(j).remove()}}}({handshake:r,scope:e,nonce:"asdf",l6n:window.location.origin});window.addEventListener("message",function(e){var r=e.data;try{if(r.type!==C)return Promise.resolve();o();var i=new URL(r.hks);return i.searchParams.append("code",r.code),Promise.resolve(fetch(i,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){return t.send(A,B,g({},e,{cid:E(e.provider),loggedIn:!0,verified:!0})),Promise.resolve(X()).then(function(e){n(e)})})}catch(e){return Promise.reject(e)}})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},A="CURRENT_USER",k="CURRENT_USER/UPDATED",B="SET_CURRENT_USER",C="FCL::CHALLENGE::RESPONSE",L='{\n "cid":null,\n "loggedIn":null,\n "verified":null,\n "identity":{\n "name":null,\n "addr":null,\n "avatar":null,\n "cover":null,\n "color":null,\n "bio":null\n },\n "scoped":{},\n "provider":{\n "addr":null,\n "pid":null,\n "name":null,\n "icon":null\n },\n "authorizations":[]\n}',_=new Set(["verified","identity","scoped","provider"]),z=function(e){return"undefined"!=typeof Proxy&&(e=new Proxy(e,{get:function(e,n){return _.has(n)&&function(e){console.warn(('\n %cFCL Deprecation Notice\n ========================\n\n Access to field "'+e+'" on "CurrentUser" is deprecated and will cease to work in future releases of FCL.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/WARNINGS.md#0001-current-user-data\n\n =======================\n ').replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")}(n),e[n]}})),e},D=((b={})[t.INIT]=function(e){e.merge(JSON.parse(L))},b[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,k,z(e.all()))},b[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},b.SNAPSHOT=function(e,n){try{return n.reply(z(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},b[B]=function(e,n,t){try{return e.merge(t),e.broadcast(k,z(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},b.DEL_CURRENT_USER=function(e,n){try{return e.merge(JSON.parse(L)),e.broadcast(k,z(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},b.GET_AS_PARAM=function(e,n,t){var o=t.key;try{return n.reply({key:o,value:e.get("addr",null),xform:r.Identity}),Promise.resolve()}catch(e){return Promise.reject(e)}},b),F=function(){return t.spawn(D,A)};function H(){F(),t.send(A,"DEL_CURRENT_USER")}function G(e){return function(){try{return F(),Promise.resolve(U()).then(function(){return t.send(A,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})})}catch(e){return Promise.reject(e)}}}function q(e){F();var n=t.spawn(function(n){try{var r;return n.send(A,t.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(N(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!N(i)){r=1;break}i=i.s}}var u=new I,c=O.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(s):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,c):a(o):O(u,1,i)})).then(void 0,c),u;function s(n){i=n;do{if(!(o=e())||N(o)&&!o.v)return void O(u,1,i);if(o.then)return void o.then(a).then(void 0,c);N(i=t())&&(i=i.v)}while(!i||!i.then);i.then(s).then(void 0,c)}function a(e){e?(i=t())&&i.then?i.then(s).then(void 0,c):s(i):O(u,1,i)}}(function(){return!r&&1},0,function(){return Promise.resolve(n.receive()).then(function(o){if("@EXIT"===o.tag)return n.send(A,t.UNSUBSCRIBE),void(r=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return t.send(n,"@EXIT")}}function X(){return F(),t.send(A,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var J=function(){return{authenticate:U,unauthenticate:H,authorization:R,param:G,subscribe:q,snapshot:X}};Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return e.config}}),Object.defineProperty(exports,"arg",{enumerable:!0,get:function(){return n.arg}}),Object.defineProperty(exports,"args",{enumerable:!0,get:function(){return n.args}}),Object.defineProperty(exports,"authorization",{enumerable:!0,get:function(){return n.authorization}}),Object.defineProperty(exports,"authorizations",{enumerable:!0,get:function(){return n.authorizations}}),Object.defineProperty(exports,"build",{enumerable:!0,get:function(){return n.build}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return n.cadence}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return n.cdc}}),Object.defineProperty(exports,"getAccount",{enumerable:!0,get:function(){return n.getAccount}}),Object.defineProperty(exports,"getEvents",{enumerable:!0,get:function(){return n.getEvents}}),Object.defineProperty(exports,"getLatestBlock",{enumerable:!0,get:function(){return n.getLatestBlock}}),Object.defineProperty(exports,"getTransactionStatus",{enumerable:!0,get:function(){return n.getTransactionStatus}}),Object.defineProperty(exports,"isBad",{enumerable:!0,get:function(){return n.isBad}}),Object.defineProperty(exports,"isOk",{enumerable:!0,get:function(){return n.isOk}}),Object.defineProperty(exports,"limit",{enumerable:!0,get:function(){return n.limit}}),Object.defineProperty(exports,"param",{enumerable:!0,get:function(){return n.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return n.params}}),Object.defineProperty(exports,"payer",{enumerable:!0,get:function(){return n.payer}}),Object.defineProperty(exports,"ping",{enumerable:!0,get:function(){return n.ping}}),Object.defineProperty(exports,"pipe",{enumerable:!0,get:function(){return n.pipe}}),Object.defineProperty(exports,"proposer",{enumerable:!0,get:function(){return n.proposer}}),Object.defineProperty(exports,"ref",{enumerable:!0,get:function(){return n.ref}}),Object.defineProperty(exports,"script",{enumerable:!0,get:function(){return n.script}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return n.transaction}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return n.why}}),exports.authenticate=function(){return J().authenticate()},exports.currentUser=J,exports.decode=c,exports.resolve=i,exports.send=u,exports.serialize=function(e){void 0===e&&(e=[]);try{var t=function(){return Promise.resolve(i(e)).then(JSON.stringify)},r=function(){if(Array.isArray(e))return Promise.resolve(n.build(e)).then(function(n){e=n})}();return Promise.resolve(r&&r.then?r.then(t):t())}catch(e){return Promise.reject(e)}},exports.tx=P,exports.unauthenticate=function(){return J().unauthenticate()}; | ||
//# sourceMappingURL=fcl.js.map |
@@ -1,2 +0,2 @@ | ||
import{config as e}from"@onflow/config";export{config}from"@onflow/config";import{resolve as t,resolveRefBlockId as n,resolveProposerSequenceNumber as a,resolveParams as o,resolveArguments as r,resolveAccounts as s,resolveSignatures as i,resolveValidators as c,build as l,send as d,decodeResponse as u,getTransactionStatus as p,getAccount as f}from"@onflow/sdk";export{arg,args,authorization,authorizations,build,cadence,cdc,getAccount,getEvents,getLatestBlock,getTransactionStatus,isBad,isOk,limit,param,params,payer,ping,pipe,proposer,ref,script,transaction,why}from"@onflow/sdk";import{send as m,spawn as y,SUBSCRIBE as h,UNSUBSCRIBE as w,INIT as g}from"@onflow/util-actor";import{Identity as E}from"@onflow/types";e().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");const T=async l=>t(l,[n({node:await e().get("accessNode.api")}),a({node:await e().get("accessNode.api")}),o,r,s,i,c]),b=async(t=[],n={})=>(n.node=n.node||await e().get("accessNode.api"),Array.isArray(t)&&(t=l(t)),d(await T(t),n)),S=async(e=[])=>(Array.isArray(e)&&(e=await l(e)),JSON.stringify(await T(e))),R=async t=>{const n=await e().where(/^decoder\./),a=Object.fromEntries(Object.entries(n).map(([e,t])=>[e=`/${e.replace(/^decoder\./,"")}$/`,t]));return u(t,a)},N=async e=>{const t=await b([p(e)]);return R(t)},P=e=>4===e.status,x=e=>3===e.status||P(e),A=e=>2===e.status||x(e),v=e=>1===e.status||A(e),k={[g]:async e=>{const t=await N(e.self());P(t)||setTimeout(()=>m(e.self(),"POLL"),1e3),e.merge(t)},[h]:(e,t)=>{e.subscribe(t.from),e.send(t.from,"TRANSACTION/UPDATED",e.all())},[w]:(e,t)=>{e.unsubscribe(t.from)},SNAPSHOT:async(e,t)=>{t.replay(e.all())},POLL:async e=>{const t=await N(e.self());P(t)||setTimeout(()=>m(e.self(),"POLL"),1e3),e.merge(t),e.broadcast("TRANSACTION/UPDATED",e.all())}},U=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return y(k,e)};function I(e){function t(t){const n=U(e),a=y(async e=>{for(e.send(n,h);;){const a=await e.receive();if("@EXIT"===a.tag)return void e.send(n,w);t(a.data)}});return()=>m(a,"@EXIT")}function n(e){return function(){return new Promise(n=>{const a=t(t=>{e(t)&&(n(t),a())})})}}return{snapshot:function(){const t=U(e);return m(t,"SNAPSHOT",null,{expectReply:!0,timeout:10})},subscribe:t,oncePending:n(v),onceFinalized:n(A),onceExecuted:n(x),onceSealed:n(P)}}I.isUnknown=e=>0===e.status||v(e),I.isPending=v,I.isFinalized=A,I.isExecuted=x,I.isSealed=P;const L="FCL_IFRAME_CHALLENGE",O="FCL_IFRAME_AUTHZ",C=(e={})=>{const t=e.addr,n=e.pid;return null==t||null==n?null:`${t}/${n}`},_={"HTTP/POST":"POST","HTTP/GET":"GET"},D=async(e,t)=>{const n=new URL(e.endpoint);for(let[t,a]of Object.entries(e.params||{}))n.searchParams.append(t,a);return t=t?JSON.stringify(t):void 0,fetch(n,{method:_[e.method],headers:{"Content-Type":"application/json"},body:t}).then(e=>e.json())},F=e=>new Promise(async(t,n)=>{const a=await D(e);"APPROVED"===a.status?t(a.compositeSignature):"DECLINED"===a.status?n({status:a.status,reason:a.reason}):setTimeout(()=>{t(F(a.authorizationUpdates))},500)}),j="CURRENT_USER",H="CURRENT_USER/UPDATED",B='{\n "cid":null,\n "loggedIn":null,\n "verified":null,\n "identity":{\n "name":null,\n "addr":null,\n "avatar":null,\n "cover":null,\n "color":null,\n "bio":null\n },\n "scoped":{},\n "provider":{\n "addr":null,\n "pid":null,\n "name":null,\n "icon":null\n },\n "authorizations":[]\n}',z=new Set(["verified","identity","scoped","provider"]),G=e=>("undefined"!=typeof Proxy&&(e=new Proxy(e,{get:(e,t)=>(z.has(t)&&(e=>{console.warn(`\n %cFCL Deprecation Notice\n ========================\n\n Access to field "${e}" on "CurrentUser" is deprecated and will cease to work in future releases of FCL.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/WARNINGS.md#0001-current-user-data\n\n =======================\n `.replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")})(t),e[t])})),e),X={[g]:e=>{e.merge(JSON.parse(B))},[h]:(e,t)=>{e.subscribe(t.from),e.send(t.from,H,G(e.all()))},[w]:(e,t)=>{e.unsubscribe(t.from)},SNAPSHOT:async(e,t)=>{t.reply(G(e.all()))},SET_CURRENT_USER:async(e,t,n)=>{e.merge(n),e.broadcast(H,G(e.all()))},DEL_CURRENT_USER:async(e,t)=>{e.merge(JSON.parse(B)),e.broadcast(H,G(e.all()))},GET_AS_PARAM:async(e,t,{key:n})=>{t.reply({key:n,value:e.get("addr",null),xform:E})}},$=()=>y(X,j);async function J(){return new Promise(async t=>{$();const n=await Z();if(n.loggedIn)return t(n);const a=function({handshake:e,scope:t,nonce:n,l6n:a}){if(document.getElementById(L))return;var o=new URL(e);o.searchParams.append("l6n",a),o.searchParams.append("nonce",n),t&&o.searchParams.append("scope",t.split(" ").join("+"));const r=document.createElement("iframe");return r.src=o.href,r.id=L,r.style.height="500px",r.style.maxHeight="90vh",r.style.width="400px",r.style.maxWidth="90vw",r.style.display="block",r.style.background="#fff",r.style.position="fixed",r.style.top="5vh",r.style.right="calc(50vw)",r.style.transform="translateX(50%)",r.style.boxShadow="0 4px 8px -4px black",r.frameBorder="0",document.body.append(r),()=>{document.getElementById(L)&&document.getElementById(L).remove()}}({handshake:await e().get("challenge.handshake"),scope:await e().get("challenge.scope"),nonce:"asdf",l6n:window.location.origin});window.addEventListener("message",async({data:e})=>{if("FCL::CHALLENGE::RESPONSE"!==e.type)return;a();const n=new URL(e.hks);n.searchParams.append("code",e.code);const o=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json());m(j,"SET_CURRENT_USER",{...o,cid:C(o.provider),loggedIn:!0,verified:!0}),t(await Z())})})}function M(){$(),m(j,"DEL_CURRENT_USER")}async function q(e){$(),await J();const t=await Z();let n;return e.role.proposer&&(n=(await K()).keys.find(e=>e.index===t.keyId).sequenceNumber),{...e,addr:t.addr,keyId:t.keyId,sequenceNum:n,signature:e.signature||null,signingFunction:async e=>{const t=await Z(),n=(await K(),await D(t.authorizations[0],e));let a=()=>{};n.local&&n.local.length>0&&(a=function(e){if(document.getElementById(O))return;var t=new URL(e.endpoint);for(let[n,a]of Object.entries(e.params||{}))t.searchParams.append(n,a);const n=document.createElement("iframe");return n.src=t.href,n.id=O,n.style.height=e.height||"500px",n.style.maxHeight="90vh",n.style.width=e.width||"400px",n.style.maxWidth="90vw",n.style.display="block",n.style.background=e.background||"#fff",n.style.position="fixed",n.style.top="5vh",n.style.right="calc(50vw)",n.style.transform="translateX(50%)",n.style.boxShadow="0 4px 8px -4px black",n.frameBorder="0",document.body.append(n),()=>{document.getElementById(O)&&document.getElementById(O).remove()}}(n.local[0]));let o=null;try{o=await F(n.authorizationUpdates)}catch(e){throw console.error(e),e}finally{return a(),o}},resolve:null,roles:e.roles}}function W(e){return async function(){return $(),await J(),m(j,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})}}function V(e){$();const t=y(async t=>{for(t.send(j,h);;){const n=await t.receive();if("@EXIT"===n.tag)return void t.send(j,w);e(n.data)}});return()=>m(t,"@EXIT")}function Z(){return $(),m(j,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function K(){$();const{addr:e}=await Z();if(null==e)throw new Error("No Flow Address for Current User");const{account:t}=await b([f(e)]);return t}const Q=()=>({authenticate:J,unauthenticate:M,authorization:q,param:W,subscribe:V,snapshot:Z}),Y=()=>Q().authenticate(),ee=()=>Q().unauthenticate();export{Y as authenticate,Q as currentUser,R as decode,T as resolve,b as send,S as serialize,I as tx,ee as unauthenticate}; | ||
import{config as e}from"@onflow/config";export{config}from"@onflow/config";import{resolve as t,resolveRefBlockId as n,resolveParams as a,resolveArguments as o,resolveAccounts as r,resolveSignatures as s,resolveValidators as i,build as c,send as l,decodeResponse as d,getTransactionStatus as u,getAccount as p}from"@onflow/sdk";export{arg,args,authorization,authorizations,build,cadence,cdc,getAccount,getEvents,getLatestBlock,getTransactionStatus,isBad,isOk,limit,param,params,payer,ping,pipe,proposer,ref,script,transaction,why}from"@onflow/sdk";import{send as f,spawn as m,SUBSCRIBE as y,UNSUBSCRIBE as h,INIT as w}from"@onflow/util-actor";import{Identity as g}from"@onflow/types";e().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");const E=async c=>t(c,[n({node:await e().get("accessNode.api")}),a,o,r,s,i]),T=async(t=[],n={})=>(n.node=n.node||await e().get("accessNode.api"),Array.isArray(t)&&(t=c(t)),l(await E(t),n)),b=async(e=[])=>(Array.isArray(e)&&(e=await c(e)),JSON.stringify(await E(e))),S=async t=>{const n=await e().where(/^decoder\./),a=Object.fromEntries(Object.entries(n).map(([e,t])=>[e=`/${e.replace(/^decoder\./,"")}$/`,t]));return d(t,a)},R=async e=>{const t=await T([u(e)]);return S(t)},P=e=>4===e.status,x=e=>3===e.status||P(e),A=e=>2===e.status||x(e),N=e=>1===e.status||A(e),v={[w]:async e=>{const t=await R(e.self());P(t)||setTimeout(()=>f(e.self(),"POLL"),1e3),e.merge(t)},[y]:(e,t)=>{e.subscribe(t.from),e.send(t.from,"TRANSACTION/UPDATED",e.all())},[h]:(e,t)=>{e.unsubscribe(t.from)},SNAPSHOT:async(e,t)=>{t.replay(e.all())},POLL:async e=>{const t=await R(e.self());P(t)||setTimeout(()=>f(e.self(),"POLL"),1e3),e.merge(t),e.broadcast("TRANSACTION/UPDATED",e.all())}},k=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return m(v,e)};function U(e){function t(t){const n=k(e),a=m(async e=>{for(e.send(n,y);;){const a=await e.receive();if("@EXIT"===a.tag)return void e.send(n,h);t(a.data)}});return()=>f(a,"@EXIT")}function n(e){return function(){return new Promise(n=>{const a=t(t=>{e(t)&&(n(t),a())})})}}return{snapshot:function(){const t=k(e);return f(t,"SNAPSHOT",null,{expectReply:!0,timeout:10})},subscribe:t,oncePending:n(N),onceFinalized:n(A),onceExecuted:n(x),onceSealed:n(P)}}U.isUnknown=e=>0===e.status||N(e),U.isPending=N,U.isFinalized=A,U.isExecuted=x,U.isSealed=P;const I="FCL_IFRAME_CHALLENGE",L="FCL_IFRAME_AUTHZ",O=(e={})=>{const t=e.addr,n=e.pid;return null==t||null==n?null:`${t}/${n}`},C={"HTTP/POST":"POST","HTTP/GET":"GET"},_=async(e,t)=>{const n=new URL(e.endpoint);for(let[t,a]of Object.entries(e.params||{}))n.searchParams.append(t,a);return t=t?JSON.stringify(t):void 0,fetch(n,{method:C[e.method],headers:{"Content-Type":"application/json"},body:t}).then(e=>e.json())},D=e=>new Promise(async(t,n)=>{const a=await _(e);"APPROVED"===a.status?t(a.compositeSignature):"DECLINED"===a.status?n({status:a.status,reason:a.reason}):setTimeout(()=>{t(D(a.authorizationUpdates))},500)}),F="CURRENT_USER",j="CURRENT_USER/UPDATED",H='{\n "cid":null,\n "loggedIn":null,\n "verified":null,\n "identity":{\n "name":null,\n "addr":null,\n "avatar":null,\n "cover":null,\n "color":null,\n "bio":null\n },\n "scoped":{},\n "provider":{\n "addr":null,\n "pid":null,\n "name":null,\n "icon":null\n },\n "authorizations":[]\n}',B=new Set(["verified","identity","scoped","provider"]),z=e=>("undefined"!=typeof Proxy&&(e=new Proxy(e,{get:(e,t)=>(B.has(t)&&(e=>{console.warn(`\n %cFCL Deprecation Notice\n ========================\n\n Access to field "${e}" on "CurrentUser" is deprecated and will cease to work in future releases of FCL.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/WARNINGS.md#0001-current-user-data\n\n =======================\n `.replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")})(t),e[t])})),e),G={[w]:e=>{e.merge(JSON.parse(H))},[y]:(e,t)=>{e.subscribe(t.from),e.send(t.from,j,z(e.all()))},[h]:(e,t)=>{e.unsubscribe(t.from)},SNAPSHOT:async(e,t)=>{t.reply(z(e.all()))},SET_CURRENT_USER:async(e,t,n)=>{e.merge(n),e.broadcast(j,z(e.all()))},DEL_CURRENT_USER:async(e,t)=>{e.merge(JSON.parse(H)),e.broadcast(j,z(e.all()))},GET_AS_PARAM:async(e,t,{key:n})=>{t.reply({key:n,value:e.get("addr",null),xform:g})}},X=()=>m(G,F);async function $(){return new Promise(async t=>{X();const n=await V();if(n.loggedIn)return t(n);const a=function({handshake:e,scope:t,nonce:n,l6n:a}){if(document.getElementById(I))return;var o=new URL(e);o.searchParams.append("l6n",a),o.searchParams.append("nonce",n),t&&o.searchParams.append("scope",t.split(" ").join("+"));const r=document.createElement("iframe");return r.src=o.href,r.id=I,r.style.height="500px",r.style.maxHeight="90vh",r.style.width="400px",r.style.maxWidth="90vw",r.style.display="block",r.style.background="#fff",r.style.position="fixed",r.style.top="5vh",r.style.right="calc(50vw)",r.style.transform="translateX(50%)",r.style.boxShadow="0 4px 8px -4px black",r.frameBorder="0",document.body.append(r),()=>{document.getElementById(I)&&document.getElementById(I).remove()}}({handshake:await e().get("challenge.handshake"),scope:await e().get("challenge.scope"),nonce:"asdf",l6n:window.location.origin});window.addEventListener("message",async({data:e})=>{if("FCL::CHALLENGE::RESPONSE"!==e.type)return;a();const n=new URL(e.hks);n.searchParams.append("code",e.code);const o=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json());f(F,"SET_CURRENT_USER",{...o,cid:O(o.provider),loggedIn:!0,verified:!0}),t(await V())})})}function J(){X(),f(F,"DEL_CURRENT_USER")}async function M(e){X(),await $();const t=await V();let n;return e.role.proposer&&(n=(await Z()).keys.find(e=>e.index===t.keyId).sequenceNumber),{...e,addr:t.addr,keyId:t.keyId,sequenceNum:n,signature:e.signature||null,signingFunction:async e=>{const t=await V(),n=(await Z(),await _(t.authorizations[0],e));let a=()=>{};n.local&&n.local.length>0&&(a=function(e){if(document.getElementById(L))return;var t=new URL(e.endpoint);for(let[n,a]of Object.entries(e.params||{}))t.searchParams.append(n,a);const n=document.createElement("iframe");return n.src=t.href,n.id=L,n.style.height=e.height||"500px",n.style.maxHeight="90vh",n.style.width=e.width||"400px",n.style.maxWidth="90vw",n.style.display="block",n.style.background=e.background||"#fff",n.style.position="fixed",n.style.top="5vh",n.style.right="calc(50vw)",n.style.transform="translateX(50%)",n.style.boxShadow="0 4px 8px -4px black",n.frameBorder="0",document.body.append(n),()=>{document.getElementById(L)&&document.getElementById(L).remove()}}(n.local[0]));let o=null;try{o=await D(n.authorizationUpdates)}catch(e){throw console.error(e),e}finally{return a(),o}},resolve:null,roles:e.roles}}function q(e){return async function(){return X(),await $(),f(F,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})}}function W(e){X();const t=m(async t=>{for(t.send(F,y);;){const n=await t.receive();if("@EXIT"===n.tag)return void t.send(F,h);e(n.data)}});return()=>f(t,"@EXIT")}function V(){return X(),f(F,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function Z(){X();const{addr:e}=await V();if(null==e)throw new Error("No Flow Address for Current User");const{account:t}=await T([p(e)]);return t}const K=()=>({authenticate:$,unauthenticate:J,authorization:M,param:q,subscribe:W,snapshot:V}),Q=()=>K().authenticate(),Y=()=>K().unauthenticate();export{Q as authenticate,K as currentUser,S as decode,E as resolve,T as send,b as serialize,U as tx,Y as unauthenticate}; | ||
//# sourceMappingURL=fcl.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import{config as e}from"@onflow/config";export{config}from"@onflow/config";import{resolveRefBlockId as n,resolve as t,resolveProposerSequenceNumber as r,resolveParams as o,resolveArguments as i,resolveAccounts as u,resolveSignatures as c,resolveValidators as s,build as a,send as f,decodeResponse as l,getTransactionStatus as h,getAccount as d}from"@onflow/sdk";export{arg,args,authorization,authorizations,build,cadence,cdc,getAccount,getEvents,getLatestBlock,getTransactionStatus,isBad,isOk,limit,param,params,payer,ping,pipe,proposer,ref,script,transaction,why}from"@onflow/sdk";import{INIT as v,send as m,SUBSCRIBE as p,UNSUBSCRIBE as y,spawn as P}from"@onflow/util-actor";import{Identity as g}from"@onflow/types";e().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var b,E=function(a){try{return Promise.resolve(e().get("accessNode.api")).then(function(f){var l=n({node:f});return Promise.resolve(e().get("accessNode.api")).then(function(e){return t(a,[l,r({node:e}),o,i,u,c,s])})})}catch(e){return Promise.reject(e)}},w=function(n,t){void 0===n&&(n=[]),void 0===t&&(t={});try{var r=function(e){return t.node=e,Array.isArray(n)&&(n=a(n)),Promise.resolve(E(n)).then(function(e){return f(e,t)})},o=t.node;return Promise.resolve(o?r(o):Promise.resolve(e().get("accessNode.api")).then(r))}catch(e){return Promise.reject(e)}},T=function(e){void 0===e&&(e=[]);try{var n=function(){return Promise.resolve(E(e)).then(JSON.stringify)},t=function(){if(Array.isArray(e))return Promise.resolve(a(e)).then(function(n){e=n})}();return Promise.resolve(t&&t.then?t.then(n):n())}catch(e){return Promise.reject(e)}},j=function(n){try{return Promise.resolve(e().where(/^decoder\./)).then(function(e){var t=Object.fromEntries(Object.entries(e).map(function(e){var n=e[0],t=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",t]}));return l(n,t)})}catch(e){return Promise.reject(e)}};function S(e,n,t){if(!e.s){if(t instanceof k){if(!t.s)return void(t.o=S.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(S.bind(null,e,n),S.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var k=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{S(r,1,i(this.v))}catch(e){S(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?S(r,1,n?n(o):o):t?S(r,1,t(o)):S(r,2,o)}catch(e){S(r,2,e)}},r},e}();function x(e){return e instanceof k&&1&e.s}var A=function(e){try{return Promise.resolve(w([h(e)])).then(j)}catch(e){return Promise.reject(e)}},N=function(e){return 4===e.status},R=function(e){return 3===e.status||N(e)},O=function(e){return 2===e.status||R(e)},I=function(e){return 1===e.status||O(e)},L=((b={})[v]=function(e){try{return Promise.resolve(A(e.self())).then(function(n){N(n)||setTimeout(function(){return m(e.self(),"POLL")},1e3),e.merge(n)})}catch(e){return Promise.reject(e)}},b[p]=function(e,n){e.subscribe(n.from),e.send(n.from,"TRANSACTION/UPDATED",e.all())},b[y]=function(e,n){e.unsubscribe(n.from)},b.SNAPSHOT=function(e,n){try{return n.replay(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},b.POLL=function(e){try{return Promise.resolve(A(e.self())).then(function(n){N(n)||setTimeout(function(){return m(e.self(),"POLL")},1e3),e.merge(n),e.broadcast("TRANSACTION/UPDATED",e.all())})}catch(e){return Promise.reject(e)}},b),U=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return P(L,e)};function C(e){function n(n){var t=U(e),r=P(function(e){try{var r;return e.send(t,p),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(x(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!x(i)){r=1;break}i=i.s}}var u=new k,c=S.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(s):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,c):a(o):S(u,1,i)})).then(void 0,c),u;function s(n){i=n;do{if(!(o=e())||x(o)&&!o.v)return void S(u,1,i);if(o.then)return void o.then(a).then(void 0,c);x(i=t())&&(i=i.v)}while(!i||!i.then);i.then(s).then(void 0,c)}function a(e){e?(i=t())&&i.then?i.then(s).then(void 0,c):s(i):S(u,1,i)}}(function(){return!r&&1},0,function(){return Promise.resolve(e.receive()).then(function(o){if("@EXIT"===o.tag)return e.send(t,y),void(r=1);n(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return m(r,"@EXIT")}}function t(e){return function(){return new Promise(function(t){var r=n(function(n){e(n)&&(t(n),r())})})}}return{snapshot:function(){var n=U(e);return m(n,"SNAPSHOT",null,{expectReply:!0,timeout:10})},subscribe:n,oncePending:t(I),onceFinalized:t(O),onceExecuted:t(R),onceSealed:t(N)}}function _(){return(_=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}C.isUnknown=function(e){return 0===e.status||I(e)},C.isPending=I,C.isFinalized=O,C.isExecuted=R,C.isSealed=N;var D,F="FCL_IFRAME_CHALLENGE",H="FCL_IFRAME_AUTHZ",B=function(e){void 0===e&&(e={});var n=e.addr,t=e.pid;return null==n||null==t?null:n+"/"+t},z={"HTTP/POST":"POST","HTTP/GET":"GET"},G=function(e,n){try{for(var t=new URL(e.endpoint),r=0,o=Object.entries(e.params||{});r<o.length;r++){var i=o[r];t.searchParams.append(i[0],i[1])}return n=n?JSON.stringify(n):void 0,Promise.resolve(fetch(t,{method:z[e.method],headers:{"Content-Type":"application/json"},body:n}).then(function(e){return e.json()}))}catch(e){return Promise.reject(e)}};function X(e,n,t){if(!e.s){if(t instanceof q){if(!t.s)return void(t.o=X.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(X.bind(null,e,n),X.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var J=function(){try{return re(),Promise.resolve(ce()).then(function(e){var n=e.addr;if(null==n)throw new Error("No Flow Address for Current User");return Promise.resolve(w([d(n)])).then(function(e){return e.account})})}catch(e){return Promise.reject(e)}},M=function(e){try{return re(),Promise.resolve(V()).then(function(){return Promise.resolve(ce()).then(function(n){function t(){return _({},e,{addr:n.addr,keyId:n.keyId,sequenceNum:r,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(ce()).then(function(n){return Promise.resolve(J()).then(function(t){return Promise.resolve(G(n.authorizations[0],e)).then(function(e){var n=function(){};e.local&&e.local.length>0&&(n=function(e){if(!document.getElementById(H)){for(var n=new URL(e.endpoint),t=0,r=Object.entries(e.params||{});t<r.length;t++){var o=r[t];n.searchParams.append(o[0],o[1])}var i=document.createElement("iframe");return i.src=n.href,i.id=H,i.style.height=e.height||"500px",i.style.maxHeight="90vh",i.style.width=e.width||"400px",i.style.maxWidth="90vw",i.style.display="block",i.style.background=e.background||"#fff",i.style.position="fixed",i.style.top="5vh",i.style.right="calc(50vw)",i.style.transform="translateX(50%)",i.style.boxShadow="0 4px 8px -4px black",i.frameBorder="0",document.body.append(i),function(){document.getElementById(H)&&document.getElementById(H).remove()}}}(e.local[0]));var t=null;return function(e,n){try{var t=e()}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(function(){return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return Promise.resolve(function e(n){return new Promise(function(t,r){try{return Promise.resolve(G(n)).then(function(n){"APPROVED"===n.status?t(n.compositeSignature):"DECLINED"===n.status?r({status:n.status,reason:n.reason}):setTimeout(function(){t(e(n.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){t=e})},function(e){throw console.error(e),e})},function(){return n(),t})})})})}catch(e){return Promise.reject(e)}},resolve:null,roles:e.roles})}var r,o=function(){if(e.role.proposer)return Promise.resolve(J()).then(function(e){var t=e.keys.find(function(e){return e.index===n.keyId});r=t.sequenceNumber})}();return o&&o.then?o.then(t):t()})})}catch(e){return Promise.reject(e)}},q=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{X(r,1,i(this.v))}catch(e){X(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?X(r,1,n?n(o):o):t?X(r,1,t(o)):X(r,2,o)}catch(e){X(r,2,e)}},r},e}();function W(e){return e instanceof q&&1&e.s}var V=function(){try{return Promise.resolve(new Promise(function(n){try{return re(),Promise.resolve(ce()).then(function(t){return t.loggedIn?n(t):Promise.resolve(e().get("challenge.handshake")).then(function(t){return Promise.resolve(e().get("challenge.scope")).then(function(e){var r=function(e){var n=e.handshake,t=e.scope,r=e.nonce,o=e.l6n;if(!document.getElementById(F)){var i=new URL(n);i.searchParams.append("l6n",o),i.searchParams.append("nonce",r),t&&i.searchParams.append("scope",t.split(" ").join("+"));var u=document.createElement("iframe");return u.src=i.href,u.id=F,u.style.height="500px",u.style.maxHeight="90vh",u.style.width="400px",u.style.maxWidth="90vw",u.style.display="block",u.style.background="#fff",u.style.position="fixed",u.style.top="5vh",u.style.right="calc(50vw)",u.style.transform="translateX(50%)",u.style.boxShadow="0 4px 8px -4px black",u.frameBorder="0",document.body.append(u),function(){document.getElementById(F)&&document.getElementById(F).remove()}}}({handshake:t,scope:e,nonce:"asdf",l6n:window.location.origin});window.addEventListener("message",function(e){var t=e.data;try{if(t.type!==Q)return Promise.resolve();r();var o=new URL(t.hks);return o.searchParams.append("code",t.code),Promise.resolve(fetch(o,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){return m(Z,K,_({},e,{cid:B(e.provider),loggedIn:!0,verified:!0})),Promise.resolve(ce()).then(function(e){n(e)})})}catch(e){return Promise.reject(e)}})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Z="CURRENT_USER",$="CURRENT_USER/UPDATED",K="SET_CURRENT_USER",Q="FCL::CHALLENGE::RESPONSE",Y='{\n "cid":null,\n "loggedIn":null,\n "verified":null,\n "identity":{\n "name":null,\n "addr":null,\n "avatar":null,\n "cover":null,\n "color":null,\n "bio":null\n },\n "scoped":{},\n "provider":{\n "addr":null,\n "pid":null,\n "name":null,\n "icon":null\n },\n "authorizations":[]\n}',ee=new Set(["verified","identity","scoped","provider"]),ne=function(e){return"undefined"!=typeof Proxy&&(e=new Proxy(e,{get:function(e,n){return ee.has(n)&&function(e){console.warn(('\n %cFCL Deprecation Notice\n ========================\n\n Access to field "'+e+'" on "CurrentUser" is deprecated and will cease to work in future releases of FCL.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/WARNINGS.md#0001-current-user-data\n\n =======================\n ').replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")}(n),e[n]}})),e},te=((D={})[v]=function(e){e.merge(JSON.parse(Y))},D[p]=function(e,n){e.subscribe(n.from),e.send(n.from,$,ne(e.all()))},D[y]=function(e,n){e.unsubscribe(n.from)},D.SNAPSHOT=function(e,n){try{return n.reply(ne(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},D[K]=function(e,n,t){try{return e.merge(t),e.broadcast($,ne(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},D.DEL_CURRENT_USER=function(e,n){try{return e.merge(JSON.parse(Y)),e.broadcast($,ne(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},D.GET_AS_PARAM=function(e,n,t){var r=t.key;try{return n.reply({key:r,value:e.get("addr",null),xform:g}),Promise.resolve()}catch(e){return Promise.reject(e)}},D),re=function(){return P(te,Z)};function oe(){re(),m(Z,"DEL_CURRENT_USER")}function ie(e){return function(){try{return re(),Promise.resolve(V()).then(function(){return m(Z,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})})}catch(e){return Promise.reject(e)}}}function ue(e){re();var n=P(function(n){try{var t;return n.send(Z,p),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(W(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!W(i)){r=1;break}i=i.s}}var u=new q,c=X.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(s):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,c):a(o):X(u,1,i)})).then(void 0,c),u;function s(n){i=n;do{if(!(o=e())||W(o)&&!o.v)return void X(u,1,i);if(o.then)return void o.then(a).then(void 0,c);W(i=t())&&(i=i.v)}while(!i||!i.then);i.then(s).then(void 0,c)}function a(e){e?(i=t())&&i.then?i.then(s).then(void 0,c):s(i):X(u,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(n.receive()).then(function(r){if("@EXIT"===r.tag)return n.send(Z,y),void(t=1);e(r.data)})}))}catch(e){return Promise.reject(e)}});return function(){return m(n,"@EXIT")}}function ce(){return re(),m(Z,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var se=function(){return{authenticate:V,unauthenticate:oe,authorization:M,param:ie,subscribe:ue,snapshot:ce}},ae=function(){return se().authenticate()},fe=function(){return se().unauthenticate()};export{ae as authenticate,se as currentUser,j as decode,E as resolve,w as send,T as serialize,C as tx,fe as unauthenticate}; | ||
import{config as e}from"@onflow/config";export{config}from"@onflow/config";import{resolve as n,resolveRefBlockId as t,resolveParams as r,resolveArguments as o,resolveAccounts as i,resolveSignatures as u,resolveValidators as c,build as s,send as a,decodeResponse as f,getTransactionStatus as l,getAccount as h}from"@onflow/sdk";export{arg,args,authorization,authorizations,build,cadence,cdc,getAccount,getEvents,getLatestBlock,getTransactionStatus,isBad,isOk,limit,param,params,payer,ping,pipe,proposer,ref,script,transaction,why}from"@onflow/sdk";import{INIT as d,send as v,SUBSCRIBE as m,UNSUBSCRIBE as p,spawn as y}from"@onflow/util-actor";import{Identity as P}from"@onflow/types";e().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var g,b=function(s){try{return Promise.resolve(e().get("accessNode.api")).then(function(e){return n(s,[t({node:e}),r,o,i,u,c])})}catch(e){return Promise.reject(e)}},E=function(n,t){void 0===n&&(n=[]),void 0===t&&(t={});try{var r=function(e){return t.node=e,Array.isArray(n)&&(n=s(n)),Promise.resolve(b(n)).then(function(e){return a(e,t)})},o=t.node;return Promise.resolve(o?r(o):Promise.resolve(e().get("accessNode.api")).then(r))}catch(e){return Promise.reject(e)}},w=function(e){void 0===e&&(e=[]);try{var n=function(){return Promise.resolve(b(e)).then(JSON.stringify)},t=function(){if(Array.isArray(e))return Promise.resolve(s(e)).then(function(n){e=n})}();return Promise.resolve(t&&t.then?t.then(n):n())}catch(e){return Promise.reject(e)}},T=function(n){try{return Promise.resolve(e().where(/^decoder\./)).then(function(e){var t=Object.fromEntries(Object.entries(e).map(function(e){var n=e[0],t=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",t]}));return f(n,t)})}catch(e){return Promise.reject(e)}};function j(e,n,t){if(!e.s){if(t instanceof S){if(!t.s)return void(t.o=j.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(j.bind(null,e,n),j.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var S=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{j(r,1,i(this.v))}catch(e){j(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?j(r,1,n?n(o):o):t?j(r,1,t(o)):j(r,2,o)}catch(e){j(r,2,e)}},r},e}();function k(e){return e instanceof S&&1&e.s}var x=function(e){try{return Promise.resolve(E([l(e)])).then(T)}catch(e){return Promise.reject(e)}},A=function(e){return 4===e.status},R=function(e){return 3===e.status||A(e)},N=function(e){return 2===e.status||R(e)},O=function(e){return 1===e.status||N(e)},I=((g={})[d]=function(e){try{return Promise.resolve(x(e.self())).then(function(n){A(n)||setTimeout(function(){return v(e.self(),"POLL")},1e3),e.merge(n)})}catch(e){return Promise.reject(e)}},g[m]=function(e,n){e.subscribe(n.from),e.send(n.from,"TRANSACTION/UPDATED",e.all())},g[p]=function(e,n){e.unsubscribe(n.from)},g.SNAPSHOT=function(e,n){try{return n.replay(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},g.POLL=function(e){try{return Promise.resolve(x(e.self())).then(function(n){A(n)||setTimeout(function(){return v(e.self(),"POLL")},1e3),e.merge(n),e.broadcast("TRANSACTION/UPDATED",e.all())})}catch(e){return Promise.reject(e)}},g),L=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return y(I,e)};function U(e){function n(n){var t=L(e),r=y(function(e){try{var r;return e.send(t,m),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(k(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!k(i)){r=1;break}i=i.s}}var u=new S,c=j.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(s):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,c):a(o):j(u,1,i)})).then(void 0,c),u;function s(n){i=n;do{if(!(o=e())||k(o)&&!o.v)return void j(u,1,i);if(o.then)return void o.then(a).then(void 0,c);k(i=t())&&(i=i.v)}while(!i||!i.then);i.then(s).then(void 0,c)}function a(e){e?(i=t())&&i.then?i.then(s).then(void 0,c):s(i):j(u,1,i)}}(function(){return!r&&1},0,function(){return Promise.resolve(e.receive()).then(function(o){if("@EXIT"===o.tag)return e.send(t,p),void(r=1);n(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return v(r,"@EXIT")}}function t(e){return function(){return new Promise(function(t){var r=n(function(n){e(n)&&(t(n),r())})})}}return{snapshot:function(){var n=L(e);return v(n,"SNAPSHOT",null,{expectReply:!0,timeout:10})},subscribe:n,oncePending:t(O),onceFinalized:t(N),onceExecuted:t(R),onceSealed:t(A)}}function C(){return(C=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}U.isUnknown=function(e){return 0===e.status||O(e)},U.isPending=O,U.isFinalized=N,U.isExecuted=R,U.isSealed=A;var _,D="FCL_IFRAME_CHALLENGE",F="FCL_IFRAME_AUTHZ",H=function(e){void 0===e&&(e={});var n=e.addr,t=e.pid;return null==n||null==t?null:n+"/"+t},B={"HTTP/POST":"POST","HTTP/GET":"GET"},z=function(e,n){try{for(var t=new URL(e.endpoint),r=0,o=Object.entries(e.params||{});r<o.length;r++){var i=o[r];t.searchParams.append(i[0],i[1])}return n=n?JSON.stringify(n):void 0,Promise.resolve(fetch(t,{method:B[e.method],headers:{"Content-Type":"application/json"},body:n}).then(function(e){return e.json()}))}catch(e){return Promise.reject(e)}};function G(e,n,t){if(!e.s){if(t instanceof M){if(!t.s)return void(t.o=G.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(G.bind(null,e,n),G.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var X=function(){try{return te(),Promise.resolve(ue()).then(function(e){var n=e.addr;if(null==n)throw new Error("No Flow Address for Current User");return Promise.resolve(E([h(n)])).then(function(e){return e.account})})}catch(e){return Promise.reject(e)}},J=function(e){try{return te(),Promise.resolve(W()).then(function(){return Promise.resolve(ue()).then(function(n){function t(){return C({},e,{addr:n.addr,keyId:n.keyId,sequenceNum:r,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(ue()).then(function(n){return Promise.resolve(X()).then(function(t){return Promise.resolve(z(n.authorizations[0],e)).then(function(e){var n=function(){};e.local&&e.local.length>0&&(n=function(e){if(!document.getElementById(F)){for(var n=new URL(e.endpoint),t=0,r=Object.entries(e.params||{});t<r.length;t++){var o=r[t];n.searchParams.append(o[0],o[1])}var i=document.createElement("iframe");return i.src=n.href,i.id=F,i.style.height=e.height||"500px",i.style.maxHeight="90vh",i.style.width=e.width||"400px",i.style.maxWidth="90vw",i.style.display="block",i.style.background=e.background||"#fff",i.style.position="fixed",i.style.top="5vh",i.style.right="calc(50vw)",i.style.transform="translateX(50%)",i.style.boxShadow="0 4px 8px -4px black",i.frameBorder="0",document.body.append(i),function(){document.getElementById(F)&&document.getElementById(F).remove()}}}(e.local[0]));var t=null;return function(e,n){try{var t=e()}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(function(){return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return Promise.resolve(function e(n){return new Promise(function(t,r){try{return Promise.resolve(z(n)).then(function(n){"APPROVED"===n.status?t(n.compositeSignature):"DECLINED"===n.status?r({status:n.status,reason:n.reason}):setTimeout(function(){t(e(n.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){t=e})},function(e){throw console.error(e),e})},function(){return n(),t})})})})}catch(e){return Promise.reject(e)}},resolve:null,roles:e.roles})}var r,o=function(){if(e.role.proposer)return Promise.resolve(X()).then(function(e){var t=e.keys.find(function(e){return e.index===n.keyId});r=t.sequenceNumber})}();return o&&o.then?o.then(t):t()})})}catch(e){return Promise.reject(e)}},M=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{G(r,1,i(this.v))}catch(e){G(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?G(r,1,n?n(o):o):t?G(r,1,t(o)):G(r,2,o)}catch(e){G(r,2,e)}},r},e}();function q(e){return e instanceof M&&1&e.s}var W=function(){try{return Promise.resolve(new Promise(function(n){try{return te(),Promise.resolve(ue()).then(function(t){return t.loggedIn?n(t):Promise.resolve(e().get("challenge.handshake")).then(function(t){return Promise.resolve(e().get("challenge.scope")).then(function(e){var r=function(e){var n=e.handshake,t=e.scope,r=e.nonce,o=e.l6n;if(!document.getElementById(D)){var i=new URL(n);i.searchParams.append("l6n",o),i.searchParams.append("nonce",r),t&&i.searchParams.append("scope",t.split(" ").join("+"));var u=document.createElement("iframe");return u.src=i.href,u.id=D,u.style.height="500px",u.style.maxHeight="90vh",u.style.width="400px",u.style.maxWidth="90vw",u.style.display="block",u.style.background="#fff",u.style.position="fixed",u.style.top="5vh",u.style.right="calc(50vw)",u.style.transform="translateX(50%)",u.style.boxShadow="0 4px 8px -4px black",u.frameBorder="0",document.body.append(u),function(){document.getElementById(D)&&document.getElementById(D).remove()}}}({handshake:t,scope:e,nonce:"asdf",l6n:window.location.origin});window.addEventListener("message",function(e){var t=e.data;try{if(t.type!==K)return Promise.resolve();r();var o=new URL(t.hks);return o.searchParams.append("code",t.code),Promise.resolve(fetch(o,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){return v(V,$,C({},e,{cid:H(e.provider),loggedIn:!0,verified:!0})),Promise.resolve(ue()).then(function(e){n(e)})})}catch(e){return Promise.reject(e)}})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},V="CURRENT_USER",Z="CURRENT_USER/UPDATED",$="SET_CURRENT_USER",K="FCL::CHALLENGE::RESPONSE",Q='{\n "cid":null,\n "loggedIn":null,\n "verified":null,\n "identity":{\n "name":null,\n "addr":null,\n "avatar":null,\n "cover":null,\n "color":null,\n "bio":null\n },\n "scoped":{},\n "provider":{\n "addr":null,\n "pid":null,\n "name":null,\n "icon":null\n },\n "authorizations":[]\n}',Y=new Set(["verified","identity","scoped","provider"]),ee=function(e){return"undefined"!=typeof Proxy&&(e=new Proxy(e,{get:function(e,n){return Y.has(n)&&function(e){console.warn(('\n %cFCL Deprecation Notice\n ========================\n\n Access to field "'+e+'" on "CurrentUser" is deprecated and will cease to work in future releases of FCL.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/WARNINGS.md#0001-current-user-data\n\n =======================\n ').replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")}(n),e[n]}})),e},ne=((_={})[d]=function(e){e.merge(JSON.parse(Q))},_[m]=function(e,n){e.subscribe(n.from),e.send(n.from,Z,ee(e.all()))},_[p]=function(e,n){e.unsubscribe(n.from)},_.SNAPSHOT=function(e,n){try{return n.reply(ee(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},_[$]=function(e,n,t){try{return e.merge(t),e.broadcast(Z,ee(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},_.DEL_CURRENT_USER=function(e,n){try{return e.merge(JSON.parse(Q)),e.broadcast(Z,ee(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},_.GET_AS_PARAM=function(e,n,t){var r=t.key;try{return n.reply({key:r,value:e.get("addr",null),xform:P}),Promise.resolve()}catch(e){return Promise.reject(e)}},_),te=function(){return y(ne,V)};function re(){te(),v(V,"DEL_CURRENT_USER")}function oe(e){return function(){try{return te(),Promise.resolve(W()).then(function(){return v(V,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})})}catch(e){return Promise.reject(e)}}}function ie(e){te();var n=y(function(n){try{var t;return n.send(V,m),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(q(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!q(i)){r=1;break}i=i.s}}var u=new M,c=G.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(s):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,c):a(o):G(u,1,i)})).then(void 0,c),u;function s(n){i=n;do{if(!(o=e())||q(o)&&!o.v)return void G(u,1,i);if(o.then)return void o.then(a).then(void 0,c);q(i=t())&&(i=i.v)}while(!i||!i.then);i.then(s).then(void 0,c)}function a(e){e?(i=t())&&i.then?i.then(s).then(void 0,c):s(i):G(u,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(n.receive()).then(function(r){if("@EXIT"===r.tag)return n.send(V,p),void(t=1);e(r.data)})}))}catch(e){return Promise.reject(e)}});return function(){return v(n,"@EXIT")}}function ue(){return te(),v(V,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var ce=function(){return{authenticate:W,unauthenticate:re,authorization:J,param:oe,subscribe:ie,snapshot:ue}},se=function(){return ce().authenticate()},ae=function(){return ce().unauthenticate()};export{se as authenticate,ce as currentUser,T as decode,b as resolve,E as send,w as serialize,U as tx,ae as unauthenticate}; | ||
//# sourceMappingURL=fcl.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/config"),require("@onflow/sdk"),require("@onflow/util-actor"),require("@onflow/types")):"function"==typeof define&&define.amd?define(["exports","@onflow/config","@onflow/sdk","@onflow/util-actor","@onflow/types"],n):n((e=e||self).fcl={},e.config,e.sdk,e.utilActor,e.types)}(this,function(e,n,t,r,o){n.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var i,u=function(e){try{return Promise.resolve(n.config().get("accessNode.api")).then(function(r){var o=t.resolveRefBlockId({node:r});return Promise.resolve(n.config().get("accessNode.api")).then(function(n){return t.resolve(e,[o,t.resolveProposerSequenceNumber({node:n}),t.resolveParams,t.resolveArguments,t.resolveAccounts,t.resolveSignatures,t.resolveValidators])})})}catch(e){return Promise.reject(e)}},c=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{var o=function(n){return r.node=n,Array.isArray(e)&&(e=t.build(e)),Promise.resolve(u(e)).then(function(e){return t.send(e,r)})},i=r.node;return Promise.resolve(i?o(i):Promise.resolve(n.config().get("accessNode.api")).then(o))}catch(e){return Promise.reject(e)}},s=function(e){try{return Promise.resolve(n.config().where(/^decoder\./)).then(function(n){var r=Object.fromEntries(Object.entries(n).map(function(e){var n=e[0],t=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",t]}));return t.decodeResponse(e,r)})}catch(e){return Promise.reject(e)}};function a(e,n,t){if(!e.s){if(t instanceof f){if(!t.s)return void(t.o=a.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(a.bind(null,e,n),a.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var f=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{a(r,1,i(this.v))}catch(e){a(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?a(r,1,n?n(o):o):t?a(r,1,t(o)):a(r,2,o)}catch(e){a(r,2,e)}},r},e}();function l(e){return e instanceof f&&1&e.s}var d=function(e){try{return Promise.resolve(c([t.getTransactionStatus(e)])).then(s)}catch(e){return Promise.reject(e)}},h=function(e){return 4===e.status},m=function(e){return 3===e.status||h(e)},v=function(e){return 2===e.status||m(e)},p=function(e){return 1===e.status||v(e)},y=((i={})[r.INIT]=function(e){try{return Promise.resolve(d(e.self())).then(function(n){h(n)||setTimeout(function(){return r.send(e.self(),"POLL")},1e3),e.merge(n)})}catch(e){return Promise.reject(e)}},i[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"TRANSACTION/UPDATED",e.all())},i[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},i.SNAPSHOT=function(e,n){try{return n.replay(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},i.POLL=function(e){try{return Promise.resolve(d(e.self())).then(function(n){h(n)||setTimeout(function(){return r.send(e.self(),"POLL")},1e3),e.merge(n),e.broadcast("TRANSACTION/UPDATED",e.all())})}catch(e){return Promise.reject(e)}},i),P=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return r.spawn(y,e)};function g(e){function n(n){var t=P(e),o=r.spawn(function(e){try{var o;return e.send(t,r.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(l(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!l(i)){r=1;break}i=i.s}}var u=new f,c=a.bind(null,u,2);return(0===r?o.then(d):1===r?i.then(s):(void 0).then(function(){(o=e())?o.then?o.then(d).then(void 0,c):d(o):a(u,1,i)})).then(void 0,c),u;function s(n){i=n;do{if(!(o=e())||l(o)&&!o.v)return void a(u,1,i);if(o.then)return void o.then(d).then(void 0,c);l(i=t())&&(i=i.v)}while(!i||!i.then);i.then(s).then(void 0,c)}function d(e){e?(i=t())&&i.then?i.then(s).then(void 0,c):s(i):a(u,1,i)}}(function(){return!o&&1},0,function(){return Promise.resolve(e.receive()).then(function(i){if("@EXIT"===i.tag)return e.send(t,r.UNSUBSCRIBE),void(o=1);n(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return r.send(o,"@EXIT")}}function t(e){return function(){return new Promise(function(t){var r=n(function(n){e(n)&&(t(n),r())})})}}return{snapshot:function(){var n=P(e);return r.send(n,"SNAPSHOT",null,{expectReply:!0,timeout:10})},subscribe:n,oncePending:t(p),onceFinalized:t(v),onceExecuted:t(m),onceSealed:t(h)}}function b(){return(b=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}g.isUnknown=function(e){return 0===e.status||p(e)},g.isPending=p,g.isFinalized=v,g.isExecuted=m,g.isSealed=h;var j,E="FCL_IFRAME_CHALLENGE",w="FCL_IFRAME_AUTHZ",S=function(e){void 0===e&&(e={});var n=e.addr,t=e.pid;return null==n||null==t?null:n+"/"+t},O={"HTTP/POST":"POST","HTTP/GET":"GET"},T=function(e,n){try{for(var t=new URL(e.endpoint),r=0,o=Object.entries(e.params||{});r<o.length;r++){var i=o[r];t.searchParams.append(i[0],i[1])}return n=n?JSON.stringify(n):void 0,Promise.resolve(fetch(t,{method:O[e.method],headers:{"Content-Type":"application/json"},body:n}).then(function(e){return e.json()}))}catch(e){return Promise.reject(e)}};function R(e,n,t){if(!e.s){if(t instanceof A){if(!t.s)return void(t.o=R.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(R.bind(null,e,n),R.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var I=function(){try{return H(),Promise.resolve(J()).then(function(e){var n=e.addr;if(null==n)throw new Error("No Flow Address for Current User");return Promise.resolve(c([t.getAccount(n)])).then(function(e){return e.account})})}catch(e){return Promise.reject(e)}},N=function(e){try{return H(),Promise.resolve(k()).then(function(){return Promise.resolve(J()).then(function(n){function t(){return b({},e,{addr:n.addr,keyId:n.keyId,sequenceNum:r,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(J()).then(function(n){return Promise.resolve(I()).then(function(t){return Promise.resolve(T(n.authorizations[0],e)).then(function(e){var n=function(){};e.local&&e.local.length>0&&(n=function(e){if(!document.getElementById(w)){for(var n=new URL(e.endpoint),t=0,r=Object.entries(e.params||{});t<r.length;t++){var o=r[t];n.searchParams.append(o[0],o[1])}var i=document.createElement("iframe");return i.src=n.href,i.id=w,i.style.height=e.height||"500px",i.style.maxHeight="90vh",i.style.width=e.width||"400px",i.style.maxWidth="90vw",i.style.display="block",i.style.background=e.background||"#fff",i.style.position="fixed",i.style.top="5vh",i.style.right="calc(50vw)",i.style.transform="translateX(50%)",i.style.boxShadow="0 4px 8px -4px black",i.frameBorder="0",document.body.append(i),function(){document.getElementById(w)&&document.getElementById(w).remove()}}}(e.local[0]));var t=null;return function(e,n){try{var t=e()}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(function(){return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return Promise.resolve(function e(n){return new Promise(function(t,r){try{return Promise.resolve(T(n)).then(function(n){"APPROVED"===n.status?t(n.compositeSignature):"DECLINED"===n.status?r({status:n.status,reason:n.reason}):setTimeout(function(){t(e(n.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){t=e})},function(e){throw console.error(e),e})},function(){return n(),t})})})})}catch(e){return Promise.reject(e)}},resolve:null,roles:e.roles})}var r,o=function(){if(e.role.proposer)return Promise.resolve(I()).then(function(e){var t=e.keys.find(function(e){return e.index===n.keyId});r=t.sequenceNumber})}();return o&&o.then?o.then(t):t()})})}catch(e){return Promise.reject(e)}},A=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{R(r,1,i(this.v))}catch(e){R(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?R(r,1,n?n(o):o):t?R(r,1,t(o)):R(r,2,o)}catch(e){R(r,2,e)}},r},e}();function U(e){return e instanceof A&&1&e.s}var k=function(){try{return Promise.resolve(new Promise(function(e){try{return H(),Promise.resolve(J()).then(function(t){return t.loggedIn?e(t):Promise.resolve(n.config().get("challenge.handshake")).then(function(t){return Promise.resolve(n.config().get("challenge.scope")).then(function(n){var o=function(e){var n=e.handshake,t=e.scope,r=e.nonce,o=e.l6n;if(!document.getElementById(E)){var i=new URL(n);i.searchParams.append("l6n",o),i.searchParams.append("nonce",r),t&&i.searchParams.append("scope",t.split(" ").join("+"));var u=document.createElement("iframe");return u.src=i.href,u.id=E,u.style.height="500px",u.style.maxHeight="90vh",u.style.width="400px",u.style.maxWidth="90vw",u.style.display="block",u.style.background="#fff",u.style.position="fixed",u.style.top="5vh",u.style.right="calc(50vw)",u.style.transform="translateX(50%)",u.style.boxShadow="0 4px 8px -4px black",u.frameBorder="0",document.body.append(u),function(){document.getElementById(E)&&document.getElementById(E).remove()}}}({handshake:t,scope:n,nonce:"asdf",l6n:window.location.origin});window.addEventListener("message",function(n){var t=n.data;try{if(t.type!==L)return Promise.resolve();o();var i=new URL(t.hks);return i.searchParams.append("code",t.code),Promise.resolve(fetch(i,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(n){return r.send(x,C,b({},n,{cid:S(n.provider),loggedIn:!0,verified:!0})),Promise.resolve(J()).then(function(n){e(n)})})}catch(e){return Promise.reject(e)}})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},x="CURRENT_USER",B="CURRENT_USER/UPDATED",C="SET_CURRENT_USER",L="FCL::CHALLENGE::RESPONSE",_='{\n "cid":null,\n "loggedIn":null,\n "verified":null,\n "identity":{\n "name":null,\n "addr":null,\n "avatar":null,\n "cover":null,\n "color":null,\n "bio":null\n },\n "scoped":{},\n "provider":{\n "addr":null,\n "pid":null,\n "name":null,\n "icon":null\n },\n "authorizations":[]\n}',z=new Set(["verified","identity","scoped","provider"]),D=function(e){return"undefined"!=typeof Proxy&&(e=new Proxy(e,{get:function(e,n){return z.has(n)&&function(e){console.warn(('\n %cFCL Deprecation Notice\n ========================\n\n Access to field "'+e+'" on "CurrentUser" is deprecated and will cease to work in future releases of FCL.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/WARNINGS.md#0001-current-user-data\n\n =======================\n ').replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")}(n),e[n]}})),e},F=((j={})[r.INIT]=function(e){e.merge(JSON.parse(_))},j[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,B,D(e.all()))},j[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},j.SNAPSHOT=function(e,n){try{return n.reply(D(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},j[C]=function(e,n,t){try{return e.merge(t),e.broadcast(B,D(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},j.DEL_CURRENT_USER=function(e,n){try{return e.merge(JSON.parse(_)),e.broadcast(B,D(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},j.GET_AS_PARAM=function(e,n,t){var r=t.key;try{return n.reply({key:r,value:e.get("addr",null),xform:o.Identity}),Promise.resolve()}catch(e){return Promise.reject(e)}},j),H=function(){return r.spawn(F,x)};function q(){H(),r.send(x,"DEL_CURRENT_USER")}function G(e){return function(){try{return H(),Promise.resolve(k()).then(function(){return r.send(x,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})})}catch(e){return Promise.reject(e)}}}function X(e){H();var n=r.spawn(function(n){try{var t;return n.send(x,r.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(U(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!U(i)){r=1;break}i=i.s}}var u=new A,c=R.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(s):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,c):a(o):R(u,1,i)})).then(void 0,c),u;function s(n){i=n;do{if(!(o=e())||U(o)&&!o.v)return void R(u,1,i);if(o.then)return void o.then(a).then(void 0,c);U(i=t())&&(i=i.v)}while(!i||!i.then);i.then(s).then(void 0,c)}function a(e){e?(i=t())&&i.then?i.then(s).then(void 0,c):s(i):R(u,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(n.receive()).then(function(o){if("@EXIT"===o.tag)return n.send(x,r.UNSUBSCRIBE),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return r.send(n,"@EXIT")}}function J(){return H(),r.send(x,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var M=function(){return{authenticate:k,unauthenticate:q,authorization:N,param:G,subscribe:X,snapshot:J}};Object.defineProperty(e,"config",{enumerable:!0,get:function(){return n.config}}),Object.defineProperty(e,"arg",{enumerable:!0,get:function(){return t.arg}}),Object.defineProperty(e,"args",{enumerable:!0,get:function(){return t.args}}),Object.defineProperty(e,"authorization",{enumerable:!0,get:function(){return t.authorization}}),Object.defineProperty(e,"authorizations",{enumerable:!0,get:function(){return t.authorizations}}),Object.defineProperty(e,"build",{enumerable:!0,get:function(){return t.build}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return t.cadence}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return t.cdc}}),Object.defineProperty(e,"getAccount",{enumerable:!0,get:function(){return t.getAccount}}),Object.defineProperty(e,"getEvents",{enumerable:!0,get:function(){return t.getEvents}}),Object.defineProperty(e,"getLatestBlock",{enumerable:!0,get:function(){return t.getLatestBlock}}),Object.defineProperty(e,"getTransactionStatus",{enumerable:!0,get:function(){return t.getTransactionStatus}}),Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return t.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return t.isOk}}),Object.defineProperty(e,"limit",{enumerable:!0,get:function(){return t.limit}}),Object.defineProperty(e,"param",{enumerable:!0,get:function(){return t.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return t.params}}),Object.defineProperty(e,"payer",{enumerable:!0,get:function(){return t.payer}}),Object.defineProperty(e,"ping",{enumerable:!0,get:function(){return t.ping}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return t.pipe}}),Object.defineProperty(e,"proposer",{enumerable:!0,get:function(){return t.proposer}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return t.ref}}),Object.defineProperty(e,"script",{enumerable:!0,get:function(){return t.script}}),Object.defineProperty(e,"transaction",{enumerable:!0,get:function(){return t.transaction}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return t.why}}),e.authenticate=function(){return M().authenticate()},e.currentUser=M,e.decode=s,e.resolve=u,e.send=c,e.serialize=function(e){void 0===e&&(e=[]);try{var n=function(){return Promise.resolve(u(e)).then(JSON.stringify)},r=function(){if(Array.isArray(e))return Promise.resolve(t.build(e)).then(function(n){e=n})}();return Promise.resolve(r&&r.then?r.then(n):n())}catch(e){return Promise.reject(e)}},e.tx=g,e.unauthenticate=function(){return M().unauthenticate()}}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/config"),require("@onflow/sdk"),require("@onflow/util-actor"),require("@onflow/types")):"function"==typeof define&&define.amd?define(["exports","@onflow/config","@onflow/sdk","@onflow/util-actor","@onflow/types"],n):n((e=e||self).fcl={},e.config,e.sdk,e.utilActor,e.types)}(this,function(e,n,t,r,o){n.config().put("accessNode.api","http://localhost:8080").put("challenge.handshake","http://localhost:8700/authenticate");var i,u=function(e){try{return Promise.resolve(n.config().get("accessNode.api")).then(function(n){return t.resolve(e,[t.resolveRefBlockId({node:n}),t.resolveParams,t.resolveArguments,t.resolveAccounts,t.resolveSignatures,t.resolveValidators])})}catch(e){return Promise.reject(e)}},c=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{var o=function(n){return r.node=n,Array.isArray(e)&&(e=t.build(e)),Promise.resolve(u(e)).then(function(e){return t.send(e,r)})},i=r.node;return Promise.resolve(i?o(i):Promise.resolve(n.config().get("accessNode.api")).then(o))}catch(e){return Promise.reject(e)}},s=function(e){try{return Promise.resolve(n.config().where(/^decoder\./)).then(function(n){var r=Object.fromEntries(Object.entries(n).map(function(e){var n=e[0],t=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",t]}));return t.decodeResponse(e,r)})}catch(e){return Promise.reject(e)}};function a(e,n,t){if(!e.s){if(t instanceof f){if(!t.s)return void(t.o=a.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(a.bind(null,e,n),a.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var f=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{a(r,1,i(this.v))}catch(e){a(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?a(r,1,n?n(o):o):t?a(r,1,t(o)):a(r,2,o)}catch(e){a(r,2,e)}},r},e}();function l(e){return e instanceof f&&1&e.s}var d=function(e){try{return Promise.resolve(c([t.getTransactionStatus(e)])).then(s)}catch(e){return Promise.reject(e)}},h=function(e){return 4===e.status},m=function(e){return 3===e.status||h(e)},v=function(e){return 2===e.status||m(e)},p=function(e){return 1===e.status||v(e)},y=((i={})[r.INIT]=function(e){try{return Promise.resolve(d(e.self())).then(function(n){h(n)||setTimeout(function(){return r.send(e.self(),"POLL")},1e3),e.merge(n)})}catch(e){return Promise.reject(e)}},i[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"TRANSACTION/UPDATED",e.all())},i[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},i.SNAPSHOT=function(e,n){try{return n.replay(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},i.POLL=function(e){try{return Promise.resolve(d(e.self())).then(function(n){h(n)||setTimeout(function(){return r.send(e.self(),"POLL")},1e3),e.merge(n),e.broadcast("TRANSACTION/UPDATED",e.all())})}catch(e){return Promise.reject(e)}},i),P=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return r.spawn(y,e)};function g(e){function n(n){var t=P(e),o=r.spawn(function(e){try{var o;return e.send(t,r.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(l(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!l(i)){r=1;break}i=i.s}}var u=new f,c=a.bind(null,u,2);return(0===r?o.then(d):1===r?i.then(s):(void 0).then(function(){(o=e())?o.then?o.then(d).then(void 0,c):d(o):a(u,1,i)})).then(void 0,c),u;function s(n){i=n;do{if(!(o=e())||l(o)&&!o.v)return void a(u,1,i);if(o.then)return void o.then(d).then(void 0,c);l(i=t())&&(i=i.v)}while(!i||!i.then);i.then(s).then(void 0,c)}function d(e){e?(i=t())&&i.then?i.then(s).then(void 0,c):s(i):a(u,1,i)}}(function(){return!o&&1},0,function(){return Promise.resolve(e.receive()).then(function(i){if("@EXIT"===i.tag)return e.send(t,r.UNSUBSCRIBE),void(o=1);n(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return r.send(o,"@EXIT")}}function t(e){return function(){return new Promise(function(t){var r=n(function(n){e(n)&&(t(n),r())})})}}return{snapshot:function(){var n=P(e);return r.send(n,"SNAPSHOT",null,{expectReply:!0,timeout:10})},subscribe:n,oncePending:t(p),onceFinalized:t(v),onceExecuted:t(m),onceSealed:t(h)}}function b(){return(b=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}g.isUnknown=function(e){return 0===e.status||p(e)},g.isPending=p,g.isFinalized=v,g.isExecuted=m,g.isSealed=h;var j,E="FCL_IFRAME_CHALLENGE",w="FCL_IFRAME_AUTHZ",S=function(e){void 0===e&&(e={});var n=e.addr,t=e.pid;return null==n||null==t?null:n+"/"+t},O={"HTTP/POST":"POST","HTTP/GET":"GET"},T=function(e,n){try{for(var t=new URL(e.endpoint),r=0,o=Object.entries(e.params||{});r<o.length;r++){var i=o[r];t.searchParams.append(i[0],i[1])}return n=n?JSON.stringify(n):void 0,Promise.resolve(fetch(t,{method:O[e.method],headers:{"Content-Type":"application/json"},body:n}).then(function(e){return e.json()}))}catch(e){return Promise.reject(e)}};function R(e,n,t){if(!e.s){if(t instanceof N){if(!t.s)return void(t.o=R.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(R.bind(null,e,n),R.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var I=function(){try{return H(),Promise.resolve(J()).then(function(e){var n=e.addr;if(null==n)throw new Error("No Flow Address for Current User");return Promise.resolve(c([t.getAccount(n)])).then(function(e){return e.account})})}catch(e){return Promise.reject(e)}},A=function(e){try{return H(),Promise.resolve(k()).then(function(){return Promise.resolve(J()).then(function(n){function t(){return b({},e,{addr:n.addr,keyId:n.keyId,sequenceNum:r,signature:e.signature||null,signingFunction:function(e){try{return Promise.resolve(J()).then(function(n){return Promise.resolve(I()).then(function(t){return Promise.resolve(T(n.authorizations[0],e)).then(function(e){var n=function(){};e.local&&e.local.length>0&&(n=function(e){if(!document.getElementById(w)){for(var n=new URL(e.endpoint),t=0,r=Object.entries(e.params||{});t<r.length;t++){var o=r[t];n.searchParams.append(o[0],o[1])}var i=document.createElement("iframe");return i.src=n.href,i.id=w,i.style.height=e.height||"500px",i.style.maxHeight="90vh",i.style.width=e.width||"400px",i.style.maxWidth="90vw",i.style.display="block",i.style.background=e.background||"#fff",i.style.position="fixed",i.style.top="5vh",i.style.right="calc(50vw)",i.style.transform="translateX(50%)",i.style.boxShadow="0 4px 8px -4px black",i.frameBorder="0",document.body.append(i),function(){document.getElementById(w)&&document.getElementById(w).remove()}}}(e.local[0]));var t=null;return function(e,n){try{var t=e()}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(function(){return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return Promise.resolve(function e(n){return new Promise(function(t,r){try{return Promise.resolve(T(n)).then(function(n){"APPROVED"===n.status?t(n.compositeSignature):"DECLINED"===n.status?r({status:n.status,reason:n.reason}):setTimeout(function(){t(e(n.authorizationUpdates))},500)})}catch(e){return Promise.reject(e)}})}(e.authorizationUpdates)).then(function(e){t=e})},function(e){throw console.error(e),e})},function(){return n(),t})})})})}catch(e){return Promise.reject(e)}},resolve:null,roles:e.roles})}var r,o=function(){if(e.role.proposer)return Promise.resolve(I()).then(function(e){var t=e.keys.find(function(e){return e.index===n.keyId});r=t.sequenceNumber})}();return o&&o.then?o.then(t):t()})})}catch(e){return Promise.reject(e)}},N=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{R(r,1,i(this.v))}catch(e){R(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?R(r,1,n?n(o):o):t?R(r,1,t(o)):R(r,2,o)}catch(e){R(r,2,e)}},r},e}();function U(e){return e instanceof N&&1&e.s}var k=function(){try{return Promise.resolve(new Promise(function(e){try{return H(),Promise.resolve(J()).then(function(t){return t.loggedIn?e(t):Promise.resolve(n.config().get("challenge.handshake")).then(function(t){return Promise.resolve(n.config().get("challenge.scope")).then(function(n){var o=function(e){var n=e.handshake,t=e.scope,r=e.nonce,o=e.l6n;if(!document.getElementById(E)){var i=new URL(n);i.searchParams.append("l6n",o),i.searchParams.append("nonce",r),t&&i.searchParams.append("scope",t.split(" ").join("+"));var u=document.createElement("iframe");return u.src=i.href,u.id=E,u.style.height="500px",u.style.maxHeight="90vh",u.style.width="400px",u.style.maxWidth="90vw",u.style.display="block",u.style.background="#fff",u.style.position="fixed",u.style.top="5vh",u.style.right="calc(50vw)",u.style.transform="translateX(50%)",u.style.boxShadow="0 4px 8px -4px black",u.frameBorder="0",document.body.append(u),function(){document.getElementById(E)&&document.getElementById(E).remove()}}}({handshake:t,scope:n,nonce:"asdf",l6n:window.location.origin});window.addEventListener("message",function(n){var t=n.data;try{if(t.type!==L)return Promise.resolve();o();var i=new URL(t.hks);return i.searchParams.append("code",t.code),Promise.resolve(fetch(i,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(n){return r.send(x,C,b({},n,{cid:S(n.provider),loggedIn:!0,verified:!0})),Promise.resolve(J()).then(function(n){e(n)})})}catch(e){return Promise.reject(e)}})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},x="CURRENT_USER",B="CURRENT_USER/UPDATED",C="SET_CURRENT_USER",L="FCL::CHALLENGE::RESPONSE",_='{\n "cid":null,\n "loggedIn":null,\n "verified":null,\n "identity":{\n "name":null,\n "addr":null,\n "avatar":null,\n "cover":null,\n "color":null,\n "bio":null\n },\n "scoped":{},\n "provider":{\n "addr":null,\n "pid":null,\n "name":null,\n "icon":null\n },\n "authorizations":[]\n}',z=new Set(["verified","identity","scoped","provider"]),D=function(e){return"undefined"!=typeof Proxy&&(e=new Proxy(e,{get:function(e,n){return z.has(n)&&function(e){console.warn(('\n %cFCL Deprecation Notice\n ========================\n\n Access to field "'+e+'" on "CurrentUser" is deprecated and will cease to work in future releases of FCL.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/WARNINGS.md#0001-current-user-data\n\n =======================\n ').replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")}(n),e[n]}})),e},F=((j={})[r.INIT]=function(e){e.merge(JSON.parse(_))},j[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,B,D(e.all()))},j[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},j.SNAPSHOT=function(e,n){try{return n.reply(D(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},j[C]=function(e,n,t){try{return e.merge(t),e.broadcast(B,D(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},j.DEL_CURRENT_USER=function(e,n){try{return e.merge(JSON.parse(_)),e.broadcast(B,D(e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},j.GET_AS_PARAM=function(e,n,t){var r=t.key;try{return n.reply({key:r,value:e.get("addr",null),xform:o.Identity}),Promise.resolve()}catch(e){return Promise.reject(e)}},j),H=function(){return r.spawn(F,x)};function G(){H(),r.send(x,"DEL_CURRENT_USER")}function q(e){return function(){try{return H(),Promise.resolve(k()).then(function(){return r.send(x,"GET_AS_PARAM",{key:e},{expectReply:!0,timeout:10})})}catch(e){return Promise.reject(e)}}}function X(e){H();var n=r.spawn(function(n){try{var t;return n.send(x,r.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(U(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!U(i)){r=1;break}i=i.s}}var u=new N,c=R.bind(null,u,2);return(0===r?o.then(a):1===r?i.then(s):(void 0).then(function(){(o=e())?o.then?o.then(a).then(void 0,c):a(o):R(u,1,i)})).then(void 0,c),u;function s(n){i=n;do{if(!(o=e())||U(o)&&!o.v)return void R(u,1,i);if(o.then)return void o.then(a).then(void 0,c);U(i=t())&&(i=i.v)}while(!i||!i.then);i.then(s).then(void 0,c)}function a(e){e?(i=t())&&i.then?i.then(s).then(void 0,c):s(i):R(u,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(n.receive()).then(function(o){if("@EXIT"===o.tag)return n.send(x,r.UNSUBSCRIBE),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return r.send(n,"@EXIT")}}function J(){return H(),r.send(x,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var M=function(){return{authenticate:k,unauthenticate:G,authorization:A,param:q,subscribe:X,snapshot:J}};Object.defineProperty(e,"config",{enumerable:!0,get:function(){return n.config}}),Object.defineProperty(e,"arg",{enumerable:!0,get:function(){return t.arg}}),Object.defineProperty(e,"args",{enumerable:!0,get:function(){return t.args}}),Object.defineProperty(e,"authorization",{enumerable:!0,get:function(){return t.authorization}}),Object.defineProperty(e,"authorizations",{enumerable:!0,get:function(){return t.authorizations}}),Object.defineProperty(e,"build",{enumerable:!0,get:function(){return t.build}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return t.cadence}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return t.cdc}}),Object.defineProperty(e,"getAccount",{enumerable:!0,get:function(){return t.getAccount}}),Object.defineProperty(e,"getEvents",{enumerable:!0,get:function(){return t.getEvents}}),Object.defineProperty(e,"getLatestBlock",{enumerable:!0,get:function(){return t.getLatestBlock}}),Object.defineProperty(e,"getTransactionStatus",{enumerable:!0,get:function(){return t.getTransactionStatus}}),Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return t.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return t.isOk}}),Object.defineProperty(e,"limit",{enumerable:!0,get:function(){return t.limit}}),Object.defineProperty(e,"param",{enumerable:!0,get:function(){return t.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return t.params}}),Object.defineProperty(e,"payer",{enumerable:!0,get:function(){return t.payer}}),Object.defineProperty(e,"ping",{enumerable:!0,get:function(){return t.ping}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return t.pipe}}),Object.defineProperty(e,"proposer",{enumerable:!0,get:function(){return t.proposer}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return t.ref}}),Object.defineProperty(e,"script",{enumerable:!0,get:function(){return t.script}}),Object.defineProperty(e,"transaction",{enumerable:!0,get:function(){return t.transaction}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return t.why}}),e.authenticate=function(){return M().authenticate()},e.currentUser=M,e.decode=s,e.resolve=u,e.send=c,e.serialize=function(e){void 0===e&&(e=[]);try{var n=function(){return Promise.resolve(u(e)).then(JSON.stringify)},r=function(){if(Array.isArray(e))return Promise.resolve(t.build(e)).then(function(n){e=n})}();return Promise.resolve(r&&r.then?r.then(n):n())}catch(e){return Promise.reject(e)}},e.tx=g,e.unauthenticate=function(){return M().unauthenticate()}}); | ||
//# sourceMappingURL=fcl.umd.js.map |
{ | ||
"name": "@onflow/fcl", | ||
"version": "0.0.47", | ||
"version": "0.0.48", | ||
"description": "Flow Client Library", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
190788
200
13
1