@stacks/connect
Advanced tools
Comparing version 7.3.2-alpha.8a13a1b.0 to 7.3.2-alpha.8d1d2bb.0
@@ -9,15 +9,15 @@ 'use strict'; | ||
var X=Object.defineProperty,M=Object.defineProperties;var L=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var b=(e,t,n)=>t in e?X(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,a=(e,t)=>{for(var n in t||(t={}))D.call(t,n)&&b(e,n,t[n]);if(T)for(var n of T(t))R.call(t,n)&&b(e,n,t[n]);return e},p=(e,t)=>M(e,L(t));var f=(e,t)=>{var n={};for(var r in e)D.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&T)for(var r of T(e))t.indexOf(r)<0&&R.call(e,r)&&(n[r]=e[r]);return n};function c(){return window.StacksProvider||window.BlockstackProvider}function zt(){return !!c()}var Ht="https://app.blockstack.org",B="7.3.2-alpha.8a13a1b.0";typeof window!="undefined"&&(window.__CONNECT_VERSION__=B);var z=()=>{let e=navigator.userAgent;return /android/i.test(e)||/iPad|iPhone|iPod/.test(e)?!0:/windows phone/i.test(e)},Qt=()=>!z(),U=e=>{if(!e){let t=new auth.AppConfig(["store_write"],document.location.href);e=new auth.UserSession({appConfig:t});}return e},A=async(e,t=c())=>{if(!t)throw new Error("[Connect] No installed Stacks wallet found");let{redirectTo:n="/",manifestPath:r,onFinish:s,onCancel:o,sendToSignIn:i=!1,userSession:u,appDetails:l}=e,d=U(u);d.isUserSignedIn()&&d.signUserOut();let S=d.generateAndStoreTransitKey(),F=d.makeAuthRequest(S,`${document.location.origin}${n}`,`${document.location.origin}${r}`,d.appConfig.scopes,void 0,void 0,{sendToSignIn:i,appDetails:l,connectVersion:B});try{let P=await t.authenticationRequest(F);await d.handlePendingSignIn(P);let h=jsontokens.decodeToken(P),$=h==null?void 0:h.payload;s==null||s({authResponse:P,authResponsePayload:$,userSession:d});}catch(P){console.error("[Connect] Error during auth request",P),o==null||o();}},Zt=async e=>(e=U(e),e.isUserSignedIn()?e.loadUserData():e.isSignInPending()?e.handlePendingSignIn():null);var Y=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function m(e){if(!(e instanceof Uint8Array))throw new Error("Uint8Array expected");let t="";for(let n of e)t+=Y[n];return t}function I(e){if(typeof e!="string")throw new TypeError(`hexToBytes: expected string, got ${typeof e}`);let t=e.length%2?`0${e}`:e,n=new Uint8Array(t.length/2);for(let r=0;r<n.length;r++){let s=r*2,o=t.slice(s,s+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");n[r]=i;}return n}var G=(r=>(r.ContractCall="contract_call",r.ContractDeploy="smart_contract",r.STXTransfer="token_transfer",r))(G||{}),W=(o=>(o.BUFFER="buffer",o.UINT="uint",o.INT="int",o.PRINCIPAL="principal",o.BOOL="bool",o))(W||{});var x=e=>{let t=e;if(!t){let n=new auth.AppConfig(["store_write"],document.location.href);t=new auth.UserSession({appConfig:n});}return t};function g(e){try{return x(e).loadUserData().appPrivateKey}catch(t){return !1}}var y=e=>{let n=x(e).loadUserData().appPrivateKey,r=jsontokens.SECP256K1Client.derivePublicKey(n);return {privateKey:n,publicKey:r}};function st(e){var u;let{stxAddress:t,userSession:n,network:r}=e;if(t)return t;if(!n||!r)return;let s=(u=n==null?void 0:n.loadUserData().profile)==null?void 0:u.stxAddress,o={[transactions.ChainID.Mainnet]:"mainnet",[transactions.ChainID.Testnet]:"testnet"};return s==null?void 0:s[o[r.chainId]]}function at(e){let t=e.network||new network.StacksTestnet,n=x(e.userSession),r=p(a({},e),{network:t,userSession:n});return a({stxAddress:st(r)},r)}function E(e){return e.map(t=>m(transactions.serializePostCondition(t)))}async function C(e,t){let{postConditions:n}=e;return n&&typeof n[0]!="string"&&(n=E(n)),new jsontokens.TokenSigner("ES256k",t).signAsync(p(a({},e),{postConditions:n}))}function w(e){let{postConditions:t}=e;return t&&typeof t[0]!="string"&&(t=E(t)),jsontokens.createUnsecuredToken(p(a({},e),{postConditions:t}))}var it=async({token:e,options:t},n=c())=>{var r,s,o;if(!n)throw new Error("[Connect] No installed Stacks wallet found");try{let i=await n.transactionRequest(e),{txRaw:u}=i,l=I(u.replace(/^0x/,"")),d=transactions.deserializeTransaction(l);if("sponsored"in t&&t.sponsored){(r=t.onFinish)==null||r.call(t,p(a({},i),{stacksTransaction:d}));return}(s=t.onFinish)==null||s.call(t,p(a({},i),{stacksTransaction:d}));}catch(i){console.error("[Connect] Error during transaction request",i),(o=t.onCancel)==null||o.call(t);}},ct=async e=>{let u=e,{functionArgs:t,appDetails:n,userSession:r}=u,s=f(u,["functionArgs","appDetails","userSession"]),o=t.map(l=>typeof l=="string"?l:m(transactions.serializeCV(l)));if(g(r)){let{privateKey:l,publicKey:d}=y(r),S=p(a({},s),{functionArgs:o,txType:"contract_call",publicKey:d});return n&&(S.appDetails=n),C(S,l)}let i=p(a({},s),{functionArgs:o,txType:"contract_call"});return n&&(i.appDetails=n),w(i)},pt=async e=>{let o=e,{appDetails:t,userSession:n}=o,r=f(o,["appDetails","userSession"]);if(g(n)){let{privateKey:i,publicKey:u}=y(n),l=p(a({},r),{publicKey:u,txType:"smart_contract"});return t&&(l.appDetails=t),C(l,i)}let s=p(a({},r),{txType:"smart_contract"});return t&&(s.appDetails=t),w(s)},ut=async e=>{let i=e,{amount:t,appDetails:n,userSession:r}=i,s=f(i,["amount","appDetails","userSession"]);if(g(r)){let{privateKey:u,publicKey:l}=y(r),d=p(a({},s),{amount:t.toString(10),publicKey:l,txType:"token_transfer"});return n&&(d.appDetails=n),C(d,u)}let o=p(a({},s),{amount:t.toString(10),txType:"token_transfer"});return n&&(o.appDetails=n),w(o)};async function k(e,t,n=c()){let r=await t(a(a({},at(e)),e));return it({token:r,options:e},n)}function le(e,t=c()){return k(e,ct,t)}function de(e,t=c()){return k(e,pt,t)}function fe(e,t=c()){return k(e,ut,t)}async function gt(e,t){return new jsontokens.TokenSigner("ES256k",t).signAsync(a({},e))}function yt(e){let t=e.network||new network.StacksTestnet,n=x(e.userSession),r=p(a({},e),{network:t,userSession:n});return a({},r)}async function xt({token:e,options:t},n=c()){var r,s;if(!n)throw new Error("[Connect] No installed Stacks wallet found");try{let o=await n.psbtRequest(e);(r=t.onFinish)==null||r.call(t,o);}catch(o){console.error("[Connect] Error during psbt request",o),(s=t.onCancel)==null||s.call(t);}}var St=async e=>{let u=e,{allowedSighash:t,hex:n,signAtIndex:r,userSession:s}=u,o=f(u,["allowedSighash","hex","signAtIndex","userSession"]);if(g(s)){let{privateKey:l,publicKey:d}=y(s),S=p(a({},o),{allowedSighash:t,hex:n,signAtIndex:r,publicKey:d});return gt(S,l)}let i=a({},o);return jsontokens.createUnsecuredToken(i)};async function mt(e,t,n=c()){let r=await t(a(a({},yt(e)),e));return xt({token:r,options:e},n)}function he(e,t=c()){return mt(e,St,t)}function Ct(e){var i;let{userSession:t,network:n}=e;if(!t||!n)return;let r=(i=t==null?void 0:t.loadUserData().profile)==null?void 0:i.stxAddress,s={[transactions.ChainID.Mainnet]:"mainnet",[transactions.ChainID.Testnet]:"testnet"};return r==null?void 0:r[s[n.chainId]]}async function wt(e,t){return new jsontokens.TokenSigner("ES256k",t).signAsync(a({},e))}function O(e){let t=e.network||new network.StacksTestnet,n=x(e.userSession),r=p(a({},e),{network:t,userSession:n});return a({stxAddress:Ct(r)},r)}async function kt({token:e,options:t},n=c()){var r,s;if(!n)throw new Error("[Connect] No installed Stacks wallet found");try{let o=await n.signatureRequest(e);(r=t.onFinish)==null||r.call(t,o);}catch(o){console.error("[Connect] Error during signature request",o),(s=t.onCancel)==null||s.call(t);}}var Ot=async e=>{let s=e,{userSession:t}=s,n=f(s,["userSession"]);if(g(t)){let{privateKey:o,publicKey:i}=y(t),u=p(a({},n),{publicKey:i});return wt(u,o)}let r=a({},n);return jsontokens.createUnsecuredToken(r)};async function bt(e,t,n=c()){let r=await t(a(a({},O(e)),e));return kt({token:r,options:e},n)}function Be(e,t=c()){return bt(e,Ot,t)}async function Bt(e,t,n=c()){let r=await t(a(a({},O(e)),e));return It({token:r,options:e},n)}function N(e){return p(a({},e),{message:m(transactions.serializeCV(e.message)),domain:m(transactions.serializeCV(e.domain))})}async function Ut(e,t){return new jsontokens.TokenSigner("ES256k",t).signAsync(N(e))}async function At(e){let r=e,{userSession:t}=r,n=f(r,["userSession"]);if(g(t)){let{privateKey:s,publicKey:o}=y(t),i=p(a({},n),{publicKey:o});return Ut(i,s)}return jsontokens.createUnsecuredToken(N(e))}async function It({token:e,options:t},n=c()){var r,s;if(!n)throw new Error("[Connect] No installed Stacks wallet found");try{let o=await n.structuredDataSignatureRequest(e);(r=t.onFinish)==null||r.call(t,o);}catch(o){console.error("[Connect] Error during signature request",o),(s=t.onCancel)==null||s.call(t);}}function Fe(e,t=c()){return Bt(e,At,t)}async function Kt(e,t){return new jsontokens.TokenSigner("ES256k",t).signAsync(a({},e))}function Nt(e){let t=e.network||new network.StacksTestnet,n=x(e.userSession),r=p(a({},e),{network:t,userSession:n});return a({},r)}async function Ft({token:e,options:t},n=c()){var r,s;if(!n)throw new Error("[Connect] No installed Stacks wallet found");try{let o=await n.profileUpdateRequest(e);(r=t.onFinish)==null||r.call(t,o);}catch(o){console.error("[Connect] Error during signature request",o),(s=t.onCancel)==null||s.call(t);}}var $t=async e=>{let o=e,{userSession:t,profile:n}=o,r=f(o,["userSession","profile"]);if(g(t)){let{privateKey:i,publicKey:u}=y(t),l=p(a({},r),{profile:n,publicKey:u});return Kt(l,i)}let s=a({},r);return jsontokens.createUnsecuredToken(s)};async function Xt(e,t,n=c()){let r=await t(a(a({},Nt(e)),e));return Ft({token:r,options:e},n)}function ze(e,t=c()){return Xt(e,$t,t)}var Mt=(o=>(o[o.DEFAULT=0]="DEFAULT",o[o.ALL=1]="ALL",o[o.NONE=2]="NONE",o[o.SINGLE=3]="SINGLE",o[o.ANYONECANPAY=128]="ANYONECANPAY",o))(Mt||{});var _t=(e,t=c())=>{if(t){A(e);return}if(typeof window!==void 0){loader.defineCustomElements(window);let n=document.createElement("connect-modal");n.authOptions=e,document.body.appendChild(n);let r=s=>{s.key==="Escape"&&(document.removeEventListener("keydown",r),n.remove());};document.addEventListener("keydown",r);}},Ze=e=>_t(e); | ||
var N=Object.defineProperty,M=Object.defineProperties;var L=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var k=(t,e,n)=>e in t?N(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,i=(t,e)=>{for(var n in e||(e={}))D.call(e,n)&&k(t,n,e[n]);if(P)for(var n of P(e))R.call(e,n)&&k(t,n,e[n]);return t},p=(t,e)=>M(t,L(e));var f=(t,e)=>{var n={};for(var r in t)D.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&P)for(var r of P(t))e.indexOf(r)<0&&R.call(t,r)&&(n[r]=t[r]);return n};function d(){return window.StacksProvider||window.BlockstackProvider}function Ht(){return !!d()}var jt="https://app.blockstack.org",U="7.3.2-alpha.8d1d2bb.0";typeof window!="undefined"&&(window.__CONNECT_VERSION__=U);var H=()=>{let t=navigator.userAgent;return /android/i.test(t)||/iPad|iPhone|iPod/.test(t)?!0:/windows phone/i.test(t)},Qt=()=>!H(),B=t=>{if(!t){let e=new auth.AppConfig(["store_write"],document.location.href);t=new auth.UserSession({appConfig:e});}return t},A=async t=>{let e=d();if(!e)throw new Error("Unable to authenticate without Hiro Wallet extension");let{redirectTo:n="/",manifestPath:r,onFinish:s,onCancel:o,sendToSignIn:a=!1,userSession:c,appDetails:u}=t,l=B(c);l.isUserSignedIn()&&l.signUserOut();let m=l.generateAndStoreTransitKey(),$=l.makeAuthRequest(m,`${document.location.origin}${n}`,`${document.location.origin}${r}`,l.appConfig.scopes,void 0,void 0,{sendToSignIn:a,appDetails:u,connectVersion:U});try{let T=await e.authenticationRequest($);await l.handlePendingSignIn(T);let h=jsontokens.decodeToken(T),X=h==null?void 0:h.payload;s==null||s({authResponse:T,authResponsePayload:X,userSession:l});}catch(T){console.error("[Connect] Error during auth request",T),o==null||o();}},Zt=async t=>(t=B(t),t.isUserSignedIn()?t.loadUserData():t.isSignInPending()?t.handlePendingSignIn():null);var J=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function S(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let n of t)e+=J[n];return e}function I(t){if(typeof t!="string")throw new TypeError(`hexToBytes: expected string, got ${typeof t}`);let e=t.length%2?`0${t}`:t,n=new Uint8Array(e.length/2);for(let r=0;r<n.length;r++){let s=r*2,o=e.slice(s,s+2),a=Number.parseInt(o,16);if(Number.isNaN(a)||a<0)throw new Error("Invalid byte sequence");n[r]=a;}return n}var z=(r=>(r.ContractCall="contract_call",r.ContractDeploy="smart_contract",r.STXTransfer="token_transfer",r))(z||{}),Y=(o=>(o.BUFFER="buffer",o.UINT="uint",o.INT="int",o.PRINCIPAL="principal",o.BOOL="bool",o))(Y||{});var x=t=>{let e=t;if(!e){let n=new auth.AppConfig(["store_write"],document.location.href);e=new auth.UserSession({appConfig:n});}return e};function g(t){try{return x(t).loadUserData().appPrivateKey}catch(e){return !1}}var y=t=>{let n=x(t).loadUserData().appPrivateKey,r=jsontokens.SECP256K1Client.derivePublicKey(n);return {privateKey:n,publicKey:r}};function st(t){var c;let{stxAddress:e,userSession:n,network:r}=t;if(e)return e;if(!n||!r)return;let s=(c=n==null?void 0:n.loadUserData().profile)==null?void 0:c.stxAddress,o={[transactions.ChainID.Mainnet]:"mainnet",[transactions.ChainID.Testnet]:"testnet"};return s==null?void 0:s[o[r.chainId]]}function it(t){let e=t.network||new network.StacksTestnet,n=x(t.userSession),r=p(i({},t),{network:e,userSession:n});return i({stxAddress:st(r)},r)}function E(t){return t.map(e=>S(transactions.serializePostCondition(e)))}async function C(t,e){let{postConditions:n}=t;return n&&typeof n[0]!="string"&&(n=E(n)),new jsontokens.TokenSigner("ES256k",e).signAsync(p(i({},t),{postConditions:n}))}function w(t){let{postConditions:e}=t;return e&&typeof e[0]!="string"&&(e=E(e)),jsontokens.createUnsecuredToken(p(i({},t),{postConditions:e}))}var at=async({token:t,options:e})=>{var r,s,o;let n=d();if(!n)throw new Error("Hiro Wallet not installed");try{let a=await n.transactionRequest(t),{txRaw:c}=a,u=I(c.replace(/^0x/,"")),l=transactions.deserializeTransaction(u);if("sponsored"in e&&e.sponsored){(r=e.onFinish)==null||r.call(e,p(i({},a),{stacksTransaction:l}));return}(s=e.onFinish)==null||s.call(e,p(i({},a),{stacksTransaction:l}));}catch(a){console.error("[Connect] Error during transaction request",a),(o=e.onCancel)==null||o.call(e);}},pt=async t=>{let c=t,{functionArgs:e,appDetails:n,userSession:r}=c,s=f(c,["functionArgs","appDetails","userSession"]),o=e.map(u=>typeof u=="string"?u:S(transactions.serializeCV(u)));if(g(r)){let{privateKey:u,publicKey:l}=y(r),m=p(i({},s),{functionArgs:o,txType:"contract_call",publicKey:l});return n&&(m.appDetails=n),C(m,u)}let a=p(i({},s),{functionArgs:o,txType:"contract_call"});return n&&(a.appDetails=n),w(a)},ct=async t=>{let o=t,{appDetails:e,userSession:n}=o,r=f(o,["appDetails","userSession"]);if(g(n)){let{privateKey:a,publicKey:c}=y(n),u=p(i({},r),{publicKey:c,txType:"smart_contract"});return e&&(u.appDetails=e),C(u,a)}let s=p(i({},r),{txType:"smart_contract"});return e&&(s.appDetails=e),w(s)},ut=async t=>{let a=t,{amount:e,appDetails:n,userSession:r}=a,s=f(a,["amount","appDetails","userSession"]);if(g(r)){let{privateKey:c,publicKey:u}=y(r),l=p(i({},s),{amount:e.toString(10),publicKey:u,txType:"token_transfer"});return n&&(l.appDetails=n),C(l,c)}let o=p(i({},s),{amount:e.toString(10),txType:"token_transfer"});return n&&(o.appDetails=n),w(o)};async function O(t,e){let n=await e(i(i({},it(t)),t));return at({token:n,options:t})}function le(t){return O(t,pt)}function de(t){return O(t,ct)}function fe(t){return O(t,ut)}async function gt(t,e){return new jsontokens.TokenSigner("ES256k",e).signAsync(i({},t))}function yt(t){let e=t.network||new network.StacksTestnet,n=x(t.userSession),r=p(i({},t),{network:e,userSession:n});return i({},r)}async function xt({token:t,options:e}){var r,s;let n=d();if(!n)throw new Error("Hiro Wallet not installed");try{let o=await n.psbtRequest(t);(r=e.onFinish)==null||r.call(e,o);}catch(o){console.error("[Connect] Error during psbt request",o),(s=e.onCancel)==null||s.call(e);}}var mt=async t=>{let c=t,{allowedSighash:e,hex:n,signAtIndex:r,userSession:s}=c,o=f(c,["allowedSighash","hex","signAtIndex","userSession"]);if(g(s)){let{privateKey:u,publicKey:l}=y(s),m=p(i({},o),{allowedSighash:e,hex:n,signAtIndex:r,publicKey:l});return gt(m,u)}let a=i({},o);return jsontokens.createUnsecuredToken(a)};async function St(t,e){let n=await e(i(i({},yt(t)),t));return xt({token:n,options:t})}function he(t){return St(t,mt)}function Ct(t){var a;let{userSession:e,network:n}=t;if(!e||!n)return;let r=(a=e==null?void 0:e.loadUserData().profile)==null?void 0:a.stxAddress,s={[transactions.ChainID.Mainnet]:"mainnet",[transactions.ChainID.Testnet]:"testnet"};return r==null?void 0:r[s[n.chainId]]}async function wt(t,e){return new jsontokens.TokenSigner("ES256k",e).signAsync(i({},t))}function b(t){let e=t.network||new network.StacksTestnet,n=x(t.userSession),r=p(i({},t),{network:e,userSession:n});return i({stxAddress:Ct(r)},r)}async function Ot({token:t,options:e}){var r,s;let n=d();if(!n)throw new Error("Hiro Wallet not installed.");try{let o=await n.signatureRequest(t);(r=e.onFinish)==null||r.call(e,o);}catch(o){console.error("[Connect] Error during signature request",o),(s=e.onCancel)==null||s.call(e);}}var bt=async t=>{let s=t,{userSession:e}=s,n=f(s,["userSession"]);if(g(e)){let{privateKey:o,publicKey:a}=y(e),c=p(i({},n),{publicKey:a});return wt(c,o)}let r=i({},n);return jsontokens.createUnsecuredToken(r)};async function kt(t,e){let n=await e(i(i({},b(t)),t));return Ot({token:n,options:t})}function Ue(t){return kt(t,bt)}async function Ut(t,e){let n=await e(i(i({},b(t)),t));return It({token:n,options:t})}function F(t){return p(i({},t),{message:S(transactions.serializeCV(t.message)),domain:S(transactions.serializeCV(t.domain))})}async function Bt(t,e){return new jsontokens.TokenSigner("ES256k",e).signAsync(F(t))}async function At(t){let r=t,{userSession:e}=r,n=f(r,["userSession"]);if(g(e)){let{privateKey:s,publicKey:o}=y(e),a=p(i({},n),{publicKey:o});return Bt(a,s)}return jsontokens.createUnsecuredToken(F(t))}async function It({token:t,options:e}){var r,s;let n=d();if(!n)throw new Error("Hiro Wallet not installed.");try{let o=await n.structuredDataSignatureRequest(t);(r=e.onFinish)==null||r.call(e,o);}catch(o){console.error("[Connect] Error during signature request",o),(s=e.onCancel)==null||s.call(e);}}function $e(t){return Ut(t,At)}async function Kt(t,e){return new jsontokens.TokenSigner("ES256k",e).signAsync(i({},t))}function Ft(t){let e=t.network||new network.StacksTestnet,n=x(t.userSession),r=p(i({},t),{network:e,userSession:n});return i({},r)}async function $t({token:t,options:e}){var r,s;let n=d();if(!n)throw new Error("Hiro Wallet not installed.");try{let o=await n.profileUpdateRequest(t);(r=e.onFinish)==null||r.call(e,o);}catch(o){console.error("[Connect] Error during signature request",o),(s=e.onCancel)==null||s.call(e);}}var Xt=async t=>{let o=t,{userSession:e,profile:n}=o,r=f(o,["userSession","profile"]);if(g(e)){let{privateKey:a,publicKey:c}=y(e),u=p(i({},r),{profile:n,publicKey:c});return Kt(u,a)}let s=i({},r);return jsontokens.createUnsecuredToken(s)};async function Nt(t,e){let n=await e(i(i({},Ft(t)),t));return $t({token:n,options:t})}function He(t){return Nt(t,Xt)}var Mt=(o=>(o[o.DEFAULT=0]="DEFAULT",o[o.ALL=1]="ALL",o[o.NONE=2]="NONE",o[o.SINGLE=3]="SINGLE",o[o.ANYONECANPAY=128]="ANYONECANPAY",o))(Mt||{});var _t=t=>{if(d()){A(t);return}if(typeof window!==void 0){loader.defineCustomElements(window);let e=document.createElement("connect-modal");e.authOptions=t,document.body.appendChild(e);let n=r=>{r.key==="Escape"&&(document.removeEventListener("keydown",n),e.remove());};document.addEventListener("keydown",n);}},Ze=t=>_t(t); | ||
exports.ContractCallArgumentType = W; | ||
exports.ContractCallArgumentType = Y; | ||
exports.SignatureHash = Mt; | ||
exports.TransactionTypes = G; | ||
exports.TransactionTypes = z; | ||
exports.authenticate = A; | ||
exports.defaultAuthURL = Ht; | ||
exports.getDefaultProfileUpdateRequestOptions = Nt; | ||
exports.defaultAuthURL = jt; | ||
exports.getDefaultProfileUpdateRequestOptions = Ft; | ||
exports.getDefaultPsbtRequestOptions = yt; | ||
exports.getDefaultSignatureRequestOptions = O; | ||
exports.getDefaultSignatureRequestOptions = b; | ||
exports.getKeys = y; | ||
exports.getOrCreateUserSession = U; | ||
exports.getStacksProvider = c; | ||
exports.getOrCreateUserSession = B; | ||
exports.getStacksProvider = d; | ||
exports.getStxAddress = st; | ||
@@ -27,20 +27,20 @@ exports.getUserData = Zt; | ||
exports.hasAppPrivateKey = g; | ||
exports.isMobile = z; | ||
exports.isStacksWalletInstalled = zt; | ||
exports.makeContractCallToken = ct; | ||
exports.makeContractDeployToken = pt; | ||
exports.makeProfileUpdateToken = $t; | ||
exports.makePsbtToken = St; | ||
exports.isMobile = H; | ||
exports.isStacksWalletInstalled = Ht; | ||
exports.makeContractCallToken = pt; | ||
exports.makeContractDeployToken = ct; | ||
exports.makeProfileUpdateToken = Xt; | ||
exports.makePsbtToken = mt; | ||
exports.makeSTXTransferToken = ut; | ||
exports.openContractCall = le; | ||
exports.openContractDeploy = de; | ||
exports.openProfileUpdateRequestPopup = ze; | ||
exports.openProfileUpdateRequestPopup = He; | ||
exports.openPsbtRequestPopup = he; | ||
exports.openSTXTransfer = fe; | ||
exports.openSignatureRequestPopup = Be; | ||
exports.openStructuredDataSignatureRequestPopup = Fe; | ||
exports.openSignatureRequestPopup = Ue; | ||
exports.openStructuredDataSignatureRequestPopup = $e; | ||
exports.shouldUsePopup = Qt; | ||
exports.showBlockstackConnect = Ze; | ||
exports.showConnect = _t; | ||
exports.signMessage = Ot; | ||
exports.signMessage = bt; | ||
exports.signStructuredMessage = At; | ||
@@ -47,0 +47,0 @@ Object.keys(auth).forEach(function (k) { |
import { UserSession } from '@stacks/auth'; | ||
import type { AuthOptions, StacksProvider } from './types'; | ||
import type { AuthOptions } from './types'; | ||
export declare const defaultAuthURL = "https://app.blockstack.org"; | ||
@@ -10,3 +10,3 @@ export declare const isMobile: () => boolean; | ||
export declare const getOrCreateUserSession: (userSession?: UserSession) => UserSession; | ||
export declare const authenticate: (authOptions: AuthOptions, provider?: StacksProvider) => Promise<void>; | ||
export declare const authenticate: (authOptions: AuthOptions) => Promise<void>; | ||
export declare const getUserData: (userSession?: UserSession) => Promise<import("@stacks/auth").UserData>; |
import { PsbtRequestOptions } from '../types/bitcoin'; | ||
import { StacksProvider } from '../types'; | ||
export declare function getDefaultPsbtRequestOptions(options: PsbtRequestOptions): { | ||
allowedSighash?: import("../types").SignatureHash[]; | ||
allowedSighash?: import("../types/bitcoin").SignatureHash[]; | ||
hex: string; | ||
@@ -13,4 +12,4 @@ signAtIndex?: number | number[]; | ||
network?: import("@stacks/network").StacksNetwork; | ||
onCancel?: import("../types").PsbtCanceled; | ||
onFinish?: import("../types").PsbtFinished; | ||
onCancel?: import("../types/bitcoin").PsbtCanceled; | ||
onFinish?: import("../types/bitcoin").PsbtFinished; | ||
stxAddress?: string; | ||
@@ -23,2 +22,2 @@ userSession?: import("@stacks/auth").UserSession; | ||
*/ | ||
export declare function openPsbtRequestPopup(options: PsbtRequestOptions, provider?: StacksProvider): Promise<void>; | ||
export declare function openPsbtRequestPopup(options: PsbtRequestOptions): Promise<void>; |
@@ -1,2 +0,2 @@ | ||
import { ProfileUpdateRequestOptions, StacksProvider } from '../types'; | ||
import { ProfileUpdateRequestOptions } from '../types'; | ||
export declare function getDefaultProfileUpdateRequestOptions(options: ProfileUpdateRequestOptions): { | ||
@@ -16,2 +16,2 @@ profile: import("@stacks/profile").PublicPersonProfile; | ||
export declare const makeProfileUpdateToken: (options: ProfileUpdateRequestOptions) => Promise<string>; | ||
export declare function openProfileUpdateRequestPopup(options: ProfileUpdateRequestOptions, provider?: StacksProvider): Promise<void>; | ||
export declare function openProfileUpdateRequestPopup(options: ProfileUpdateRequestOptions): Promise<void>; |
import { CommonSignatureRequestOptions, SignatureRequestOptions } from '../types/signature'; | ||
import { StacksProvider } from '../types'; | ||
export declare function getDefaultSignatureRequestOptions(options: CommonSignatureRequestOptions): { | ||
@@ -12,4 +11,4 @@ appDetails?: { | ||
userSession?: import("@stacks/auth").UserSession; | ||
onFinish?: import("../types").SignatureFinished; | ||
onCancel?: import("../types").SignatureCanceled; | ||
onFinish?: import("../types/signature").SignatureFinished; | ||
onCancel?: import("../types/signature").SignatureCanceled; | ||
}; | ||
@@ -20,2 +19,2 @@ export interface SignatureRequestPayload { | ||
export declare const signMessage: (options: SignatureRequestOptions) => Promise<string>; | ||
export declare function openSignatureRequestPopup(options: SignatureRequestOptions, provider?: StacksProvider): Promise<void>; | ||
export declare function openSignatureRequestPopup(options: SignatureRequestOptions): Promise<void>; |
import { StructuredDataSignatureRequestOptions } from '../types/structuredDataSignature'; | ||
import { StacksProvider } from '../types'; | ||
export declare function signStructuredMessage(options: StructuredDataSignatureRequestOptions): Promise<string>; | ||
export declare function openStructuredDataSignatureRequestPopup(options: StructuredDataSignatureRequestOptions, provider?: StacksProvider): Promise<void>; | ||
export declare function openStructuredDataSignatureRequestPopup(options: StructuredDataSignatureRequestOptions): Promise<void>; |
import { UserSession } from '@stacks/auth'; | ||
import { ContractCallOptions, ContractCallRegularOptions, ContractCallSponsoredOptions, ContractDeployOptions, ContractDeployRegularOptions, ContractDeploySponsoredOptions, STXTransferOptions, STXTransferRegularOptions, STXTransferSponsoredOptions, TransactionOptions } from '../types/transactions'; | ||
import { StacksProvider } from '../types'; | ||
export declare const getUserSession: (_userSession?: UserSession) => UserSession; | ||
@@ -14,4 +13,10 @@ export declare function hasAppPrivateKey(userSession?: UserSession): string | false; | ||
export declare const makeSTXTransferToken: (options: STXTransferOptions) => Promise<string>; | ||
export declare function openContractCall(options: ContractCallOptions | ContractCallRegularOptions | ContractCallSponsoredOptions, provider?: StacksProvider): Promise<void>; | ||
export declare function openContractDeploy(options: ContractDeployOptions | ContractDeployRegularOptions | ContractDeploySponsoredOptions, provider?: StacksProvider): Promise<void>; | ||
export declare function openSTXTransfer(options: STXTransferOptions | STXTransferRegularOptions | STXTransferSponsoredOptions, provider?: StacksProvider): Promise<void>; | ||
export declare function openContractCall(options: ContractCallRegularOptions): Promise<void>; | ||
export declare function openContractCall(options: ContractCallSponsoredOptions): Promise<void>; | ||
export declare function openContractCall(options: ContractCallOptions): Promise<void>; | ||
export declare function openContractDeploy(options: ContractDeployRegularOptions): Promise<void>; | ||
export declare function openContractDeploy(options: ContractDeploySponsoredOptions): Promise<void>; | ||
export declare function openContractDeploy(options: ContractDeployOptions): Promise<void>; | ||
export declare function openSTXTransfer(options: STXTransferRegularOptions): Promise<void>; | ||
export declare function openSTXTransfer(options: STXTransferSponsoredOptions): Promise<void>; | ||
export declare function openSTXTransfer(options: STXTransferOptions): Promise<void>; |
import type { AuthOptions } from './types/auth'; | ||
import { StacksProvider } from './types'; | ||
export declare const showConnect: (authOptions: AuthOptions, provider?: StacksProvider) => void; | ||
export declare const showConnect: (authOptions: AuthOptions) => void; | ||
/** | ||
@@ -5,0 +4,0 @@ * @deprecated Use the renamed `showConnect` method |
{ | ||
"name": "@stacks/connect", | ||
"version": "7.3.2-alpha.8a13a1b.0", | ||
"version": "7.3.2-alpha.8d1d2bb.0", | ||
"license": "MIT", | ||
@@ -14,3 +14,3 @@ "prettier": "@stacks/prettier-config", | ||
"@stacks/auth": "^6.1.1", | ||
"@stacks/connect-ui": "^6.1.2-alpha.8a13a1b.0", | ||
"@stacks/connect-ui": "^6.1.2-alpha.8d1d2bb.0", | ||
"@stacks/network": "^6.1.1", | ||
@@ -39,3 +39,3 @@ "@stacks/profile": "^6.1.1", | ||
}, | ||
"gitHead": "ee504896cd435657ea3bd86f0ecdbe34311aa4dc" | ||
"gitHead": "8ea1574e788c0d0edaf842fe414c2f708f77cfbe" | ||
} |
@@ -177,23 +177,6 @@ # `@stacks/connect` [![npm](https://img.shields.io/npm/v/@stacks/connect)](https://www.npmjs.com/package/@stacks/connect) <!-- omit in toc --> | ||
### 🛠 Advanced <!-- omit in toc --> | ||
#### Opening a specific wallet <!-- omit in toc --> | ||
By default, `@stacks/connect` will defer to the `window.StacksProvider` object to interact with wallets. | ||
However, if multiple wallets are installed, they might interfere with each other. | ||
To avoid this, you can specify which wallet to use in the wallet interaction methods. | ||
```js | ||
// This will open only the Hiro Wallet | ||
authenticate({ ...opts }, HiroWalletProvider); | ||
openPsbtRequestPopup({ ...opts }, HiroWalletProvider); | ||
openProfileUpdateRequestPopup({ ...opts }, HiroWalletProvider); | ||
openSignatureRequestPopup({ ...opts }, HiroWalletProvider); | ||
openStructuredDataSignatureRequestPopup({ ...opts }, HiroWalletProvider); | ||
``` | ||
## 🤔 Pitfalls <!-- omit in toc --> | ||
- Connect can currently not set manual nonces, since this is not supported by wallets. | ||
- For some projects it might be necessary to also install the `regenerator-runtime` package. `npm install --save-dev regenerator-runtime`. This is a build issue of older versions of `@stacks/connect`. | ||
- For some projects it might be necessary to also install the `regenerator-runtime` package. `npm install --save-dev regenerator-runtime`. This is a build issue of `@stacks/connect` and we are working on a fix. | ||
@@ -200,0 +183,0 @@ ## 📚 Option Glossary <!-- omit in toc --> |
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
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
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
0
100
4311049
5848
212
+ Added@types/node@18.19.67(transitive)
- Removed@types/node@18.19.65(transitive)