Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stacks/connect

Package Overview
Dependencies
Maintainers
4
Versions
703
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stacks/connect - npm Package Compare versions

Comparing version 7.4.2 to 7.4.3-alpha.0dccaab.0

2

dist/index.js

@@ -9,3 +9,3 @@ 'use strict';

var X=Object.defineProperty,_=Object.defineProperties;var M=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,B=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(P)for(var n of P(t))B.call(t,n)&&b(e,n,t[n]);return e},c=(e,t)=>_(e,M(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&&P)for(var r of P(e))t.indexOf(r)<0&&B.call(e,r)&&(n[r]=e[r]);return n};function d(){return window.StacksProvider||window.BlockstackProvider}function zt(){return !!d()}var Qt="https://app.blockstack.org",R="7.4.2";typeof window!="undefined"&&(window.__CONNECT_VERSION__=R);var J=()=>{let e=navigator.userAgent;return /android/i.test(e)||/iPad|iPhone|iPod/.test(e)?!0:/windows phone/i.test(e)},Zt=()=>!J(),A=e=>{if(!e){let t=new auth.AppConfig(["store_write"],document.location.href);e=new auth.UserSession({appConfig:t});}return e},U=async(e,t=d())=>{if(!t)throw new Error("[Connect] No installed Stacks wallet found");let{redirectTo:n="/",manifestPath:r,onFinish:s,onCancel:o,sendToSignIn:i=!1,userSession:p,appDetails:u}=e,l=A(p);l.isUserSignedIn()&&l.signUserOut();let S=l.generateAndStoreTransitKey(),F=l.makeAuthRequest(S,`${document.location.origin}${n}`,`${document.location.origin}${r}`,l.appConfig.scopes,void 0,void 0,{sendToSignIn:i,appDetails:u,connectVersion:R});try{let T=await t.authenticationRequest(F);await l.handlePendingSignIn(T);let k=jsontokens.decodeToken(T),$=k==null?void 0:k.payload;s==null||s({authResponse:T,authResponsePayload:$,userSession:l});}catch(T){console.error("[Connect] Error during auth request",T),o==null||o();}},te=async e=>(e=A(e),e.isUserSignedIn()?e.loadUserData():e.isSignInPending()?e.handlePendingSignIn():null);var z=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+=z[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 Y=(r=>(r.ContractCall="contract_call",r.ContractDeploy="smart_contract",r.STXTransfer="token_transfer",r))(Y||{}),H=(o=>(o.BUFFER="buffer",o.UINT="uint",o.INT="int",o.PRINCIPAL="principal",o.BOOL="bool",o))(H||{});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 p;let{stxAddress:t,userSession:n,network:r}=e;if(t)return t;if(!n||!r)return;let s=(p=n==null?void 0:n.loadUserData().profile)==null?void 0:p.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=c(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 h(e,t){let{postConditions:n}=e;return n&&typeof n[0]!="string"&&(n=E(n)),new jsontokens.TokenSigner("ES256k",t).signAsync(c(a({},e),{postConditions:n}))}function w(e){let{postConditions:t}=e;return t&&typeof t[0]!="string"&&(t=E(t)),jsontokens.createUnsecuredToken(c(a({},e),{postConditions:t}))}var it=async({token:e,options:t},n)=>{var r,s,o;try{let i=await n.transactionRequest(e),{txRaw:p}=i,u=I(p.replace(/^0x/,"")),l=transactions.deserializeTransaction(u);if("sponsored"in t&&t.sponsored){(r=t.onFinish)==null||r.call(t,c(a({},i),{stacksTransaction:l}));return}(s=t.onFinish)==null||s.call(t,c(a({},i),{stacksTransaction:l}));}catch(i){console.error("[Connect] Error during transaction request",i),(o=t.onCancel)==null||o.call(t);}},ct=async e=>{let p=e,{functionArgs:t,appDetails:n,userSession:r}=p,s=f(p,["functionArgs","appDetails","userSession"]),o=t.map(u=>typeof u=="string"?u:m(transactions.serializeCV(u)));if(g(r)){let{privateKey:u,publicKey:l}=y(r),S=c(a({},s),{functionArgs:o,txType:"contract_call",publicKey:l});return n&&(S.appDetails=n),h(S,u)}let i=c(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:p}=y(n),u=c(a({},r),{publicKey:p,txType:"smart_contract"});return t&&(u.appDetails=t),h(u,i)}let s=c(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:p,publicKey:u}=y(r),l=c(a({},s),{amount:t.toString(10),publicKey:u,txType:"token_transfer"});return n&&(l.appDetails=n),h(l,p)}let o=c(a({},s),{amount:t.toString(10),txType:"token_transfer"});return n&&(o.appDetails=n),w(o)},lt=async e=>{let i=e,{txHex:t,appDetails:n,userSession:r}=i,s=f(i,["txHex","appDetails","userSession"]);if(g(r)){let{privateKey:p,publicKey:u}=y(r),l=c(a({},s),{txHex:t,publicKey:u});return n&&(l.appDetails=n),h(l,p)}let o=c(a({},s),{txHex:t});return n&&(o.appDetails=n),w(o)};async function C(e,t,n){let r=await t(a(a({},at(e)),e));return it({token:r,options:e},n)}function de(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return C(e,ct,t)}function fe(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return C(e,pt,t)}function ge(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return C(e,ut,t)}function ye(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return C(e,lt,t)}async function yt(e,t){return new jsontokens.TokenSigner("ES256k",t).signAsync(a({},e))}function xt(e){let t=e.network||new network.StacksTestnet,n=x(e.userSession),r=c(a({},e),{network:t,userSession:n});return a({},r)}async function St({token:e,options:t},n){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 mt=async e=>{let p=e,{allowedSighash:t,hex:n,signAtIndex:r,userSession:s}=p,o=f(p,["allowedSighash","hex","signAtIndex","userSession"]);if(g(s)){let{privateKey:u,publicKey:l}=y(s),S=c(a({},o),{allowedSighash:t,hex:n,signAtIndex:r,publicKey:l});return yt(S,u)}let i=a({},o);return jsontokens.createUnsecuredToken(i)};async function Tt(e,t,n){let r=await t(a(a({},xt(e)),e));return St({token:r,options:e},n)}function Ce(e,t=d()){return Tt(e,mt,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 kt(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=c(a({},e),{network:t,userSession:n});return a({stxAddress:Ct(r)},r)}async function Ot({token:e,options:t},n){var r,s;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 bt=async e=>{let s=e,{userSession:t}=s,n=f(s,["userSession"]);if(g(t)){let{privateKey:o,publicKey:i}=y(t),p=c(a({},n),{publicKey:i});return kt(p,o)}let r=a({},n);return jsontokens.createUnsecuredToken(r)};async function Dt(e,t,n){let r=await t(a(a({},O(e)),e));return Ot({token:r,options:e},n)}function Ue(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return Dt(e,bt,t)}async function At(e,t,n){let r=await t(a(a({},O(e)),e));return vt({token:r,options:e},n)}function N(e){return c(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 It(e){let r=e,{userSession:t}=r,n=f(r,["userSession"]);if(g(t)){let{privateKey:s,publicKey:o}=y(t),i=c(a({},n),{publicKey:o});return Ut(i,s)}return jsontokens.createUnsecuredToken(N(e))}async function vt({token:e,options:t},n){var r,s;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 Xe(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return At(e,It,t)}async function Nt(e,t){return new jsontokens.TokenSigner("ES256k",t).signAsync(a({},e))}function Ft(e){let t=e.network||new network.StacksTestnet,n=x(e.userSession),r=c(a({},e),{network:t,userSession:n});return a({},r)}async function $t({token:e,options:t},n){var r,s;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 Xt=async e=>{let o=e,{userSession:t,profile:n}=o,r=f(o,["userSession","profile"]);if(g(t)){let{privateKey:i,publicKey:p}=y(t),u=c(a({},r),{profile:n,publicKey:p});return Nt(u,i)}let s=a({},r);return jsontokens.createUnsecuredToken(s)};async function _t(e,t,n){let r=await t(a(a({},Ft(e)),e));return $t({token:r,options:e},n)}function Ye(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return _t(e,Xt,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 Vt=(e,t=d())=>{if(t){U(e,t);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);}},en=e=>Vt(e);
var X=Object.defineProperty,_=Object.defineProperties;var M=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,B=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(P)for(var n of P(t))B.call(t,n)&&b(e,n,t[n]);return e},c=(e,t)=>_(e,M(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&&P)for(var r of P(e))t.indexOf(r)<0&&B.call(e,r)&&(n[r]=e[r]);return n};function d(){return window.StacksProvider||window.BlockstackProvider}function zt(){return !!d()}var Qt="https://app.blockstack.org",R="7.4.3-alpha.0dccaab.0";typeof window!="undefined"&&(window.__CONNECT_VERSION__=R);var J=()=>{let e=navigator.userAgent;return /android/i.test(e)||/iPad|iPhone|iPod/.test(e)?!0:/windows phone/i.test(e)},Zt=()=>!J(),A=e=>{if(!e){let t=new auth.AppConfig(["store_write"],document.location.href);e=new auth.UserSession({appConfig:t});}return e},U=async(e,t=d())=>{if(!t)throw new Error("[Connect] No installed Stacks wallet found");let{redirectTo:n="/",manifestPath:r,onFinish:s,onCancel:o,sendToSignIn:i=!1,userSession:p,appDetails:u}=e,l=A(p);l.isUserSignedIn()&&l.signUserOut();let S=l.generateAndStoreTransitKey(),F=l.makeAuthRequest(S,`${document.location.origin}${n}`,`${document.location.origin}${r}`,l.appConfig.scopes,void 0,void 0,{sendToSignIn:i,appDetails:u,connectVersion:R});try{let T=await t.authenticationRequest(F);await l.handlePendingSignIn(T);let k=jsontokens.decodeToken(T),$=k==null?void 0:k.payload;s==null||s({authResponse:T,authResponsePayload:$,userSession:l});}catch(T){console.error("[Connect] Error during auth request",T),o==null||o();}},te=async e=>(e=A(e),e.isUserSignedIn()?e.loadUserData():e.isSignInPending()?e.handlePendingSignIn():null);var z=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+=z[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 Y=(r=>(r.ContractCall="contract_call",r.ContractDeploy="smart_contract",r.STXTransfer="token_transfer",r))(Y||{}),H=(o=>(o.BUFFER="buffer",o.UINT="uint",o.INT="int",o.PRINCIPAL="principal",o.BOOL="bool",o))(H||{});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 p;let{stxAddress:t,userSession:n,network:r}=e;if(t)return t;if(!n||!r)return;let s=(p=n==null?void 0:n.loadUserData().profile)==null?void 0:p.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=c(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 h(e,t){let{postConditions:n}=e;return n&&typeof n[0]!="string"&&(n=E(n)),new jsontokens.TokenSigner("ES256k",t).signAsync(c(a({},e),{postConditions:n}))}function w(e){let{postConditions:t}=e;return t&&typeof t[0]!="string"&&(t=E(t)),jsontokens.createUnsecuredToken(c(a({},e),{postConditions:t}))}var it=async({token:e,options:t},n)=>{var r,s,o;try{let i=await n.transactionRequest(e),{txRaw:p}=i,u=I(p.replace(/^0x/,"")),l=transactions.deserializeTransaction(u);if("sponsored"in t&&t.sponsored){(r=t.onFinish)==null||r.call(t,c(a({},i),{stacksTransaction:l}));return}(s=t.onFinish)==null||s.call(t,c(a({},i),{stacksTransaction:l}));}catch(i){console.error("[Connect] Error during transaction request",i),(o=t.onCancel)==null||o.call(t);}},ct=async e=>{let p=e,{functionArgs:t,appDetails:n,userSession:r}=p,s=f(p,["functionArgs","appDetails","userSession"]),o=t.map(u=>typeof u=="string"?u:m(transactions.serializeCV(u)));if(g(r)){let{privateKey:u,publicKey:l}=y(r),S=c(a({},s),{functionArgs:o,txType:"contract_call",publicKey:l});return n&&(S.appDetails=n),h(S,u)}let i=c(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:p}=y(n),u=c(a({},r),{publicKey:p,txType:"smart_contract"});return t&&(u.appDetails=t),h(u,i)}let s=c(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:p,publicKey:u}=y(r),l=c(a({},s),{amount:t.toString(10),publicKey:u,txType:"token_transfer"});return n&&(l.appDetails=n),h(l,p)}let o=c(a({},s),{amount:t.toString(10),txType:"token_transfer"});return n&&(o.appDetails=n),w(o)},lt=async e=>{let i=e,{txHex:t,appDetails:n,userSession:r}=i,s=f(i,["txHex","appDetails","userSession"]);if(g(r)){let{privateKey:p,publicKey:u}=y(r),l=c(a({},s),{txHex:t,publicKey:u});return n&&(l.appDetails=n),h(l,p)}let o=c(a({},s),{txHex:t});return n&&(o.appDetails=n),w(o)};async function C(e,t,n){let r=await t(a(a({},at(e)),e));return it({token:r,options:e},n)}function de(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return C(e,ct,t)}function fe(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return C(e,pt,t)}function ge(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return C(e,ut,t)}function ye(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return C(e,lt,t)}async function yt(e,t){return new jsontokens.TokenSigner("ES256k",t).signAsync(a({},e))}function xt(e){let t=e.network||new network.StacksTestnet,n=x(e.userSession),r=c(a({},e),{network:t,userSession:n});return a({},r)}async function St({token:e,options:t},n){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 mt=async e=>{let p=e,{allowedSighash:t,hex:n,signAtIndex:r,userSession:s}=p,o=f(p,["allowedSighash","hex","signAtIndex","userSession"]);if(g(s)){let{privateKey:u,publicKey:l}=y(s),S=c(a({},o),{allowedSighash:t,hex:n,signAtIndex:r,publicKey:l});return yt(S,u)}let i=a({},o);return jsontokens.createUnsecuredToken(i)};async function Tt(e,t,n){let r=await t(a(a({},xt(e)),e));return St({token:r,options:e},n)}function Ce(e,t=d()){return Tt(e,mt,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 kt(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=c(a({},e),{network:t,userSession:n});return a({stxAddress:Ct(r)},r)}async function Ot({token:e,options:t},n){var r,s;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 bt=async e=>{let s=e,{userSession:t}=s,n=f(s,["userSession"]);if(g(t)){let{privateKey:o,publicKey:i}=y(t),p=c(a({},n),{publicKey:i});return kt(p,o)}let r=a({},n);return jsontokens.createUnsecuredToken(r)};async function Dt(e,t,n){let r=await t(a(a({},O(e)),e));return Ot({token:r,options:e},n)}function Ue(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return Dt(e,bt,t)}async function At(e,t,n){let r=await t(a(a({},O(e)),e));return vt({token:r,options:e},n)}function N(e){return c(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 It(e){let r=e,{userSession:t}=r,n=f(r,["userSession"]);if(g(t)){let{privateKey:s,publicKey:o}=y(t),i=c(a({},n),{publicKey:o});return Ut(i,s)}return jsontokens.createUnsecuredToken(N(e))}async function vt({token:e,options:t},n){var r,s;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 Xe(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return At(e,It,t)}async function Nt(e,t){return new jsontokens.TokenSigner("ES256k",t).signAsync(a({},e))}function Ft(e){let t=e.network||new network.StacksTestnet,n=x(e.userSession),r=c(a({},e),{network:t,userSession:n});return a({},r)}async function $t({token:e,options:t},n){var r,s;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 Xt=async e=>{let o=e,{userSession:t,profile:n}=o,r=f(o,["userSession","profile"]);if(g(t)){let{privateKey:i,publicKey:p}=y(t),u=c(a({},r),{profile:n,publicKey:p});return Nt(u,i)}let s=a({},r);return jsontokens.createUnsecuredToken(s)};async function _t(e,t,n){let r=await t(a(a({},Ft(e)),e));return $t({token:r,options:e},n)}function Ye(e,t=d()){if(!t)throw new Error("[Connect] No installed Stacks wallet found");return _t(e,Xt,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 Vt=(e,t=d())=>{if(t){U(e,t);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);}},en=e=>Vt(e);

@@ -12,0 +12,0 @@ exports.ContractCallArgumentType = H;

{
"name": "@stacks/connect",
"version": "7.4.2",
"version": "7.4.3-alpha.0dccaab.0",
"license": "MIT",

@@ -14,3 +14,3 @@ "prettier": "@stacks/prettier-config",

"@stacks/auth": "^6.1.1",
"@stacks/connect-ui": "6.1.3",
"@stacks/connect-ui": "^6.1.4-alpha.0dccaab.0",
"@stacks/network": "^6.1.1",

@@ -39,3 +39,3 @@ "@stacks/profile": "^6.1.1",

},
"gitHead": "3b52a2d417e114e8c5c77782e676befaa35c6189"
"gitHead": "760a378a8a75de57497bd361b1f568a71451ae5d"
}

@@ -170,5 +170,5 @@ # `@stacks/connect` [![npm](https://img.shields.io/npm/v/@stacks/connect)](https://www.npmjs.com/package/@stacks/connect) <!-- omit in toc -->

- `PostConditionMode.Deny` will fail the transaction if any unspecified assets are transferred
- `PostConditionMode.Allow` will allow unspecified assets to be transferred
- In both cases, all `postConditions` will be checked
- `PostConditionMode.Deny` fails the transaction if any unspecified assets are transferred
- `PostConditionMode.Allow` allows unspecified assets to be transferred
- In both cases, all `postConditions` are checked

@@ -179,3 +179,3 @@ ### 🛠 Advanced <!-- omit in toc -->

By default, `@stacks/connect` will defer to the `window.StacksProvider` object to interact with wallets.
By default, `@stacks/connect` defers to the `window.StacksProvider` object to interact with wallets.
However, if multiple wallets are installed, they might interfere with each other.

@@ -185,8 +185,8 @@ 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);
// Only opens requests in Leather
authenticate({ ...opts }, LeatherProvider);
openPsbtRequestPopup({ ...opts }, LeatherProvider);
openProfileUpdateRequestPopup({ ...opts }, LeatherProvider);
openSignatureRequestPopup({ ...opts }, LeatherProvider);
openStructuredDataSignatureRequestPopup({ ...opts }, LeatherProvider);
```

@@ -193,0 +193,0 @@

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc