@stacks/connect
Advanced tools
Comparing version 7.2.0 to 7.2.1
@@ -7,3 +7,3 @@ import { asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from './_virtual/_rollupPluginBabelHelpers.js'; | ||
var defaultAuthURL = "https://app.blockstack.org"; | ||
var version = "7.2.0"; | ||
var version = "7.2.1"; | ||
if (typeof window !== "undefined") { | ||
@@ -10,0 +10,0 @@ window.__CONNECT_VERSION__ = version; |
@@ -378,3 +378,3 @@ 'use strict'; | ||
var defaultAuthURL = "https://app.blockstack.org"; | ||
var version = "7.2.0"; | ||
var version = "7.2.1"; | ||
if (typeof window !== "undefined") { | ||
@@ -381,0 +381,0 @@ window.__CONNECT_VERSION__ = version; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@stacks/auth"),t=require("jsontokens"),n=require("@stacks/network"),r=require("@stacks/common"),o=require("@stacks/transactions"),a=require("@stacks/connect-ui/loader");function i(){i=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function p(e,t,n,o){var a=Object.create((t&&t.prototype instanceof h?t:h).prototype),i=new E(o||[]);return r(a,"_invoke",{value:m(e,n,i)}),a}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=p;var f={};function h(){}function d(){}function v(){}var y={};c(y,a,(function(){return this}));var x=Object.getPrototypeOf,w=x&&x(x(P([])));w&&w!==t&&n.call(w,a)&&(y=w);var g=v.prototype=h.prototype=Object.create(y);function k(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var o;r(this,"_invoke",{value:function(r,a){function i(){return new t((function(o,i){!function r(o,a,i,s){var u=l(e[o],e,a);if("throw"!==u.type){var c=u.arg,p=c.value;return p&&"object"==typeof p&&n.call(p,"__await")?t.resolve(p.__await).then((function(e){r("next",e,i,s)}),(function(e){r("throw",e,i,s)})):t.resolve(p).then((function(e){c.value=e,i(c)}),(function(e){return r("throw",e,i,s)}))}s(u.arg)}(r,a,o,i)}))}return o=o?o.then(i,i):i()}})}function m(e,t,n){var r="suspendedStart";return function(o,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw a;return{value:void 0,done:!0}}for(n.method=o,n.arg=a;;){var i=n.delegate;if(i){var s=S(i,n);if(s){if(s===f)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=l(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function S(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var o=l(r,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,f;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function P(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return d.prototype=v,r(g,"constructor",{value:v,configurable:!0}),r(v,"constructor",{value:d,configurable:!0}),d.displayName=c(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,c(e,u,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},k(b.prototype),c(b.prototype,s,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,o,a){void 0===a&&(a=Promise);var i=new b(p(t,n,r,o),a);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},k(g),c(g,u,"Generator"),c(g,a,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=P,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(C),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),C(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;C(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:P(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function s(e,t,n,r,o,a,i){try{var s=e[a](i),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,o)}function u(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){s(a,r,o,i,u,"next",e)}function u(e){s(a,r,o,i,u,"throw",e)}i(void 0)}))}}function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function p(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}function l(){return window.StacksProvider||window.BlockstackProvider}"undefined"!=typeof window&&(window.__CONNECT_VERSION__="7.2.0");var f,h,d=function(){var e=navigator.userAgent;return!!/android/i.test(e)||!!/iPad|iPhone|iPod/.test(e)||/windows phone/i.test(e)},v=function(t){if(!t){var n=new e.AppConfig(["store_write"],document.location.href);t=new e.UserSession({appConfig:n})}return t},y=function(){var e=u(i().mark((function e(n){var r,o,a,s,u,c,p,f,h,d,y,x,w,g,k;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=l()){e.next=3;break}throw new Error("Unable to authenticate without Hiro Wallet extension");case 3:return a=void 0===(o=n.redirectTo)?"/":o,s=n.manifestPath,u=n.onFinish,c=n.onCancel,f=void 0!==(p=n.sendToSignIn)&&p,h=n.appDetails,(d=v(n.userSession)).isUserSignedIn()&&d.signUserOut(),y=d.generateAndStoreTransitKey(),x=d.makeAuthRequest(y,""+document.location.origin+a,""+document.location.origin+s,d.appConfig.scopes,void 0,void 0,{sendToSignIn:f,appDetails:h,connectVersion:"7.2.0"}),e.prev=8,e.next=11,r.authenticationRequest(x);case 11:return w=e.sent,e.next=14,d.handlePendingSignIn(w);case 14:g=t.decodeToken(w),k=null==g?void 0:g.payload,null==u||u({authResponse:w,authResponsePayload:k,userSession:d}),e.next=24;break;case 20:e.prev=20,e.t0=e.catch(8),console.error("[Connect] Error during auth request",e.t0),null==c||c();case 24:case"end":return e.stop()}}),e,null,[[8,20]])})));return function(t){return e.apply(this,arguments)}}(),x=function(){var e=u(i().mark((function e(t){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t=v(t)).isUserSignedIn()){e.next=3;break}return e.abrupt("return",t.loadUserData());case 3:if(!t.isSignInPending()){e.next=5;break}return e.abrupt("return",t.handlePendingSignIn());case 5:return e.abrupt("return",null);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();(f=exports.TransactionTypes||(exports.TransactionTypes={})).ContractCall="contract_call",f.ContractDeploy="smart_contract",f.STXTransfer="token_transfer",(h=exports.ContractCallArgumentType||(exports.ContractCallArgumentType={})).BUFFER="buffer",h.UINT="uint",h.INT="int",h.PRINCIPAL="principal",h.BOOL="bool";var w=["functionArgs","appDetails","userSession"],g=["appDetails","userSession"],k=["amount","appDetails","userSession"],b=function(t){var n=t;if(!n){var r=new e.AppConfig(["store_write"],document.location.href);n=new e.UserSession({appConfig:r})}return n};function m(e){try{return b(e).loadUserData().appPrivateKey}catch(e){return!1}}var S=function(e){var n=b(e).loadUserData().appPrivateKey;return{privateKey:n,publicKey:t.SECP256K1Client.derivePublicKey(n)}};function T(e){var t,n,r=e.stxAddress,a=e.userSession,i=e.network;if(r)return r;if(a&&i){var s=null==a||null==(t=a.loadUserData().profile)?void 0:t.stxAddress,u=((n={})[o.ChainID.Mainnet]="mainnet",n[o.ChainID.Testnet]="testnet",n);return null==s?void 0:s[u[i.chainId]]}}function C(e){var t=c({},e,{network:e.network||new n.StacksTestnet,userSession:b(e.userSession)});return c({stxAddress:T(t)},t)}function E(e){return e.map((function(e){return r.bytesToHex(o.serializePostCondition(e))}))}function P(e,t){return L.apply(this,arguments)}function L(){return(L=u(i().mark((function e(n,r){var o,a;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(o=n.postConditions)&&"string"!=typeof o[0]&&(o=E(o)),a=new t.TokenSigner("ES256k",r),e.abrupt("return",a.signAsync(c({},n,{postConditions:o})));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function A(e){var n=e.postConditions;return n&&"string"!=typeof n[0]&&(n=E(n)),t.createUnsecuredToken(c({},e,{postConditions:n}))}var O=function(){var e=u(i().mark((function e(t){var n,a,s,u,p,f;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.token,a=t.options,s=l()){e.next=4;break}throw new Error("Hiro Wallet not installed");case 4:return e.prev=4,e.next=7,s.transactionRequest(n);case 7:if(p=r.hexToBytes((u=e.sent).txRaw.replace(/^0x/,"")),f=o.deserializeTransaction(p),!("sponsored"in a)||!a.sponsored){e.next=14;break}return null==a.onFinish||a.onFinish(c({},u,{stacksTransaction:f})),e.abrupt("return");case 14:null==a.onFinish||a.onFinish(c({},u,{stacksTransaction:f})),e.next=21;break;case 17:e.prev=17,e.t0=e.catch(4),console.error("[Connect] Error during transaction request",e.t0),null==a.onCancel||a.onCancel();case 21:case"end":return e.stop()}}),e,null,[[4,17]])})));return function(t){return e.apply(this,arguments)}}(),D=function(){var e=u(i().mark((function e(t){var n,a,s,u,l,f,h,d,v;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.functionArgs,a=t.appDetails,s=t.userSession,u=p(t,w),l=n.map((function(e){return"string"==typeof e?e:r.bytesToHex(o.serializeCV(e))})),!m(s)){e.next=7;break}return f=S(s),h=f.privateKey,d=c({},u,{functionArgs:l,txType:exports.TransactionTypes.ContractCall,publicKey:f.publicKey}),a&&(d.appDetails=a),e.abrupt("return",P(d,h));case 7:return v=c({},u,{functionArgs:l,txType:exports.TransactionTypes.ContractCall}),a&&(v.appDetails=a),e.abrupt("return",A(v));case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),K=function(){var e=u(i().mark((function e(t){var n,r,o,a,s,u,l;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.appDetails,r=t.userSession,o=p(t,g),!m(r)){e.next=6;break}return a=S(r),s=a.privateKey,u=c({},o,{publicKey:a.publicKey,txType:exports.TransactionTypes.ContractDeploy}),n&&(u.appDetails=n),e.abrupt("return",P(u,s));case 6:return l=c({},o,{txType:exports.TransactionTypes.ContractDeploy}),n&&(l.appDetails=n),e.abrupt("return",A(l));case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),U=function(){var e=u(i().mark((function e(t){var n,r,o,a,s,u,l,f,h;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.amount,r=t.appDetails,o=t.userSession,a=p(t,k),!m(o)){e.next=6;break}return s=S(o),u=s.privateKey,l=s.publicKey,f=c({},a,{amount:n.toString(10),publicKey:l,txType:exports.TransactionTypes.STXTransfer}),r&&(f.appDetails=r),e.abrupt("return",P(f,u));case 6:return h=c({},a,{amount:n.toString(10),txType:exports.TransactionTypes.STXTransfer}),r&&(h.appDetails=r),e.abrupt("return",A(h));case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function I(e,t){return _.apply(this,arguments)}function _(){return(_=u(i().mark((function e(t,n){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(c({},C(t),t));case 2:return e.abrupt("return",O({token:e.sent,options:t}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var q=["allowedSighash","hex","signAtIndex","userSession"];function N(e,t){return F.apply(this,arguments)}function F(){return(F=u(i().mark((function e(n,r){var o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new t.TokenSigner("ES256k",r),e.abrupt("return",o.signAsync(c({},n)));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function j(e){var t=c({},e,{network:e.network||new n.StacksTestnet,userSession:b(e.userSession)});return c({},t)}function R(e){return H.apply(this,arguments)}function H(){return(H=u(i().mark((function e(t){var n,r,o,a;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.token,r=t.options,o=l()){e.next=4;break}throw new Error("Hiro Wallet not installed");case 4:return e.prev=4,e.next=7,o.psbtRequest(n);case 7:a=e.sent,null==r.onFinish||r.onFinish(a),e.next=15;break;case 11:e.prev=11,e.t0=e.catch(4),console.error("[Connect] Error during psbt request",e.t0),null==r.onCancel||r.onCancel();case 15:case"end":return e.stop()}}),e,null,[[4,11]])})))).apply(this,arguments)}var G=function(){var e=u(i().mark((function e(n){var r,o,a,s,u,l,f,h,d;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.allowedSighash,o=n.hex,a=n.signAtIndex,s=n.userSession,u=p(n,q),!m(s)){e.next=5;break}return l=S(s),f=l.privateKey,h=c({},u,{allowedSighash:r,hex:o,signAtIndex:a,publicKey:l.publicKey}),e.abrupt("return",N(h,f));case 5:return d=c({},u),e.abrupt("return",t.createUnsecuredToken(d));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function W(){return(W=u(i().mark((function e(t,n){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(c({},j(t),t));case 2:return e.abrupt("return",R({token:e.sent,options:t}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var M=["userSession"];function Y(e){var t,n,r=e.userSession,a=e.network;if(r&&a){var i=null==r||null==(t=r.loadUserData().profile)?void 0:t.stxAddress,s=((n={})[o.ChainID.Mainnet]="mainnet",n[o.ChainID.Testnet]="testnet",n);return null==i?void 0:i[s[a.chainId]]}}function z(e,t){return B.apply(this,arguments)}function B(){return(B=u(i().mark((function e(n,r){var o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new t.TokenSigner("ES256k",r),e.abrupt("return",o.signAsync(c({},n)));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function V(e){var t=c({},e,{network:e.network||new n.StacksTestnet,userSession:b(e.userSession)});return c({stxAddress:Y(t)},t)}function X(e){return J.apply(this,arguments)}function J(){return(J=u(i().mark((function e(t){var n,r,o,a;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.token,r=t.options,o=l()){e.next=4;break}throw new Error("Hiro Wallet not installed.");case 4:return e.prev=4,e.next=7,o.signatureRequest(n);case 7:a=e.sent,null==r.onFinish||r.onFinish(a),e.next=15;break;case 11:e.prev=11,e.t0=e.catch(4),console.error("[Connect] Error during signature request",e.t0),null==r.onCancel||r.onCancel();case 15:case"end":return e.stop()}}),e,null,[[4,11]])})))).apply(this,arguments)}var Q=function(){var e=u(i().mark((function e(n){var r,o,a,s,u,l;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.userSession,o=p(n,M),!m(r)){e.next=5;break}return a=S(r),s=a.privateKey,u=c({},o,{publicKey:a.publicKey}),e.abrupt("return",z(u,s));case 5:return l=c({},o),e.abrupt("return",t.createUnsecuredToken(l));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function Z(){return(Z=u(i().mark((function e(t,n){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(c({},V(t),t));case 2:return e.abrupt("return",X({token:e.sent,options:t}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var $=["userSession"];function ee(){return(ee=u(i().mark((function e(t,n){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(c({},V(t),t));case 2:return e.abrupt("return",ie({token:e.sent,options:t}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function te(e){return c({},e,{message:r.bytesToHex(o.serializeCV(e.message)),domain:r.bytesToHex(o.serializeCV(e.domain))})}function ne(e,t){return re.apply(this,arguments)}function re(){return(re=u(i().mark((function e(n,r){var o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new t.TokenSigner("ES256k",r),e.abrupt("return",o.signAsync(te(n)));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function oe(e){return ae.apply(this,arguments)}function ae(){return(ae=u(i().mark((function e(n){var r,o,a,s,u;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.userSession,o=p(n,$),!m(r)){e.next=5;break}return a=S(r),s=a.privateKey,u=c({},o,{publicKey:a.publicKey}),e.abrupt("return",ne(u,s));case 5:return e.abrupt("return",t.createUnsecuredToken(te(n)));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ie(e){return se.apply(this,arguments)}function se(){return(se=u(i().mark((function e(t){var n,r,o,a;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.token,r=t.options,o=l()){e.next=4;break}throw new Error("Hiro Wallet not installed.");case 4:return e.prev=4,e.next=7,o.structuredDataSignatureRequest(n);case 7:a=e.sent,null==r.onFinish||r.onFinish(a),e.next=15;break;case 11:e.prev=11,e.t0=e.catch(4),console.error("[Connect] Error during signature request",e.t0),null==r.onCancel||r.onCancel();case 15:case"end":return e.stop()}}),e,null,[[4,11]])})))).apply(this,arguments)}var ue=["userSession","profile"];function ce(e,t){return pe.apply(this,arguments)}function pe(){return(pe=u(i().mark((function e(n,r){var o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new t.TokenSigner("ES256k",r),e.abrupt("return",o.signAsync(c({},n)));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function le(e){var t=c({},e,{network:e.network||new n.StacksTestnet,userSession:b(e.userSession)});return c({},t)}function fe(e){return he.apply(this,arguments)}function he(){return(he=u(i().mark((function e(t){var n,r,o,a;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.token,r=t.options,o=l()){e.next=4;break}throw new Error("Hiro Wallet not installed.");case 4:return e.prev=4,e.next=7,o.profileUpdateRequest(n);case 7:a=e.sent,null==r.onFinish||r.onFinish(a),e.next=15;break;case 11:e.prev=11,e.t0=e.catch(4),console.error("[Connect] Error during signature request",e.t0),null==r.onCancel||r.onCancel();case 15:case"end":return e.stop()}}),e,null,[[4,11]])})))).apply(this,arguments)}var de,ve=function(){var e=u(i().mark((function e(n){var r,o,a,s,u,l,f;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.userSession,o=n.profile,a=p(n,ue),!m(r)){e.next=5;break}return s=S(r),u=s.privateKey,l=c({},a,{profile:o,publicKey:s.publicKey}),e.abrupt("return",ce(l,u));case 5:return f=c({},a),e.abrupt("return",t.createUnsecuredToken(f));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function ye(){return(ye=u(i().mark((function e(t,n){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(c({},le(t),t));case 2:return e.abrupt("return",fe({token:e.sent,options:t}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}(de=exports.SignatureHash||(exports.SignatureHash={}))[de.DEFAULT=0]="DEFAULT",de[de.ALL=1]="ALL",de[de.NONE=2]="NONE",de[de.SINGLE=3]="SINGLE",de[de.ANYONECANPAY=128]="ANYONECANPAY";var xe=function(e){if(l())y(e);else if(void 0!==typeof window){a.defineCustomElements(window);var t=document.createElement("connect-modal");t.authOptions=e,document.body.appendChild(t),document.addEventListener("keydown",(function e(n){"Escape"===n.key&&(document.removeEventListener("keydown",e),t.remove())}))}};Object.keys(e).forEach((function(t){"default"!==t&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),exports.authenticate=y,exports.defaultAuthURL="https://app.blockstack.org",exports.getDefaultProfileUpdateRequestOptions=le,exports.getDefaultPsbtRequestOptions=j,exports.getDefaultSignatureRequestOptions=V,exports.getKeys=S,exports.getOrCreateUserSession=v,exports.getStacksProvider=l,exports.getStxAddress=T,exports.getUserData=x,exports.getUserSession=b,exports.hasAppPrivateKey=m,exports.isMobile=d,exports.isStacksWalletInstalled=function(){return!!l()},exports.makeContractCallToken=D,exports.makeContractDeployToken=K,exports.makeProfileUpdateToken=ve,exports.makePsbtToken=G,exports.makeSTXTransferToken=U,exports.openContractCall=function(e){return I(e,D)},exports.openContractDeploy=function(e){return I(e,K)},exports.openProfileUpdateRequestPopup=function(e){return function(e,t){return ye.apply(this,arguments)}(e,ve)},exports.openPsbtRequestPopup=function(e){return function(e,t){return W.apply(this,arguments)}(e,G)},exports.openSTXTransfer=function(e){return I(e,U)},exports.openSignatureRequestPopup=function(e){return function(e,t){return Z.apply(this,arguments)}(e,Q)},exports.openStructuredDataSignatureRequestPopup=function(e){return function(e,t){return ee.apply(this,arguments)}(e,oe)},exports.shouldUsePopup=function(){return!d()},exports.showBlockstackConnect=function(e){return xe(e)},exports.showConnect=xe,exports.signMessage=Q,exports.signStructuredMessage=oe; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@stacks/auth"),t=require("jsontokens"),n=require("@stacks/network"),r=require("@stacks/common"),o=require("@stacks/transactions"),a=require("@stacks/connect-ui/loader");function i(){i=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function p(e,t,n,o){var a=Object.create((t&&t.prototype instanceof h?t:h).prototype),i=new E(o||[]);return r(a,"_invoke",{value:m(e,n,i)}),a}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=p;var f={};function h(){}function d(){}function v(){}var y={};c(y,a,(function(){return this}));var x=Object.getPrototypeOf,w=x&&x(x(P([])));w&&w!==t&&n.call(w,a)&&(y=w);var g=v.prototype=h.prototype=Object.create(y);function k(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var o;r(this,"_invoke",{value:function(r,a){function i(){return new t((function(o,i){!function r(o,a,i,s){var u=l(e[o],e,a);if("throw"!==u.type){var c=u.arg,p=c.value;return p&&"object"==typeof p&&n.call(p,"__await")?t.resolve(p.__await).then((function(e){r("next",e,i,s)}),(function(e){r("throw",e,i,s)})):t.resolve(p).then((function(e){c.value=e,i(c)}),(function(e){return r("throw",e,i,s)}))}s(u.arg)}(r,a,o,i)}))}return o=o?o.then(i,i):i()}})}function m(e,t,n){var r="suspendedStart";return function(o,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw a;return{value:void 0,done:!0}}for(n.method=o,n.arg=a;;){var i=n.delegate;if(i){var s=S(i,n);if(s){if(s===f)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=l(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function S(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var o=l(r,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,f;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function P(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return d.prototype=v,r(g,"constructor",{value:v,configurable:!0}),r(v,"constructor",{value:d,configurable:!0}),d.displayName=c(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,c(e,u,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},k(b.prototype),c(b.prototype,s,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,o,a){void 0===a&&(a=Promise);var i=new b(p(t,n,r,o),a);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},k(g),c(g,u,"Generator"),c(g,a,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=P,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(C),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),C(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;C(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:P(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function s(e,t,n,r,o,a,i){try{var s=e[a](i),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,o)}function u(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){s(a,r,o,i,u,"next",e)}function u(e){s(a,r,o,i,u,"throw",e)}i(void 0)}))}}function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function p(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}function l(){return window.StacksProvider||window.BlockstackProvider}"undefined"!=typeof window&&(window.__CONNECT_VERSION__="7.2.1");var f,h,d=function(){var e=navigator.userAgent;return!!/android/i.test(e)||!!/iPad|iPhone|iPod/.test(e)||/windows phone/i.test(e)},v=function(t){if(!t){var n=new e.AppConfig(["store_write"],document.location.href);t=new e.UserSession({appConfig:n})}return t},y=function(){var e=u(i().mark((function e(n){var r,o,a,s,u,c,p,f,h,d,y,x,w,g,k;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=l()){e.next=3;break}throw new Error("Unable to authenticate without Hiro Wallet extension");case 3:return a=void 0===(o=n.redirectTo)?"/":o,s=n.manifestPath,u=n.onFinish,c=n.onCancel,f=void 0!==(p=n.sendToSignIn)&&p,h=n.appDetails,(d=v(n.userSession)).isUserSignedIn()&&d.signUserOut(),y=d.generateAndStoreTransitKey(),x=d.makeAuthRequest(y,""+document.location.origin+a,""+document.location.origin+s,d.appConfig.scopes,void 0,void 0,{sendToSignIn:f,appDetails:h,connectVersion:"7.2.1"}),e.prev=8,e.next=11,r.authenticationRequest(x);case 11:return w=e.sent,e.next=14,d.handlePendingSignIn(w);case 14:g=t.decodeToken(w),k=null==g?void 0:g.payload,null==u||u({authResponse:w,authResponsePayload:k,userSession:d}),e.next=24;break;case 20:e.prev=20,e.t0=e.catch(8),console.error("[Connect] Error during auth request",e.t0),null==c||c();case 24:case"end":return e.stop()}}),e,null,[[8,20]])})));return function(t){return e.apply(this,arguments)}}(),x=function(){var e=u(i().mark((function e(t){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t=v(t)).isUserSignedIn()){e.next=3;break}return e.abrupt("return",t.loadUserData());case 3:if(!t.isSignInPending()){e.next=5;break}return e.abrupt("return",t.handlePendingSignIn());case 5:return e.abrupt("return",null);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();(f=exports.TransactionTypes||(exports.TransactionTypes={})).ContractCall="contract_call",f.ContractDeploy="smart_contract",f.STXTransfer="token_transfer",(h=exports.ContractCallArgumentType||(exports.ContractCallArgumentType={})).BUFFER="buffer",h.UINT="uint",h.INT="int",h.PRINCIPAL="principal",h.BOOL="bool";var w=["functionArgs","appDetails","userSession"],g=["appDetails","userSession"],k=["amount","appDetails","userSession"],b=function(t){var n=t;if(!n){var r=new e.AppConfig(["store_write"],document.location.href);n=new e.UserSession({appConfig:r})}return n};function m(e){try{return b(e).loadUserData().appPrivateKey}catch(e){return!1}}var S=function(e){var n=b(e).loadUserData().appPrivateKey;return{privateKey:n,publicKey:t.SECP256K1Client.derivePublicKey(n)}};function T(e){var t,n,r=e.stxAddress,a=e.userSession,i=e.network;if(r)return r;if(a&&i){var s=null==a||null==(t=a.loadUserData().profile)?void 0:t.stxAddress,u=((n={})[o.ChainID.Mainnet]="mainnet",n[o.ChainID.Testnet]="testnet",n);return null==s?void 0:s[u[i.chainId]]}}function C(e){var t=c({},e,{network:e.network||new n.StacksTestnet,userSession:b(e.userSession)});return c({stxAddress:T(t)},t)}function E(e){return e.map((function(e){return r.bytesToHex(o.serializePostCondition(e))}))}function P(e,t){return L.apply(this,arguments)}function L(){return(L=u(i().mark((function e(n,r){var o,a;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(o=n.postConditions)&&"string"!=typeof o[0]&&(o=E(o)),a=new t.TokenSigner("ES256k",r),e.abrupt("return",a.signAsync(c({},n,{postConditions:o})));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function A(e){var n=e.postConditions;return n&&"string"!=typeof n[0]&&(n=E(n)),t.createUnsecuredToken(c({},e,{postConditions:n}))}var O=function(){var e=u(i().mark((function e(t){var n,a,s,u,p,f;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.token,a=t.options,s=l()){e.next=4;break}throw new Error("Hiro Wallet not installed");case 4:return e.prev=4,e.next=7,s.transactionRequest(n);case 7:if(p=r.hexToBytes((u=e.sent).txRaw.replace(/^0x/,"")),f=o.deserializeTransaction(p),!("sponsored"in a)||!a.sponsored){e.next=14;break}return null==a.onFinish||a.onFinish(c({},u,{stacksTransaction:f})),e.abrupt("return");case 14:null==a.onFinish||a.onFinish(c({},u,{stacksTransaction:f})),e.next=21;break;case 17:e.prev=17,e.t0=e.catch(4),console.error("[Connect] Error during transaction request",e.t0),null==a.onCancel||a.onCancel();case 21:case"end":return e.stop()}}),e,null,[[4,17]])})));return function(t){return e.apply(this,arguments)}}(),D=function(){var e=u(i().mark((function e(t){var n,a,s,u,l,f,h,d,v;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.functionArgs,a=t.appDetails,s=t.userSession,u=p(t,w),l=n.map((function(e){return"string"==typeof e?e:r.bytesToHex(o.serializeCV(e))})),!m(s)){e.next=7;break}return f=S(s),h=f.privateKey,d=c({},u,{functionArgs:l,txType:exports.TransactionTypes.ContractCall,publicKey:f.publicKey}),a&&(d.appDetails=a),e.abrupt("return",P(d,h));case 7:return v=c({},u,{functionArgs:l,txType:exports.TransactionTypes.ContractCall}),a&&(v.appDetails=a),e.abrupt("return",A(v));case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),K=function(){var e=u(i().mark((function e(t){var n,r,o,a,s,u,l;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.appDetails,r=t.userSession,o=p(t,g),!m(r)){e.next=6;break}return a=S(r),s=a.privateKey,u=c({},o,{publicKey:a.publicKey,txType:exports.TransactionTypes.ContractDeploy}),n&&(u.appDetails=n),e.abrupt("return",P(u,s));case 6:return l=c({},o,{txType:exports.TransactionTypes.ContractDeploy}),n&&(l.appDetails=n),e.abrupt("return",A(l));case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),U=function(){var e=u(i().mark((function e(t){var n,r,o,a,s,u,l,f,h;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.amount,r=t.appDetails,o=t.userSession,a=p(t,k),!m(o)){e.next=6;break}return s=S(o),u=s.privateKey,l=s.publicKey,f=c({},a,{amount:n.toString(10),publicKey:l,txType:exports.TransactionTypes.STXTransfer}),r&&(f.appDetails=r),e.abrupt("return",P(f,u));case 6:return h=c({},a,{amount:n.toString(10),txType:exports.TransactionTypes.STXTransfer}),r&&(h.appDetails=r),e.abrupt("return",A(h));case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function I(e,t){return _.apply(this,arguments)}function _(){return(_=u(i().mark((function e(t,n){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(c({},C(t),t));case 2:return e.abrupt("return",O({token:e.sent,options:t}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var q=["allowedSighash","hex","signAtIndex","userSession"];function N(e,t){return F.apply(this,arguments)}function F(){return(F=u(i().mark((function e(n,r){var o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new t.TokenSigner("ES256k",r),e.abrupt("return",o.signAsync(c({},n)));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function j(e){var t=c({},e,{network:e.network||new n.StacksTestnet,userSession:b(e.userSession)});return c({},t)}function R(e){return H.apply(this,arguments)}function H(){return(H=u(i().mark((function e(t){var n,r,o,a;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.token,r=t.options,o=l()){e.next=4;break}throw new Error("Hiro Wallet not installed");case 4:return e.prev=4,e.next=7,o.psbtRequest(n);case 7:a=e.sent,null==r.onFinish||r.onFinish(a),e.next=15;break;case 11:e.prev=11,e.t0=e.catch(4),console.error("[Connect] Error during psbt request",e.t0),null==r.onCancel||r.onCancel();case 15:case"end":return e.stop()}}),e,null,[[4,11]])})))).apply(this,arguments)}var G=function(){var e=u(i().mark((function e(n){var r,o,a,s,u,l,f,h,d;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.allowedSighash,o=n.hex,a=n.signAtIndex,s=n.userSession,u=p(n,q),!m(s)){e.next=5;break}return l=S(s),f=l.privateKey,h=c({},u,{allowedSighash:r,hex:o,signAtIndex:a,publicKey:l.publicKey}),e.abrupt("return",N(h,f));case 5:return d=c({},u),e.abrupt("return",t.createUnsecuredToken(d));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function W(){return(W=u(i().mark((function e(t,n){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(c({},j(t),t));case 2:return e.abrupt("return",R({token:e.sent,options:t}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var M=["userSession"];function Y(e){var t,n,r=e.userSession,a=e.network;if(r&&a){var i=null==r||null==(t=r.loadUserData().profile)?void 0:t.stxAddress,s=((n={})[o.ChainID.Mainnet]="mainnet",n[o.ChainID.Testnet]="testnet",n);return null==i?void 0:i[s[a.chainId]]}}function z(e,t){return B.apply(this,arguments)}function B(){return(B=u(i().mark((function e(n,r){var o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new t.TokenSigner("ES256k",r),e.abrupt("return",o.signAsync(c({},n)));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function V(e){var t=c({},e,{network:e.network||new n.StacksTestnet,userSession:b(e.userSession)});return c({stxAddress:Y(t)},t)}function X(e){return J.apply(this,arguments)}function J(){return(J=u(i().mark((function e(t){var n,r,o,a;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.token,r=t.options,o=l()){e.next=4;break}throw new Error("Hiro Wallet not installed.");case 4:return e.prev=4,e.next=7,o.signatureRequest(n);case 7:a=e.sent,null==r.onFinish||r.onFinish(a),e.next=15;break;case 11:e.prev=11,e.t0=e.catch(4),console.error("[Connect] Error during signature request",e.t0),null==r.onCancel||r.onCancel();case 15:case"end":return e.stop()}}),e,null,[[4,11]])})))).apply(this,arguments)}var Q=function(){var e=u(i().mark((function e(n){var r,o,a,s,u,l;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.userSession,o=p(n,M),!m(r)){e.next=5;break}return a=S(r),s=a.privateKey,u=c({},o,{publicKey:a.publicKey}),e.abrupt("return",z(u,s));case 5:return l=c({},o),e.abrupt("return",t.createUnsecuredToken(l));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function Z(){return(Z=u(i().mark((function e(t,n){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(c({},V(t),t));case 2:return e.abrupt("return",X({token:e.sent,options:t}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var $=["userSession"];function ee(){return(ee=u(i().mark((function e(t,n){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(c({},V(t),t));case 2:return e.abrupt("return",ie({token:e.sent,options:t}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function te(e){return c({},e,{message:r.bytesToHex(o.serializeCV(e.message)),domain:r.bytesToHex(o.serializeCV(e.domain))})}function ne(e,t){return re.apply(this,arguments)}function re(){return(re=u(i().mark((function e(n,r){var o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new t.TokenSigner("ES256k",r),e.abrupt("return",o.signAsync(te(n)));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function oe(e){return ae.apply(this,arguments)}function ae(){return(ae=u(i().mark((function e(n){var r,o,a,s,u;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.userSession,o=p(n,$),!m(r)){e.next=5;break}return a=S(r),s=a.privateKey,u=c({},o,{publicKey:a.publicKey}),e.abrupt("return",ne(u,s));case 5:return e.abrupt("return",t.createUnsecuredToken(te(n)));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ie(e){return se.apply(this,arguments)}function se(){return(se=u(i().mark((function e(t){var n,r,o,a;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.token,r=t.options,o=l()){e.next=4;break}throw new Error("Hiro Wallet not installed.");case 4:return e.prev=4,e.next=7,o.structuredDataSignatureRequest(n);case 7:a=e.sent,null==r.onFinish||r.onFinish(a),e.next=15;break;case 11:e.prev=11,e.t0=e.catch(4),console.error("[Connect] Error during signature request",e.t0),null==r.onCancel||r.onCancel();case 15:case"end":return e.stop()}}),e,null,[[4,11]])})))).apply(this,arguments)}var ue=["userSession","profile"];function ce(e,t){return pe.apply(this,arguments)}function pe(){return(pe=u(i().mark((function e(n,r){var o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new t.TokenSigner("ES256k",r),e.abrupt("return",o.signAsync(c({},n)));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function le(e){var t=c({},e,{network:e.network||new n.StacksTestnet,userSession:b(e.userSession)});return c({},t)}function fe(e){return he.apply(this,arguments)}function he(){return(he=u(i().mark((function e(t){var n,r,o,a;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.token,r=t.options,o=l()){e.next=4;break}throw new Error("Hiro Wallet not installed.");case 4:return e.prev=4,e.next=7,o.profileUpdateRequest(n);case 7:a=e.sent,null==r.onFinish||r.onFinish(a),e.next=15;break;case 11:e.prev=11,e.t0=e.catch(4),console.error("[Connect] Error during signature request",e.t0),null==r.onCancel||r.onCancel();case 15:case"end":return e.stop()}}),e,null,[[4,11]])})))).apply(this,arguments)}var de,ve=function(){var e=u(i().mark((function e(n){var r,o,a,s,u,l,f;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.userSession,o=n.profile,a=p(n,ue),!m(r)){e.next=5;break}return s=S(r),u=s.privateKey,l=c({},a,{profile:o,publicKey:s.publicKey}),e.abrupt("return",ce(l,u));case 5:return f=c({},a),e.abrupt("return",t.createUnsecuredToken(f));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function ye(){return(ye=u(i().mark((function e(t,n){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(c({},le(t),t));case 2:return e.abrupt("return",fe({token:e.sent,options:t}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}(de=exports.SignatureHash||(exports.SignatureHash={}))[de.DEFAULT=0]="DEFAULT",de[de.ALL=1]="ALL",de[de.NONE=2]="NONE",de[de.SINGLE=3]="SINGLE",de[de.ANYONECANPAY=128]="ANYONECANPAY";var xe=function(e){if(l())y(e);else if(void 0!==typeof window){a.defineCustomElements(window);var t=document.createElement("connect-modal");t.authOptions=e,document.body.appendChild(t),document.addEventListener("keydown",(function e(n){"Escape"===n.key&&(document.removeEventListener("keydown",e),t.remove())}))}};Object.keys(e).forEach((function(t){"default"!==t&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),exports.authenticate=y,exports.defaultAuthURL="https://app.blockstack.org",exports.getDefaultProfileUpdateRequestOptions=le,exports.getDefaultPsbtRequestOptions=j,exports.getDefaultSignatureRequestOptions=V,exports.getKeys=S,exports.getOrCreateUserSession=v,exports.getStacksProvider=l,exports.getStxAddress=T,exports.getUserData=x,exports.getUserSession=b,exports.hasAppPrivateKey=m,exports.isMobile=d,exports.isStacksWalletInstalled=function(){return!!l()},exports.makeContractCallToken=D,exports.makeContractDeployToken=K,exports.makeProfileUpdateToken=ve,exports.makePsbtToken=G,exports.makeSTXTransferToken=U,exports.openContractCall=function(e){return I(e,D)},exports.openContractDeploy=function(e){return I(e,K)},exports.openProfileUpdateRequestPopup=function(e){return function(e,t){return ye.apply(this,arguments)}(e,ve)},exports.openPsbtRequestPopup=function(e){return function(e,t){return W.apply(this,arguments)}(e,G)},exports.openSTXTransfer=function(e){return I(e,U)},exports.openSignatureRequestPopup=function(e){return function(e,t){return Z.apply(this,arguments)}(e,Q)},exports.openStructuredDataSignatureRequestPopup=function(e){return function(e,t){return ee.apply(this,arguments)}(e,oe)},exports.shouldUsePopup=function(){return!d()},exports.showBlockstackConnect=function(e){return xe(e)},exports.showConnect=xe,exports.signMessage=Q,exports.signStructuredMessage=oe; | ||
//# sourceMappingURL=connect.cjs.production.min.js.map |
@@ -5,3 +5,3 @@ import { PsbtRequestOptions } from '../types/bitcoin'; | ||
hex: string; | ||
signAtIndex?: number | undefined; | ||
signAtIndex?: number | number[] | undefined; | ||
appDetails?: { | ||
@@ -8,0 +8,0 @@ name: string; |
@@ -28,3 +28,3 @@ import { UserSession } from '@stacks/auth'; | ||
hex: string; | ||
signAtIndex?: number; | ||
signAtIndex?: number | number[]; | ||
} | ||
@@ -37,3 +37,3 @@ export interface CommonPsbtPayload extends PsbtBase { | ||
hex: string; | ||
signAtIndex?: number; | ||
signAtIndex?: number | number[]; | ||
} | ||
@@ -40,0 +40,0 @@ /** |
{ | ||
"name": "@stacks/connect", | ||
"version": "7.2.0", | ||
"version": "7.2.1", | ||
"license": "MIT", | ||
@@ -63,3 +63,3 @@ "prettier": "@stacks/prettier-config", | ||
}, | ||
"gitHead": "da28c4133734ba1dd521c85841e35c2b5bfc52cd" | ||
"gitHead": "1c059b1bc2633fc579236cbae28a310a2349f817" | ||
} |
Sorry, the diff of this file is too big to display
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
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
883180
0