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

@stacks/common

Package Overview
Dependencies
Maintainers
0
Versions
617
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stacks/common - npm Package Compare versions

Comparing version 7.0.0-next.70 to 7.0.0-next.89

15

dist/esm/fetch.d.ts
export declare const getFetchOptions: () => RequestInit;
export declare const setFetchOptions: (ops: RequestInit) => RequestInit;
export type FetchFn = (url: string, init?: RequestInit) => Promise<Response>;
export type ClientOpts = {
export interface ClientOpts {
baseUrl?: string;
fetch?: FetchFn;
};
export type ClientParam = {
}
export interface ClientParam {
client?: ClientOpts;
};
}
export interface RequestContext {

@@ -38,8 +38,1 @@ fetch: FetchFn;

export declare function createFetchFn(...middleware: FetchMiddleware[]): FetchFn;
export declare function defaultClientOpts(opts?: {
baseUrl?: string;
fetch?: FetchFn;
}): {
baseUrl: string;
fetch: FetchFn;
};

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

import { HIRO_MAINNET_URL } from './constants';
const defaultFetchOpts = {

@@ -78,8 +77,2 @@ referrerPolicy: 'origin',

}
export function defaultClientOpts(opts) {
return {
baseUrl: opts?.baseUrl ?? HIRO_MAINNET_URL,
fetch: opts?.fetch ?? createFetchFn(),
};
}
//# sourceMappingURL=fetch.js.map

@@ -26,3 +26,3 @@ export declare const BLOCKSTACK_HANDLER = "blockstack";

export declare function hexToBigInt(hex: string): bigint;
export declare function intToHex(integer: IntegerType, lengthBytes?: number): string;
export declare function intToHex(integer: IntegerType, byteLength?: number): string;
export declare function hexToInt(hex: string): number;

@@ -29,0 +29,0 @@ export declare function bigIntToBytes(value: bigint, length?: number): Uint8Array;

@@ -212,5 +212,5 @@ import { Logger } from './logger';

}
export function intToHex(integer, lengthBytes = 8) {
export function intToHex(integer, byteLength = 8) {
const value = typeof integer === 'bigint' ? integer : intToBigInt(integer);
return value.toString(16).padStart(lengthBytes * 2, '0');
return value.toString(16).padStart(byteLength * 2, '0');
}

@@ -217,0 +217,0 @@ export function hexToInt(hex) {

export declare const getFetchOptions: () => RequestInit;
export declare const setFetchOptions: (ops: RequestInit) => RequestInit;
export type FetchFn = (url: string, init?: RequestInit) => Promise<Response>;
export type ClientOpts = {
export interface ClientOpts {
baseUrl?: string;
fetch?: FetchFn;
};
export type ClientParam = {
}
export interface ClientParam {
client?: ClientOpts;
};
}
export interface RequestContext {

@@ -38,8 +38,1 @@ fetch: FetchFn;

export declare function createFetchFn(...middleware: FetchMiddleware[]): FetchFn;
export declare function defaultClientOpts(opts?: {
baseUrl?: string;
fetch?: FetchFn;
}): {
baseUrl: string;
fetch: FetchFn;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultClientOpts = exports.createFetchFn = exports.createApiKeyMiddleware = exports.hostMatches = exports.fetchWrapper = exports.setFetchOptions = exports.getFetchOptions = void 0;
const constants_1 = require("./constants");
exports.createFetchFn = exports.createApiKeyMiddleware = exports.hostMatches = exports.fetchWrapper = exports.setFetchOptions = exports.getFetchOptions = void 0;
const defaultFetchOpts = {

@@ -87,9 +86,2 @@ referrerPolicy: 'origin',

exports.createFetchFn = createFetchFn;
function defaultClientOpts(opts) {
return {
baseUrl: opts?.baseUrl ?? constants_1.HIRO_MAINNET_URL,
fetch: opts?.fetch ?? createFetchFn(),
};
}
exports.defaultClientOpts = defaultClientOpts;
//# sourceMappingURL=fetch.js.map

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.StacksCommon=t():e.StacksCommon=t()}(this,(()=>(()=>{"use strict";var e={142:(e,t,r)=>{function n(e,t){if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function o(e,t){const r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=t;return r}function s(e,t){return(e[t+0]<<8|e[t+1])>>>0}function i(e,t,r=0){return e[r+0]=t>>>8,e[r+1]=t>>>0,e}function a(e,t){return e[t]}function c(e,t,r=0){return e[r]=t,e}function u(e,t){return e[t+0]<<0>>>0|e[t+1]<<8>>>0}function l(e,t,r=0){return e[r+0]=255&t,t>>>=8,e[r+1]=255&t,e}function g(e,t){return e[t]*2**24+65536*e[t+1]+256*e[t+2]+e[t+3]}function f(e,t,r=0){return e[r+3]=t,t>>>=8,e[r+2]=t,t>>>=8,e[r+1]=t,t>>>=8,e[r]=t,e}function d(e,t){return e[t+0]<<0>>>0|e[t+1]<<8>>>0|e[t+2]<<16>>>0|e[t+3]<<24>>>0}function h(e,t,r=0){return e[r+0]=255&t,t>>>=8,e[r+1]=255&t,t>>>=8,e[r+2]=255&t,t>>>=8,e[r+3]=255&t,e}r.d(t,{Ag:()=>g,Cg:()=>c,Q$:()=>a,T4:()=>f,cQ:()=>i,fS:()=>n,mP:()=>u,n8:()=>s,nm:()=>d,oq:()=>l,un:()=>o,v7:()=>h})},392:(e,t,r)=>{r.d(t,{v:()=>n});const n={network:{layer1:"placeholder"},logLevel:"debug"}},902:(e,t,r)=>{r.d(t,{IE:()=>o,Mh:()=>c,fg:()=>n,it:()=>s,lW:()=>i,sQ:()=>a});const n="https://api.mainnet.hiro.so",o="https://api.testnet.hiro.so",s="http://localhost:3999",i="https://hub.blockstack.org",a=33,c=32},889:(e,t,r)=>{r.d(t,{AI:()=>I,AY:()=>y,Ev:()=>u,Fe:()=>E,Ie:()=>b,JU:()=>m,M4:()=>h,O1:()=>n,Ru:()=>R,Y0:()=>f,hy:()=>a,jO:()=>s,kn:()=>c,oO:()=>p,p8:()=>_,sk:()=>o,ur:()=>T,v0:()=>i,vP:()=>d,xE:()=>l,zd:()=>g});const n={MISSING_PARAMETER:"missing_parameter",REMOTE_SERVICE_ERROR:"remote_service_error",INVALID_STATE:"invalid_state",NO_SESSION_DATA:"no_session_data",DOES_NOT_EXIST:"does_not_exist",FAILED_DECRYPTION_ERROR:"failed_decryption_error",INVALID_DID_ERROR:"invalid_did_error",NOT_ENOUGH_FUNDS_ERROR:"not_enough_error",INVALID_AMOUNT_ERROR:"invalid_amount_error",LOGIN_FAILED_ERROR:"login_failed",SIGNATURE_VERIFICATION_ERROR:"signature_verification_failure",CONFLICT_ERROR:"conflict_error",NOT_ENOUGH_PROOF_ERROR:"not_enough_proof_error",BAD_PATH_ERROR:"bad_path_error",VALIDATION_ERROR:"validation_error",PAYLOAD_TOO_LARGE_ERROR:"payload_too_large_error",PRECONDITION_FAILED_ERROR:"precondition_failed_error",UNKNOWN:"unknown"};Object.freeze(n);class o extends Error{constructor(e){super();let t=e.message,r=`Error Code: ${e.code}`,n=this.stack;if(n)r+=`Stack Trace:\n${n}`;else try{throw new Error}catch(e){n=e.stack}t+=`\nIf you believe this exception is caused by a bug in stacks.js,\n please file a bug report: https://github.com/blockstack/stacks.js/issues\n\n${r}`,this.message=t,this.code=e.code,this.parameter=e.parameter?e.parameter:void 0}toString(){return`${super.toString()}\n code: ${this.code} param: ${this.parameter?this.parameter:"n/a"}`}}class s extends o{constructor(e,t=""){super({code:n.MISSING_PARAMETER,message:t,parameter:e}),this.name="MissingParametersError"}}class i extends o{constructor(e,t=""){super({code:n.MISSING_PARAMETER,message:t,parameter:e}),this.name="MissingParametersError"}}class a extends o{constructor(e,t=""){super({code:n.REMOTE_SERVICE_ERROR,message:t}),this.response=e}}class c extends o{constructor(e=""){super({code:n.INVALID_DID_ERROR,message:e}),this.name="InvalidDIDError"}}class u extends o{constructor(e){const t=`Not enough UTXOs to fund. Left to fund: ${e}`;super({code:n.NOT_ENOUGH_FUNDS_ERROR,message:t}),this.leftToFund=e,this.name="NotEnoughFundsError",this.message=t}}class l extends o{constructor(e,t){const r=`Not enough coin to fund fees transaction fees. Fees would be ${e}, specified spend is ${t}`;super({code:n.INVALID_AMOUNT_ERROR,message:r}),this.specifiedAmount=t,this.fees=e,this.name="InvalidAmountError",this.message=r}}class g extends o{constructor(e){const t=`Failed to login: ${e}`;super({code:n.LOGIN_FAILED_ERROR,message:t}),this.message=t,this.name="LoginFailedError"}}class f extends o{constructor(e){const t=`Failed to verify signature: ${e}`;super({code:n.SIGNATURE_VERIFICATION_ERROR,message:t}),this.message=t,this.name="SignatureVerificationError"}}class d extends o{constructor(e="Unable to decrypt cipher object."){super({code:n.FAILED_DECRYPTION_ERROR,message:e}),this.message=e,this.name="FailedDecryptionError"}}class h extends o{constructor(e){super({code:n.INVALID_STATE,message:e}),this.message=e,this.name="InvalidStateError"}}class E extends o{constructor(e){super({code:n.INVALID_STATE,message:e}),this.message=e,this.name="NoSessionDataError"}}class p extends o{constructor(e,t){super(e),t&&(this.hubError={statusCode:t.status,statusText:t.statusText},"string"==typeof t.body?this.hubError.message=t.body:"object"==typeof t.body&&Object.assign(this.hubError,t.body))}}class I extends p{constructor(e,t){super({message:e,code:n.DOES_NOT_EXIST},t),this.name="DoesNotExist"}}class y extends p{constructor(e,t){super({message:e,code:n.CONFLICT_ERROR},t),this.name="ConflictError"}}class m extends p{constructor(e,t){super({message:e,code:n.NOT_ENOUGH_PROOF_ERROR},t),this.name="NotEnoughProofError"}}class R extends p{constructor(e,t){super({message:e,code:n.BAD_PATH_ERROR},t),this.name="BadPathError"}}class _ extends p{constructor(e,t){super({message:e,code:n.VALIDATION_ERROR},t),this.name="ValidationError"}}class b extends p{constructor(e,t,r){super({message:e,code:n.PAYLOAD_TOO_LARGE_ERROR},t),this.name="PayloadTooLargeError",this.maxUploadByteSize=r}}class T extends p{constructor(e,t){super({message:e,code:n.PRECONDITION_FAILED_ERROR},t),this.name="PreconditionFailedError"}}},436:(e,t,r)=>{r.d(t,{O6:()=>g,e3:()=>I,eA:()=>p,h$:()=>h,hM:()=>d,i$:()=>f,jX:()=>E});var n=r(902),o=Object.defineProperty,s=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,c=(e,t,r)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,u=(e,t)=>{for(var r in t||(t={}))i.call(t,r)&&c(e,r,t[r]);if(s)for(var r of s(t))a.call(t,r)&&c(e,r,t[r]);return e};const l={referrerPolicy:"origin",headers:{"x-hiro-product":"stacksjs"}},g=()=>l,f=e=>Object.assign(l,e);async function d(e,t){const r={};return Object.assign(r,l,t),await fetch(e,r)}function h(e,t){return"string"==typeof t?t===e:t.exec(e)}function E({apiKey:e,host:t=/(.*)api(.*)(\.stacks\.co|\.hiro\.so)$/i,httpHeader:r="x-api-key"}){return{pre:n=>{h(new URL(n.url).host,t)&&(n.init.headers instanceof Headers?n.init.headers:n.init.headers=new Headers(n.init.headers)).set(r,e)}}}function p(...e){const{fetchLib:t,middlewares:r}=function(e){let t=d,r=[];return e.length>0&&"function"==typeof e[0]&&(t=e.shift()),e.length>0&&(r=e),{fetchLib:t,middlewares:r}}(e);return async(e,n)=>{var o;let s={url:e,init:null!=n?n:{}};for(const e of r)if("function"==typeof e.pre){const r=await Promise.resolve(e.pre(u({fetch:t},s)));s=null!=r?r:s}let i=await t(s.url,s.init);for(const e of r)if("function"==typeof e.post){const r=await Promise.resolve(e.post({fetch:t,url:s.url,init:s.init,response:null!=(o=null==i?void 0:i.clone())?o:i}));i=null!=r?r:i}return i}}function I(e){var t,r;return{baseUrl:null!=(t=null==e?void 0:e.baseUrl)?t:n.fg,fetch:null!=(r=null==e?void 0:e.fetch)?r:p()}}},631:(e,t,r)=>{r.d(t,{z:()=>o});var n=r(788);function o(e){const t="string"==typeof e?(0,n.nr)(e):e;if(32!=t.length&&33!=t.length)throw new Error(`Improperly formatted private-key. Private-key byte length should be 32 or 33. Length provided: ${t.length}`);if(33==t.length&&1!==t[32])throw new Error("Improperly formatted private-key. 33 bytes indicate compressed key, but the last byte must be == 01");return t}},976:(e,t,r)=>{r.d(t,{Y:()=>a});var n=r(392);const o=["debug","info","warn","error","none"],s={},i={};for(let e=0;e<o.length;e++){const t=o[e];s[t]=e,i[e]=t}class a{static error(e){this.shouldLog("error")&&console.error(this.logMessage("error",e))}static warn(e){this.shouldLog("warn")&&console.warn(this.logMessage("warn",e))}static info(e){this.shouldLog("info")&&console.log(this.logMessage("info",e))}static debug(e){this.shouldLog("debug")&&console.log(this.logMessage("debug",e))}static logMessage(e,t){return`[${e.toUpperCase()}] ${t}`}static shouldLog(e){return s[n.v.logLevel]<=s[e]}}},225:(e,t,r)=>{r.d(t,{U8:()=>a,ph:()=>i,xP:()=>s});var n=r(788);const o=32;function s(e){if(e.length<2*o*2+1)throw new Error("Invalid signature");const t=e.slice(0,2),r=e.slice(2,2+2*o),s=e.slice(2+2*o);return{recoveryId:(0,n.WR)(t),r,s}}function i(e){return e.slice(2)+e.slice(0,2)}function a(e){return e.slice(-2)+e.slice(0,-2)}},59:()=>{},788:(e,t,r)=>{r.d(t,{$O:()=>k,$g:()=>_,$j:()=>v,A5:()=>y,GW:()=>g,HN:()=>R,I4:()=>O,Md:()=>B,NA:()=>F,NJ:()=>s,QD:()=>P,Qs:()=>$,Rf:()=>I,T7:()=>V,WR:()=>w,WT:()=>u,WW:()=>C,Xt:()=>c,_Y:()=>N,at:()=>b,cG:()=>a,ci:()=>U,cn:()=>A,eV:()=>j,gS:()=>d,iY:()=>D,jk:()=>x,ko:()=>h,lW:()=>E,nD:()=>i,nr:()=>L,ru:()=>l,sO:()=>m,se:()=>f,y_:()=>T,ym:()=>o});var n=r(976);const o="blockstack";function s(){return new Date((new Date).setFullYear((new Date).getFullYear()+1))}function i(){return new Date((new Date).setMonth((new Date).getMonth()+1))}function a(){return new Date((new Date).setHours((new Date).getHours()+1))}function c(e){return Number.isFinite(e)?Math.floor(1024*e*1024):0}function u(e){return 16*(Math.floor(e/16)+1)}function l(e){return 4*Math.ceil(e/3)}function g(e,t,r){const n=new RegExp(`([?&])${t}=.*?(&|$)`,"i"),o=-1!==e.indexOf("?")?"&":"?";return e.match(n)?e.replace(n,`$1${t}=${r}$2`):`${e}${o}${t}=${r}`}function f(e,t){void 0!==e&&""!==e||(e="0.0.0"),void 0!==t&&""!==e||(t="0.0.0");const r=e.split(".").map((e=>parseInt(e,10))),n=t.split(".").map((e=>parseInt(e,10)));for(let o=0;o<t.length;o++)if(o>=e.length&&n.push(0),r[o]<n[o])return!1;return!0}function d(){let e=(new Date).getTime();return"undefined"!=typeof performance&&"function"==typeof performance.now&&(e+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?r:3&r|8).toString(16)}))}function h(e,t){try{const r=new URL(e),n=new URL(t),o=0|parseInt(r.port||"0",10)||("https:"===r.protocol?443:80),s=0|parseInt(n.port||"0",10)||("https:"===n.protocol?443:80),i={scheme:r.protocol===n.protocol,hostname:r.hostname===n.hostname,port:o===s,absolute:(e.includes("http://")||e.includes("https://"))&&(t.includes("http://")||t.includes("https://"))};return i.scheme&&i.hostname&&i.port&&i.absolute}catch(e){return console.log(e),console.log("Parsing error in same URL origin check"),!1}}function E(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r.g)return r.g;throw new Error("Unexpected runtime environment - no supported global scope (`window`, `self`, `global`) available")}function p(e,t,r){return r?`Use of '${r}' requires \`${t}\` which is unavailable on the '${e}' object within the currently executing environment.`:`\`${t}\` is unavailable on the '${e}' object within the currently executing environment.`}function I(e,{throwIfUnavailable:t,usageDesc:r,returnEmptyObject:o}={}){let s;try{if(s=E(),s){const t=s[e];if(t)return t}}catch(t){n.Y.error(`Error getting object '${e}' from global scope '${s}': ${t}`)}if(t){const t=p(s,e.toString(),r);throw n.Y.error(t),new Error(t)}if(o)return{}}function y(e,{throwIfUnavailable:t,usageDesc:r,returnEmptyObject:o}={}){let s;try{s=E()}catch(i){if(n.Y.error(`Error getting global scope: ${i}`),t){const t=p(s,e[0].toString(),r);throw n.Y.error(t),t}o&&(s={})}const i={};for(let a=0;a<e.length;a++){const c=e[a];try{if(s){const e=s[c];if(e)i[c]=e;else{if(t){const e=p(s,c.toString(),r);throw n.Y.error(e),new Error(e)}o&&(i[c]={})}}}catch(e){if(t){const e=p(s,c.toString(),r);throw n.Y.error(e),new Error(e)}}}return i}function m(e,t){return x(R(e),t)}function R(e){if("bigint"==typeof e)return e;if("string"==typeof e)return BigInt(e);if("number"==typeof e){if(!Number.isInteger(e))throw new RangeError("Invalid value. Values of type 'number' must be an integer.");if(e>Number.MAX_SAFE_INTEGER)throw new RangeError(`Invalid value. Values of type 'number' must be less than or equal to ${Number.MAX_SAFE_INTEGER}. For larger values, try using a BigInt instead.`);return BigInt(e)}if(k(e,Uint8Array))return BigInt(`0x${U(e)}`);throw new TypeError("intToBigInt: Invalid value type. Must be a number, bigint, BigInt-compatible string, or Uint8Array.")}function _(e){return/^0x/i.test(e)?e:`0x${e}`}function b(e){return/^0x/i.test(e)?e.slice(2):e}function T(e){if("string"!=typeof e)throw new TypeError("hexToBigInt: expected string, got "+typeof e);return BigInt(`0x${e}`)}function O(e,t=8){return("bigint"==typeof e?e:R(e)).toString(16).padStart(2*t,"0")}function w(e){return parseInt(e,16)}function x(e,t=16){return L(O(e,t))}function v(e,t){if(e<-(BigInt(1)<<t-BigInt(1))||(BigInt(1)<<t-BigInt(1))-BigInt(1)<e)throw`Unable to represent integer in width: ${t}`;return e>=BigInt(0)?BigInt(e):e+(BigInt(1)<<t)}function A(e){return N(BigInt(`0x${U(e)}`),BigInt(8*e.byteLength))}function N(e,t){return function(e,t){return e&BigInt(1)<<t}(e,t-BigInt(1))?e-(BigInt(1)<<t):e}const S=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function U(e){if(!(e instanceof Uint8Array))throw new Error("Uint8Array expected");let t="";for(const r of e)t+=S[r];return t}function L(e){if("string"!=typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);e=(e=b(e)).length%2?`0${e}`:e;const t=new Uint8Array(e.length/2);for(let r=0;r<t.length;r++){const n=2*r,o=e.slice(n,n+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");t[r]=s}return t}function D(e){return(new TextEncoder).encode(e)}function B(e){return(new TextDecoder).decode(e)}function P(e){const t=[];for(let r=0;r<e.length;r++)t.push(255&e.charCodeAt(r));return new Uint8Array(t)}function $(e){return String.fromCharCode.apply(null,e)}function M(e){return!Number.isInteger(e)||e<0||e>255}function F(e){if(e.some(M))throw new Error("Some values are invalid bytes.");return new Uint8Array(e)}function j(...e){if(!e.every((e=>e instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===e.length)return e[0];const t=e.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return r}function C(e){return j(...e.map((e=>"number"==typeof e?F([e]):e instanceof Array?F(e):e)))}function k(e,t){var r,n;return e instanceof t||(null==(n=null==(r=null==e?void 0:e.constructor)?void 0:r.name)?void 0:n.toLowerCase())===t.name}function V(e){return 64===(e=b(e)).length&&/^[0-9a-fA-F]+$/.test(e)}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{r.r(n),r.d(n,{BLOCKSTACK_HANDLER:()=>s.ym,BadPathError:()=>t.Ru,BlockstackError:()=>t.sk,ConflictError:()=>t.AY,DEVNET_URL:()=>i.it,DoesNotExist:()=>t.AI,ERROR_CODES:()=>t.O1,FailedDecryptionError:()=>t.vP,GAIA_URL:()=>i.lW,GaiaHubError:()=>t.oO,HIRO_MAINNET_URL:()=>i.fg,HIRO_TESTNET_URL:()=>i.IE,InvalidAmountError:()=>t.xE,InvalidDIDError:()=>t.kn,InvalidParameterError:()=>t.jO,InvalidStateError:()=>t.M4,Logger:()=>o.Y,LoginFailedError:()=>t.zd,MissingParameterError:()=>t.v0,NoSessionDataError:()=>t.Fe,NotEnoughFundsError:()=>t.Ev,NotEnoughProofError:()=>t.JU,PRIVATE_KEY_BYTES_COMPRESSED:()=>i.sQ,PRIVATE_KEY_BYTES_UNCOMPRESSED:()=>i.Mh,PayloadTooLargeError:()=>t.Ie,PreconditionFailedError:()=>t.ur,RemoteServiceError:()=>t.hy,SignatureVerificationError:()=>t.Y0,ValidationError:()=>t.p8,alloc:()=>u.un,asciiToBytes:()=>s.QD,bigIntToBytes:()=>s.jk,bytesToAscii:()=>s.Qs,bytesToHex:()=>s.ci,bytesToTwosBigInt:()=>s.cn,bytesToUtf8:()=>s.Md,concatArray:()=>s.WW,concatBytes:()=>s.eV,config:()=>e.v,createApiKeyMiddleware:()=>f.jX,createFetchFn:()=>f.eA,defaultClientOpts:()=>f.e3,equals:()=>u.fS,fetchWrapper:()=>f.hM,fromTwos:()=>s._Y,getAesCbcOutputLength:()=>s.WT,getBase64OutputLength:()=>s.ru,getFetchOptions:()=>f.O6,getGlobalObject:()=>s.Rf,getGlobalObjects:()=>s.A5,getGlobalScope:()=>s.lW,hexToBigInt:()=>s.y_,hexToBytes:()=>s.nr,hexToInt:()=>s.WR,hostMatches:()=>f.h$,intToBigInt:()=>s.HN,intToBytes:()=>s.sO,intToHex:()=>s.I4,isInstance:()=>s.$O,isLaterVersion:()=>s.se,isSameOriginAbsoluteUrl:()=>s.ko,makeUUID4:()=>s.gS,megabytesToBytes:()=>s.Xt,nextHour:()=>s.cG,nextMonth:()=>s.nD,nextYear:()=>s.NJ,octetsToBytes:()=>s.NA,parseRecoverableSignatureVrs:()=>a.xP,privateKeyToBytes:()=>c.z,readUInt16BE:()=>u.n8,readUInt16LE:()=>u.mP,readUInt32BE:()=>u.Ag,readUInt32LE:()=>u.nm,readUInt8:()=>u.Q$,setFetchOptions:()=>f.i$,signatureRsvToVrs:()=>a.U8,signatureVrsToRsv:()=>a.ph,toTwos:()=>s.$j,updateQueryStringParameter:()=>s.GW,utf8ToBytes:()=>s.iY,validateHash256:()=>s.T7,with0x:()=>s.$g,without0x:()=>s.at,writeUInt16BE:()=>u.cQ,writeUInt16LE:()=>u.oq,writeUInt32BE:()=>u.T4,writeUInt32LE:()=>u.v7,writeUInt8:()=>u.Cg});var e=r(392),t=r(889),o=r(976),s=r(788),i=r(902),a=r(225),c=r(631),u=r(142),l=r(59),g={};for(const e in l)["default","config","BadPathError","BlockstackError","ConflictError","DoesNotExist","ERROR_CODES","FailedDecryptionError","GaiaHubError","InvalidAmountError","InvalidDIDError","InvalidParameterError","InvalidStateError","LoginFailedError","MissingParameterError","NoSessionDataError","NotEnoughFundsError","NotEnoughProofError","PayloadTooLargeError","PreconditionFailedError","RemoteServiceError","SignatureVerificationError","ValidationError","Logger","BLOCKSTACK_HANDLER","asciiToBytes","bigIntToBytes","bytesToAscii","bytesToHex","bytesToTwosBigInt","bytesToUtf8","concatArray","concatBytes","fromTwos","getAesCbcOutputLength","getBase64OutputLength","getGlobalObject","getGlobalObjects","getGlobalScope","hexToBigInt","hexToBytes","hexToInt","intToBigInt","intToBytes","intToHex","isInstance","isLaterVersion","isSameOriginAbsoluteUrl","makeUUID4","megabytesToBytes","nextHour","nextMonth","nextYear","octetsToBytes","toTwos","updateQueryStringParameter","utf8ToBytes","validateHash256","with0x","without0x","DEVNET_URL","GAIA_URL","HIRO_MAINNET_URL","HIRO_TESTNET_URL","PRIVATE_KEY_BYTES_COMPRESSED","PRIVATE_KEY_BYTES_UNCOMPRESSED","parseRecoverableSignatureVrs","signatureRsvToVrs","signatureVrsToRsv","privateKeyToBytes","alloc","equals","readUInt16BE","readUInt16LE","readUInt32BE","readUInt32LE","readUInt8","writeUInt16BE","writeUInt16LE","writeUInt32BE","writeUInt32LE","writeUInt8"].indexOf(e)<0&&(g[e]=()=>l[e]);r.d(n,g);var f=r(436)})(),n})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.StacksCommon=t():e.StacksCommon=t()}(this,(()=>(()=>{"use strict";var e={142:(e,t,r)=>{function n(e,t){if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function o(e,t){const r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=t;return r}function s(e,t){return(e[t+0]<<8|e[t+1])>>>0}function i(e,t,r=0){return e[r+0]=t>>>8,e[r+1]=t>>>0,e}function a(e,t){return e[t]}function c(e,t,r=0){return e[r]=t,e}function u(e,t){return e[t+0]<<0>>>0|e[t+1]<<8>>>0}function l(e,t,r=0){return e[r+0]=255&t,t>>>=8,e[r+1]=255&t,e}function g(e,t){return e[t]*2**24+65536*e[t+1]+256*e[t+2]+e[t+3]}function f(e,t,r=0){return e[r+3]=t,t>>>=8,e[r+2]=t,t>>>=8,e[r+1]=t,t>>>=8,e[r]=t,e}function d(e,t){return e[t+0]<<0>>>0|e[t+1]<<8>>>0|e[t+2]<<16>>>0|e[t+3]<<24>>>0}function h(e,t,r=0){return e[r+0]=255&t,t>>>=8,e[r+1]=255&t,t>>>=8,e[r+2]=255&t,t>>>=8,e[r+3]=255&t,e}r.d(t,{Ag:()=>g,Cg:()=>c,Q$:()=>a,T4:()=>f,cQ:()=>i,fS:()=>n,mP:()=>u,n8:()=>s,nm:()=>d,oq:()=>l,un:()=>o,v7:()=>h})},392:(e,t,r)=>{r.d(t,{v:()=>n});const n={network:{layer1:"placeholder"},logLevel:"debug"}},902:(e,t,r)=>{r.d(t,{IE:()=>o,Mh:()=>c,fg:()=>n,it:()=>s,lW:()=>i,sQ:()=>a});const n="https://api.mainnet.hiro.so",o="https://api.testnet.hiro.so",s="http://localhost:3999",i="https://hub.blockstack.org",a=33,c=32},889:(e,t,r)=>{r.d(t,{AI:()=>I,AY:()=>y,Ev:()=>u,Fe:()=>E,Ie:()=>b,JU:()=>m,M4:()=>h,O1:()=>n,Ru:()=>R,Y0:()=>f,hy:()=>a,jO:()=>s,kn:()=>c,oO:()=>p,p8:()=>_,sk:()=>o,ur:()=>T,v0:()=>i,vP:()=>d,xE:()=>l,zd:()=>g});const n={MISSING_PARAMETER:"missing_parameter",REMOTE_SERVICE_ERROR:"remote_service_error",INVALID_STATE:"invalid_state",NO_SESSION_DATA:"no_session_data",DOES_NOT_EXIST:"does_not_exist",FAILED_DECRYPTION_ERROR:"failed_decryption_error",INVALID_DID_ERROR:"invalid_did_error",NOT_ENOUGH_FUNDS_ERROR:"not_enough_error",INVALID_AMOUNT_ERROR:"invalid_amount_error",LOGIN_FAILED_ERROR:"login_failed",SIGNATURE_VERIFICATION_ERROR:"signature_verification_failure",CONFLICT_ERROR:"conflict_error",NOT_ENOUGH_PROOF_ERROR:"not_enough_proof_error",BAD_PATH_ERROR:"bad_path_error",VALIDATION_ERROR:"validation_error",PAYLOAD_TOO_LARGE_ERROR:"payload_too_large_error",PRECONDITION_FAILED_ERROR:"precondition_failed_error",UNKNOWN:"unknown"};Object.freeze(n);class o extends Error{constructor(e){super();let t=e.message,r=`Error Code: ${e.code}`,n=this.stack;if(n)r+=`Stack Trace:\n${n}`;else try{throw new Error}catch(e){n=e.stack}t+=`\nIf you believe this exception is caused by a bug in stacks.js,\n please file a bug report: https://github.com/blockstack/stacks.js/issues\n\n${r}`,this.message=t,this.code=e.code,this.parameter=e.parameter?e.parameter:void 0}toString(){return`${super.toString()}\n code: ${this.code} param: ${this.parameter?this.parameter:"n/a"}`}}class s extends o{constructor(e,t=""){super({code:n.MISSING_PARAMETER,message:t,parameter:e}),this.name="MissingParametersError"}}class i extends o{constructor(e,t=""){super({code:n.MISSING_PARAMETER,message:t,parameter:e}),this.name="MissingParametersError"}}class a extends o{constructor(e,t=""){super({code:n.REMOTE_SERVICE_ERROR,message:t}),this.response=e}}class c extends o{constructor(e=""){super({code:n.INVALID_DID_ERROR,message:e}),this.name="InvalidDIDError"}}class u extends o{constructor(e){const t=`Not enough UTXOs to fund. Left to fund: ${e}`;super({code:n.NOT_ENOUGH_FUNDS_ERROR,message:t}),this.leftToFund=e,this.name="NotEnoughFundsError",this.message=t}}class l extends o{constructor(e,t){const r=`Not enough coin to fund fees transaction fees. Fees would be ${e}, specified spend is ${t}`;super({code:n.INVALID_AMOUNT_ERROR,message:r}),this.specifiedAmount=t,this.fees=e,this.name="InvalidAmountError",this.message=r}}class g extends o{constructor(e){const t=`Failed to login: ${e}`;super({code:n.LOGIN_FAILED_ERROR,message:t}),this.message=t,this.name="LoginFailedError"}}class f extends o{constructor(e){const t=`Failed to verify signature: ${e}`;super({code:n.SIGNATURE_VERIFICATION_ERROR,message:t}),this.message=t,this.name="SignatureVerificationError"}}class d extends o{constructor(e="Unable to decrypt cipher object."){super({code:n.FAILED_DECRYPTION_ERROR,message:e}),this.message=e,this.name="FailedDecryptionError"}}class h extends o{constructor(e){super({code:n.INVALID_STATE,message:e}),this.message=e,this.name="InvalidStateError"}}class E extends o{constructor(e){super({code:n.INVALID_STATE,message:e}),this.message=e,this.name="NoSessionDataError"}}class p extends o{constructor(e,t){super(e),t&&(this.hubError={statusCode:t.status,statusText:t.statusText},"string"==typeof t.body?this.hubError.message=t.body:"object"==typeof t.body&&Object.assign(this.hubError,t.body))}}class I extends p{constructor(e,t){super({message:e,code:n.DOES_NOT_EXIST},t),this.name="DoesNotExist"}}class y extends p{constructor(e,t){super({message:e,code:n.CONFLICT_ERROR},t),this.name="ConflictError"}}class m extends p{constructor(e,t){super({message:e,code:n.NOT_ENOUGH_PROOF_ERROR},t),this.name="NotEnoughProofError"}}class R extends p{constructor(e,t){super({message:e,code:n.BAD_PATH_ERROR},t),this.name="BadPathError"}}class _ extends p{constructor(e,t){super({message:e,code:n.VALIDATION_ERROR},t),this.name="ValidationError"}}class b extends p{constructor(e,t,r){super({message:e,code:n.PAYLOAD_TOO_LARGE_ERROR},t),this.name="PayloadTooLargeError",this.maxUploadByteSize=r}}class T extends p{constructor(e,t){super({message:e,code:n.PRECONDITION_FAILED_ERROR},t),this.name="PreconditionFailedError"}}},436:(e,t,r)=>{r.d(t,{O6:()=>l,eA:()=>E,h$:()=>d,hM:()=>f,i$:()=>g,jX:()=>h});var n=Object.defineProperty,o=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,a=(e,t,r)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,c=(e,t)=>{for(var r in t||(t={}))s.call(t,r)&&a(e,r,t[r]);if(o)for(var r of o(t))i.call(t,r)&&a(e,r,t[r]);return e};const u={referrerPolicy:"origin",headers:{"x-hiro-product":"stacksjs"}},l=()=>u,g=e=>Object.assign(u,e);async function f(e,t){const r={};return Object.assign(r,u,t),await fetch(e,r)}function d(e,t){return"string"==typeof t?t===e:t.exec(e)}function h({apiKey:e,host:t=/(.*)api(.*)(\.stacks\.co|\.hiro\.so)$/i,httpHeader:r="x-api-key"}){return{pre:n=>{d(new URL(n.url).host,t)&&(n.init.headers instanceof Headers?n.init.headers:n.init.headers=new Headers(n.init.headers)).set(r,e)}}}function E(...e){const{fetchLib:t,middlewares:r}=function(e){let t=f,r=[];return e.length>0&&"function"==typeof e[0]&&(t=e.shift()),e.length>0&&(r=e),{fetchLib:t,middlewares:r}}(e);return async(e,n)=>{var o;let s={url:e,init:null!=n?n:{}};for(const e of r)if("function"==typeof e.pre){const r=await Promise.resolve(e.pre(c({fetch:t},s)));s=null!=r?r:s}let i=await t(s.url,s.init);for(const e of r)if("function"==typeof e.post){const r=await Promise.resolve(e.post({fetch:t,url:s.url,init:s.init,response:null!=(o=null==i?void 0:i.clone())?o:i}));i=null!=r?r:i}return i}}},631:(e,t,r)=>{r.d(t,{z:()=>o});var n=r(788);function o(e){const t="string"==typeof e?(0,n.nr)(e):e;if(32!=t.length&&33!=t.length)throw new Error(`Improperly formatted private-key. Private-key byte length should be 32 or 33. Length provided: ${t.length}`);if(33==t.length&&1!==t[32])throw new Error("Improperly formatted private-key. 33 bytes indicate compressed key, but the last byte must be == 01");return t}},976:(e,t,r)=>{r.d(t,{Y:()=>a});var n=r(392);const o=["debug","info","warn","error","none"],s={},i={};for(let e=0;e<o.length;e++){const t=o[e];s[t]=e,i[e]=t}class a{static error(e){this.shouldLog("error")&&console.error(this.logMessage("error",e))}static warn(e){this.shouldLog("warn")&&console.warn(this.logMessage("warn",e))}static info(e){this.shouldLog("info")&&console.log(this.logMessage("info",e))}static debug(e){this.shouldLog("debug")&&console.log(this.logMessage("debug",e))}static logMessage(e,t){return`[${e.toUpperCase()}] ${t}`}static shouldLog(e){return s[n.v.logLevel]<=s[e]}}},225:(e,t,r)=>{r.d(t,{U8:()=>a,ph:()=>i,xP:()=>s});var n=r(788);const o=32;function s(e){if(e.length<2*o*2+1)throw new Error("Invalid signature");const t=e.slice(0,2),r=e.slice(2,2+2*o),s=e.slice(2+2*o);return{recoveryId:(0,n.WR)(t),r,s}}function i(e){return e.slice(2)+e.slice(0,2)}function a(e){return e.slice(-2)+e.slice(0,-2)}},59:()=>{},788:(e,t,r)=>{r.d(t,{$O:()=>k,$g:()=>_,$j:()=>A,A5:()=>y,GW:()=>g,HN:()=>R,I4:()=>O,Md:()=>B,NA:()=>F,NJ:()=>s,QD:()=>P,Qs:()=>$,Rf:()=>I,T7:()=>V,WR:()=>w,WT:()=>u,WW:()=>C,Xt:()=>c,_Y:()=>N,at:()=>b,cG:()=>a,ci:()=>L,cn:()=>v,eV:()=>j,gS:()=>d,iY:()=>D,jk:()=>x,ko:()=>h,lW:()=>E,nD:()=>i,nr:()=>U,ru:()=>l,sO:()=>m,se:()=>f,y_:()=>T,ym:()=>o});var n=r(976);const o="blockstack";function s(){return new Date((new Date).setFullYear((new Date).getFullYear()+1))}function i(){return new Date((new Date).setMonth((new Date).getMonth()+1))}function a(){return new Date((new Date).setHours((new Date).getHours()+1))}function c(e){return Number.isFinite(e)?Math.floor(1024*e*1024):0}function u(e){return 16*(Math.floor(e/16)+1)}function l(e){return 4*Math.ceil(e/3)}function g(e,t,r){const n=new RegExp(`([?&])${t}=.*?(&|$)`,"i"),o=-1!==e.indexOf("?")?"&":"?";return e.match(n)?e.replace(n,`$1${t}=${r}$2`):`${e}${o}${t}=${r}`}function f(e,t){void 0!==e&&""!==e||(e="0.0.0"),void 0!==t&&""!==e||(t="0.0.0");const r=e.split(".").map((e=>parseInt(e,10))),n=t.split(".").map((e=>parseInt(e,10)));for(let o=0;o<t.length;o++)if(o>=e.length&&n.push(0),r[o]<n[o])return!1;return!0}function d(){let e=(new Date).getTime();return"undefined"!=typeof performance&&"function"==typeof performance.now&&(e+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?r:3&r|8).toString(16)}))}function h(e,t){try{const r=new URL(e),n=new URL(t),o=0|parseInt(r.port||"0",10)||("https:"===r.protocol?443:80),s=0|parseInt(n.port||"0",10)||("https:"===n.protocol?443:80),i={scheme:r.protocol===n.protocol,hostname:r.hostname===n.hostname,port:o===s,absolute:(e.includes("http://")||e.includes("https://"))&&(t.includes("http://")||t.includes("https://"))};return i.scheme&&i.hostname&&i.port&&i.absolute}catch(e){return console.log(e),console.log("Parsing error in same URL origin check"),!1}}function E(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r.g)return r.g;throw new Error("Unexpected runtime environment - no supported global scope (`window`, `self`, `global`) available")}function p(e,t,r){return r?`Use of '${r}' requires \`${t}\` which is unavailable on the '${e}' object within the currently executing environment.`:`\`${t}\` is unavailable on the '${e}' object within the currently executing environment.`}function I(e,{throwIfUnavailable:t,usageDesc:r,returnEmptyObject:o}={}){let s;try{if(s=E(),s){const t=s[e];if(t)return t}}catch(t){n.Y.error(`Error getting object '${e}' from global scope '${s}': ${t}`)}if(t){const t=p(s,e.toString(),r);throw n.Y.error(t),new Error(t)}if(o)return{}}function y(e,{throwIfUnavailable:t,usageDesc:r,returnEmptyObject:o}={}){let s;try{s=E()}catch(i){if(n.Y.error(`Error getting global scope: ${i}`),t){const t=p(s,e[0].toString(),r);throw n.Y.error(t),t}o&&(s={})}const i={};for(let a=0;a<e.length;a++){const c=e[a];try{if(s){const e=s[c];if(e)i[c]=e;else{if(t){const e=p(s,c.toString(),r);throw n.Y.error(e),new Error(e)}o&&(i[c]={})}}}catch(e){if(t){const e=p(s,c.toString(),r);throw n.Y.error(e),new Error(e)}}}return i}function m(e,t){return x(R(e),t)}function R(e){if("bigint"==typeof e)return e;if("string"==typeof e)return BigInt(e);if("number"==typeof e){if(!Number.isInteger(e))throw new RangeError("Invalid value. Values of type 'number' must be an integer.");if(e>Number.MAX_SAFE_INTEGER)throw new RangeError(`Invalid value. Values of type 'number' must be less than or equal to ${Number.MAX_SAFE_INTEGER}. For larger values, try using a BigInt instead.`);return BigInt(e)}if(k(e,Uint8Array))return BigInt(`0x${L(e)}`);throw new TypeError("intToBigInt: Invalid value type. Must be a number, bigint, BigInt-compatible string, or Uint8Array.")}function _(e){return/^0x/i.test(e)?e:`0x${e}`}function b(e){return/^0x/i.test(e)?e.slice(2):e}function T(e){if("string"!=typeof e)throw new TypeError("hexToBigInt: expected string, got "+typeof e);return BigInt(`0x${e}`)}function O(e,t=8){return("bigint"==typeof e?e:R(e)).toString(16).padStart(2*t,"0")}function w(e){return parseInt(e,16)}function x(e,t=16){return U(O(e,t))}function A(e,t){if(e<-(BigInt(1)<<t-BigInt(1))||(BigInt(1)<<t-BigInt(1))-BigInt(1)<e)throw`Unable to represent integer in width: ${t}`;return e>=BigInt(0)?BigInt(e):e+(BigInt(1)<<t)}function v(e){return N(BigInt(`0x${L(e)}`),BigInt(8*e.byteLength))}function N(e,t){return function(e,t){return e&BigInt(1)<<t}(e,t-BigInt(1))?e-(BigInt(1)<<t):e}const S=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function L(e){if(!(e instanceof Uint8Array))throw new Error("Uint8Array expected");let t="";for(const r of e)t+=S[r];return t}function U(e){if("string"!=typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);e=(e=b(e)).length%2?`0${e}`:e;const t=new Uint8Array(e.length/2);for(let r=0;r<t.length;r++){const n=2*r,o=e.slice(n,n+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");t[r]=s}return t}function D(e){return(new TextEncoder).encode(e)}function B(e){return(new TextDecoder).decode(e)}function P(e){const t=[];for(let r=0;r<e.length;r++)t.push(255&e.charCodeAt(r));return new Uint8Array(t)}function $(e){return String.fromCharCode.apply(null,e)}function M(e){return!Number.isInteger(e)||e<0||e>255}function F(e){if(e.some(M))throw new Error("Some values are invalid bytes.");return new Uint8Array(e)}function j(...e){if(!e.every((e=>e instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===e.length)return e[0];const t=e.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return r}function C(e){return j(...e.map((e=>"number"==typeof e?F([e]):e instanceof Array?F(e):e)))}function k(e,t){var r,n;return e instanceof t||(null==(n=null==(r=null==e?void 0:e.constructor)?void 0:r.name)?void 0:n.toLowerCase())===t.name}function V(e){return 64===(e=b(e)).length&&/^[0-9a-fA-F]+$/.test(e)}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{r.r(n),r.d(n,{BLOCKSTACK_HANDLER:()=>s.ym,BadPathError:()=>t.Ru,BlockstackError:()=>t.sk,ConflictError:()=>t.AY,DEVNET_URL:()=>i.it,DoesNotExist:()=>t.AI,ERROR_CODES:()=>t.O1,FailedDecryptionError:()=>t.vP,GAIA_URL:()=>i.lW,GaiaHubError:()=>t.oO,HIRO_MAINNET_URL:()=>i.fg,HIRO_TESTNET_URL:()=>i.IE,InvalidAmountError:()=>t.xE,InvalidDIDError:()=>t.kn,InvalidParameterError:()=>t.jO,InvalidStateError:()=>t.M4,Logger:()=>o.Y,LoginFailedError:()=>t.zd,MissingParameterError:()=>t.v0,NoSessionDataError:()=>t.Fe,NotEnoughFundsError:()=>t.Ev,NotEnoughProofError:()=>t.JU,PRIVATE_KEY_BYTES_COMPRESSED:()=>i.sQ,PRIVATE_KEY_BYTES_UNCOMPRESSED:()=>i.Mh,PayloadTooLargeError:()=>t.Ie,PreconditionFailedError:()=>t.ur,RemoteServiceError:()=>t.hy,SignatureVerificationError:()=>t.Y0,ValidationError:()=>t.p8,alloc:()=>u.un,asciiToBytes:()=>s.QD,bigIntToBytes:()=>s.jk,bytesToAscii:()=>s.Qs,bytesToHex:()=>s.ci,bytesToTwosBigInt:()=>s.cn,bytesToUtf8:()=>s.Md,concatArray:()=>s.WW,concatBytes:()=>s.eV,config:()=>e.v,createApiKeyMiddleware:()=>f.jX,createFetchFn:()=>f.eA,equals:()=>u.fS,fetchWrapper:()=>f.hM,fromTwos:()=>s._Y,getAesCbcOutputLength:()=>s.WT,getBase64OutputLength:()=>s.ru,getFetchOptions:()=>f.O6,getGlobalObject:()=>s.Rf,getGlobalObjects:()=>s.A5,getGlobalScope:()=>s.lW,hexToBigInt:()=>s.y_,hexToBytes:()=>s.nr,hexToInt:()=>s.WR,hostMatches:()=>f.h$,intToBigInt:()=>s.HN,intToBytes:()=>s.sO,intToHex:()=>s.I4,isInstance:()=>s.$O,isLaterVersion:()=>s.se,isSameOriginAbsoluteUrl:()=>s.ko,makeUUID4:()=>s.gS,megabytesToBytes:()=>s.Xt,nextHour:()=>s.cG,nextMonth:()=>s.nD,nextYear:()=>s.NJ,octetsToBytes:()=>s.NA,parseRecoverableSignatureVrs:()=>a.xP,privateKeyToBytes:()=>c.z,readUInt16BE:()=>u.n8,readUInt16LE:()=>u.mP,readUInt32BE:()=>u.Ag,readUInt32LE:()=>u.nm,readUInt8:()=>u.Q$,setFetchOptions:()=>f.i$,signatureRsvToVrs:()=>a.U8,signatureVrsToRsv:()=>a.ph,toTwos:()=>s.$j,updateQueryStringParameter:()=>s.GW,utf8ToBytes:()=>s.iY,validateHash256:()=>s.T7,with0x:()=>s.$g,without0x:()=>s.at,writeUInt16BE:()=>u.cQ,writeUInt16LE:()=>u.oq,writeUInt32BE:()=>u.T4,writeUInt32LE:()=>u.v7,writeUInt8:()=>u.Cg});var e=r(392),t=r(889),o=r(976),s=r(788),i=r(902),a=r(225),c=r(631),u=r(142),l=r(59),g={};for(const e in l)["default","config","BadPathError","BlockstackError","ConflictError","DoesNotExist","ERROR_CODES","FailedDecryptionError","GaiaHubError","InvalidAmountError","InvalidDIDError","InvalidParameterError","InvalidStateError","LoginFailedError","MissingParameterError","NoSessionDataError","NotEnoughFundsError","NotEnoughProofError","PayloadTooLargeError","PreconditionFailedError","RemoteServiceError","SignatureVerificationError","ValidationError","Logger","BLOCKSTACK_HANDLER","asciiToBytes","bigIntToBytes","bytesToAscii","bytesToHex","bytesToTwosBigInt","bytesToUtf8","concatArray","concatBytes","fromTwos","getAesCbcOutputLength","getBase64OutputLength","getGlobalObject","getGlobalObjects","getGlobalScope","hexToBigInt","hexToBytes","hexToInt","intToBigInt","intToBytes","intToHex","isInstance","isLaterVersion","isSameOriginAbsoluteUrl","makeUUID4","megabytesToBytes","nextHour","nextMonth","nextYear","octetsToBytes","toTwos","updateQueryStringParameter","utf8ToBytes","validateHash256","with0x","without0x","DEVNET_URL","GAIA_URL","HIRO_MAINNET_URL","HIRO_TESTNET_URL","PRIVATE_KEY_BYTES_COMPRESSED","PRIVATE_KEY_BYTES_UNCOMPRESSED","parseRecoverableSignatureVrs","signatureRsvToVrs","signatureVrsToRsv","privateKeyToBytes","alloc","equals","readUInt16BE","readUInt16LE","readUInt32BE","readUInt32LE","readUInt8","writeUInt16BE","writeUInt16LE","writeUInt32BE","writeUInt32LE","writeUInt8"].indexOf(e)<0&&(g[e]=()=>l[e]);r.d(n,g);var f=r(436)})(),n})()));
//# sourceMappingURL=index.js.map

@@ -26,3 +26,3 @@ export declare const BLOCKSTACK_HANDLER = "blockstack";

export declare function hexToBigInt(hex: string): bigint;
export declare function intToHex(integer: IntegerType, lengthBytes?: number): string;
export declare function intToHex(integer: IntegerType, byteLength?: number): string;
export declare function hexToInt(hex: string): number;

@@ -29,0 +29,0 @@ export declare function bigIntToBytes(value: bigint, length?: number): Uint8Array;

@@ -233,5 +233,5 @@ "use strict";

exports.hexToBigInt = hexToBigInt;
function intToHex(integer, lengthBytes = 8) {
function intToHex(integer, byteLength = 8) {
const value = typeof integer === 'bigint' ? integer : intToBigInt(integer);
return value.toString(16).padStart(lengthBytes * 2, '0');
return value.toString(16).padStart(byteLength * 2, '0');
}

@@ -238,0 +238,0 @@ exports.intToHex = intToHex;

{
"name": "@stacks/common",
"version": "7.0.0-next.70+0adf46c4",
"version": "7.0.0-next.89+3d4052b2",
"description": "Common Stacks utilities",

@@ -47,3 +47,3 @@ "license": "MIT",

},
"gitHead": "0adf46c4eadac85f234140dc2df0e5d06b0ca775"
"gitHead": "3d4052b21c76cd8f28ae64a266d61b650386a726"
}

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

// Define a default request options and allow modification using getters, setters
import { HIRO_MAINNET_URL } from './constants';
// Define default request options and allow modification using getters, setters
// Reference: https://developer.mozilla.org/en-US/docs/Web/API/Request/Request

@@ -58,12 +55,12 @@ const defaultFetchOpts: RequestInit = {

*/
export type ClientOpts = {
export interface ClientOpts {
baseUrl?: string;
fetch?: FetchFn;
};
}
/** @ignore Internally used for letting networking functions specify "API" options */
export type ClientParam = {
/** Optional API object (for `.url` and `.fetch`) used for API/Node, defaults to use mainnet */
export interface ClientParam {
/** Optional API object (for `.baseUrl` and `.fetch`) used for API/Node, defaults to use mainnet */
client?: ClientOpts;
};
}

@@ -199,9 +196,8 @@ export interface RequestContext {

/** @ignore Creates a client-like object, which can be used without circular dependencies */
export function defaultClientOpts(opts?: { baseUrl?: string; fetch?: FetchFn }) {
return {
// todo: do we want network here as well?
baseUrl: opts?.baseUrl ?? HIRO_MAINNET_URL,
fetch: opts?.fetch ?? createFetchFn(),
};
}
// /** @ignore Creates a client-like object, which can be used without circular dependencies */
// export function defaultClientOpts(opts?: { baseUrl?: string; fetch?: FetchFn }) {
// return {
// baseUrl: opts?.baseUrl ?? HIRO_MAINNET_URL,
// fetch: opts?.fetch ?? createFetchFn(),
// };
// }

@@ -16,2 +16,3 @@ import { config } from './config';

* @ignore
* @deprecated
*/

@@ -18,0 +19,0 @@ export class Logger {

@@ -5,2 +5,3 @@ import { Logger } from './logger';

* @ignore
* @deprecated
*/

@@ -14,2 +15,3 @@ export const BLOCKSTACK_HANDLER = 'blockstack';

* @ignore
* @deprecated
*/

@@ -24,2 +26,3 @@ export function nextYear() {

* @ignore
* @deprecated
*/

@@ -34,2 +37,3 @@ export function nextMonth() {

* @ignore
* @deprecated
*/

@@ -43,2 +47,3 @@ export function nextHour() {

* @ignore
* @deprecated
*/

@@ -56,2 +61,3 @@ export function megabytesToBytes(megabytes: number): number {

* @ignore
* @deprecated
*/

@@ -69,2 +75,3 @@ export function getAesCbcOutputLength(inputByteLength: number) {

* @param number
* @deprecated
*/

@@ -80,4 +87,4 @@ export function getBase64OutputLength(inputByteLength: number) {

* @ignore
* @deprecated
*/
export function updateQueryStringParameter(uri: string, key: string, value: string) {

@@ -100,4 +107,4 @@ const re = new RegExp(`([?&])${key}=.*?(&|$)`, 'i');

* @ignore
* @deprecated
*/
export function isLaterVersion(v1: string, v2: string) {

@@ -130,2 +137,3 @@ if (v1 === undefined || v1 === '') {

* @ignore
* @deprecated
*/

@@ -151,2 +159,3 @@ export function makeUUID4() {

* @ignore
* @deprecated
*/

@@ -211,2 +220,3 @@ export function isSameOriginAbsoluteUrl(uri1: string, uri2: string) {

/** @deprecated */
function getAPIUsageErrorMessage(

@@ -330,4 +340,14 @@ scopeObject: unknown,

/** Different Integer representations */
export type IntegerType = number | string | bigint | Uint8Array;
/**
* Converts an integer-compatible value to a Uint8Array (given a byte length)
* @example
* ```ts
* import { intToBytes } from "@stacks/common";
* console.log(intToBytes(560, 4));
* // Uint8Array(4) [ 0, 0, 2, 48 ]
* ```
*/
export function intToBytes(value: IntegerType, byteLength: number): Uint8Array {

@@ -403,7 +423,6 @@ return bigIntToBytes(intToBigInt(value), byteLength);

* Converts IntegerType to hex string
* @ignore
*/
export function intToHex(integer: IntegerType, lengthBytes = 8): string {
export function intToHex(integer: IntegerType, byteLength = 8): string {
const value = typeof integer === 'bigint' ? integer : intToBigInt(integer);
return value.toString(16).padStart(lengthBytes * 2, '0');
return value.toString(16).padStart(byteLength * 2, '0');
}

@@ -413,3 +432,2 @@

* Converts hex string to integer
* @ignore
*/

@@ -416,0 +434,0 @@ export function hexToInt(hex: string): number {

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

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