@stacks/common
Advanced tools
Comparing version 7.0.3-pr.2 to 7.0.3-pr.4
@@ -0,1 +1,2 @@ | ||
import { isInstance } from './utils'; | ||
const defaultFetchOpts = { | ||
@@ -27,4 +28,8 @@ referrerPolicy: 'origin', | ||
pre: context => { | ||
const reqUrl = new URL(context.url); | ||
if (!hostMatches(reqUrl.host, host)) | ||
const url = isInstance(context.input, URL) | ||
? context.input | ||
: typeof context.input === 'string' | ||
? new URL(context.input) | ||
: new URL(context.input.url); | ||
if (!hostMatches(url.host, host)) | ||
return; | ||
@@ -31,0 +36,0 @@ const headers = context.init.headers instanceof Headers |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createFetchFn = exports.createApiKeyMiddleware = exports.hostMatches = exports.fetchWrapper = exports.setFetchOptions = exports.getFetchOptions = void 0; | ||
const utils_1 = require("./utils"); | ||
const defaultFetchOpts = { | ||
@@ -34,4 +35,8 @@ referrerPolicy: 'origin', | ||
pre: context => { | ||
const reqUrl = new URL(context.url); | ||
if (!hostMatches(reqUrl.host, host)) | ||
const url = (0, utils_1.isInstance)(context.input, URL) | ||
? context.input | ||
: typeof context.input === 'string' | ||
? new URL(context.input) | ||
: new URL(context.input.url); | ||
if (!hostMatches(url.host, host)) | ||
return; | ||
@@ -38,0 +43,0 @@ const headers = context.init.headers instanceof Headers |
@@ -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 d(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 f(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:()=>d,cQ:()=>i,fS:()=>n,mP:()=>u,n8:()=>s,nm:()=>f,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:()=>m,Ev:()=>u,Fe:()=>E,Ie:()=>T,JU:()=>R,M4:()=>h,O1:()=>n,Ru:()=>y,Y0:()=>d,hy:()=>a,jO:()=>s,kn:()=>c,oO:()=>p,p8:()=>_,sk:()=>o,ur:()=>b,v0:()=>i,vP:()=>f,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 d 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 f 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 m extends p{constructor(e,t){super({message:e,code:n.CONFLICT_ERROR},t),this.name="ConflictError"}}class R extends p{constructor(e,t){super({message:e,code:n.NOT_ENOUGH_PROOF_ERROR},t),this.name="NotEnoughProofError"}}class y 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 T extends p{constructor(e,t,r){super({message:e,code:n.PAYLOAD_TOO_LARGE_ERROR},t),this.name="PayloadTooLargeError",this.maxUploadByteSize=r}}class b 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:()=>o,eA:()=>u,h$:()=>a,hM:()=>i,i$:()=>s,jX:()=>c});const n={referrerPolicy:"origin",headers:{"x-hiro-product":"stacksjs"}},o=()=>n,s=e=>Object.assign(n,e);async function i(e,t){const r={};return Object.assign(r,n,t),await fetch(e,r)}function a(e,t){return"string"==typeof t?t===e:t.exec(e)}function c({apiKey:e,host:t=/(.*)api(.*)(\.stacks\.co|\.hiro\.so)$/i,httpHeader:r="x-api-key"}){return{pre:n=>{a(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 u(...e){const{fetch:t,middlewares:r}=function(e){return"function"==typeof e[0]?{fetch:e.shift(),middlewares:e}:{fetch:i,middlewares:e}}(e);return async(e,n)=>{var o,s,i;let a={input:e,init:null!=n?n:{}};for(const e of r)if("function"==typeof e.pre){const r=await Promise.resolve(e.pre({fetch:t,url:a.input,input:a.input,init:null!=(o=a.init)?o:{}}));r&&"url"in r&&(r.input=r.url),a=null!=r?r:a}let c=await t(a.input,a.init);for(const e of r)if("function"==typeof e.post){const r=await Promise.resolve(e.post({fetch:t,url:a.input,input:a.input,init:null!=(s=a.init)?s:{},response:null!=(i=null==c?void 0:c.clone())?i:c}));c=null!=r?r:c}return c}}},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:()=>V,$g:()=>_,$j:()=>A,A5:()=>m,GW:()=>g,HN:()=>y,I4:()=>O,Md:()=>B,NA:()=>F,NJ:()=>s,QD:()=>P,Qs:()=>$,Rf:()=>I,T7:()=>j,WR:()=>w,WT:()=>u,WW:()=>k,Xt:()=>c,_Y:()=>N,at:()=>T,cG:()=>a,ci:()=>U,cn:()=>v,eV:()=>C,gS:()=>f,iY:()=>L,jk:()=>x,ko:()=>h,lW:()=>E,nD:()=>i,nr:()=>D,ru:()=>l,sO:()=>R,se:()=>d,y_:()=>b,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 d(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 f(){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 m(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 R(e,t){return x(y(e),t)}function y(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(V(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 T(e){return/^0x/i.test(e)?e.slice(2):e}function b(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:y(e)).toString(16).padStart(2*t,"0")}function w(e){return parseInt(e,16)}function x(e,t=16){return D(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${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 D(e){if("string"!=typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);e=(e=T(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 L(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 C(...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 k(e){return C(...e.map((e=>"number"==typeof e?F([e]):e instanceof Array?F(e):e)))}function V(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 j(e){return 64===(e=T(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:()=>d.jX,createFetchFn:()=>d.eA,equals:()=>u.fS,fetchWrapper:()=>d.hM,fromTwos:()=>s._Y,getAesCbcOutputLength:()=>s.WT,getBase64OutputLength:()=>s.ru,getFetchOptions:()=>d.O6,getGlobalObject:()=>s.Rf,getGlobalObjects:()=>s.A5,getGlobalScope:()=>s.lW,hexToBigInt:()=>s.y_,hexToBytes:()=>s.nr,hexToInt:()=>s.WR,hostMatches:()=>d.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:()=>d.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 d=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 d(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 f(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:()=>d,cQ:()=>i,fS:()=>n,mP:()=>u,n8:()=>s,nm:()=>f,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:()=>m,Ev:()=>u,Fe:()=>E,Ie:()=>T,JU:()=>R,M4:()=>h,O1:()=>n,Ru:()=>y,Y0:()=>d,hy:()=>a,jO:()=>s,kn:()=>c,oO:()=>p,p8:()=>_,sk:()=>o,ur:()=>b,v0:()=>i,vP:()=>f,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 d 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 f 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 m extends p{constructor(e,t){super({message:e,code:n.CONFLICT_ERROR},t),this.name="ConflictError"}}class R extends p{constructor(e,t){super({message:e,code:n.NOT_ENOUGH_PROOF_ERROR},t),this.name="NotEnoughProofError"}}class y 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 T extends p{constructor(e,t,r){super({message:e,code:n.PAYLOAD_TOO_LARGE_ERROR},t),this.name="PayloadTooLargeError",this.maxUploadByteSize=r}}class b 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:()=>s,eA:()=>l,h$:()=>c,hM:()=>a,i$:()=>i,jX:()=>u});var n=r(788);const o={referrerPolicy:"origin",headers:{"x-hiro-product":"stacksjs"}},s=()=>o,i=e=>Object.assign(o,e);async function a(e,t){const r={};return Object.assign(r,o,t),await fetch(e,r)}function c(e,t){return"string"==typeof t?t===e:t.exec(e)}function u({apiKey:e,host:t=/(.*)api(.*)(\.stacks\.co|\.hiro\.so)$/i,httpHeader:r="x-api-key"}){return{pre:o=>{c(((0,n.$O)(o.input,URL)?o.input:"string"==typeof o.input?new URL(o.input):new URL(o.input.url)).host,t)&&(o.init.headers instanceof Headers?o.init.headers:o.init.headers=new Headers(o.init.headers)).set(r,e)}}}function l(...e){const{fetch:t,middlewares:r}=function(e){return"function"==typeof e[0]?{fetch:e.shift(),middlewares:e}:{fetch:a,middlewares:e}}(e);return async(e,n)=>{var o,s,i;let a={input:e,init:null!=n?n:{}};for(const e of r)if("function"==typeof e.pre){const r=await Promise.resolve(e.pre({fetch:t,url:a.input,input:a.input,init:null!=(o=a.init)?o:{}}));r&&"url"in r&&(r.input=r.url),a=null!=r?r:a}let c=await t(a.input,a.init);for(const e of r)if("function"==typeof e.post){const r=await Promise.resolve(e.post({fetch:t,url:a.input,input:a.input,init:null!=(s=a.init)?s:{},response:null!=(i=null==c?void 0:c.clone())?i:c}));c=null!=r?r:c}return c}}},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:()=>V,$g:()=>_,$j:()=>A,A5:()=>m,GW:()=>g,HN:()=>y,I4:()=>O,Md:()=>B,NA:()=>F,NJ:()=>s,QD:()=>P,Qs:()=>$,Rf:()=>I,T7:()=>j,WR:()=>w,WT:()=>u,WW:()=>k,Xt:()=>c,_Y:()=>N,at:()=>T,cG:()=>a,ci:()=>U,cn:()=>v,eV:()=>C,gS:()=>f,iY:()=>D,jk:()=>x,ko:()=>h,lW:()=>E,nD:()=>i,nr:()=>L,ru:()=>l,sO:()=>R,se:()=>d,y_:()=>b,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 d(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 f(){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 m(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 R(e,t){return x(y(e),t)}function y(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(V(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 T(e){return/^0x/i.test(e)?e.slice(2):e}function b(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:y(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 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${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=T(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 C(...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 k(e){return C(...e.map((e=>"number"==typeof e?F([e]):e instanceof Array?F(e):e)))}function V(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 j(e){return 64===(e=T(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:()=>d.jX,createFetchFn:()=>d.eA,equals:()=>u.fS,fetchWrapper:()=>d.hM,fromTwos:()=>s._Y,getAesCbcOutputLength:()=>s.WT,getBase64OutputLength:()=>s.ru,getFetchOptions:()=>d.O6,getGlobalObject:()=>s.Rf,getGlobalObjects:()=>s.A5,getGlobalScope:()=>s.lW,hexToBigInt:()=>s.y_,hexToBytes:()=>s.nr,hexToInt:()=>s.WR,hostMatches:()=>d.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:()=>d.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 d=r(436)})(),n})())); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@stacks/common", | ||
"version": "7.0.3-pr.2+edbd2947", | ||
"version": "7.0.3-pr.4+64a49b58", | ||
"description": "Common Stacks utilities", | ||
@@ -47,3 +47,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "edbd29473c18075d3d9dcd0b2a1967ebadcefbc2" | ||
"gitHead": "64a49b589b2542db8e4ed79848a93cbffc8ba13d" | ||
} |
@@ -0,2 +1,5 @@ | ||
import { isInstance } from './utils'; | ||
// Define default request options and allow modification using getters, setters | ||
// Reference: https://developer.mozilla.org/en-US/docs/Web/API/Request/Request | ||
@@ -141,5 +144,10 @@ const defaultFetchOpts: RequestInit = { | ||
pre: context => { | ||
const reqUrl = new URL(context.url); | ||
if (!hostMatches(reqUrl.host, host)) return; // Skip middleware if host does not match pattern | ||
const url = isInstance(context.input, URL) | ||
? context.input | ||
: typeof context.input === 'string' | ||
? new URL(context.input) | ||
: new URL(context.input.url); | ||
if (!hostMatches(url.host, host)) return; // Skip middleware if host does not match pattern | ||
const headers = | ||
@@ -146,0 +154,0 @@ context.init.headers instanceof Headers |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
267494
3521