@stacks/common 7.4.0-beta.0 → 7.4.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/umd/index.js CHANGED
@@ -1,2 +1,1197 @@
1
- !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={146:(e,t,r)=>{r.d(t,{ER:()=>a,Ht:()=>d,IA:()=>l,In:()=>i,Iz:()=>h,N0:()=>c,O3:()=>_,OQ:()=>n,Pp:()=>E,Yj:()=>u,_Q:()=>I,aY:()=>o,dV:()=>s,f6:()=>f,fK:()=>R,k9:()=>T,mN:()=>m,tS:()=>g,uI:()=>p,y7:()=>y,yI:()=>b});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 f 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 g extends o{constructor(e="Unable to decrypt cipher object."){super({code:n.FAILED_DECRYPTION_ERROR,message:e}),this.message=e,this.name="FailedDecryptionError"}}class E extends o{constructor(e){super({code:n.INVALID_STATE,message:e}),this.message=e,this.name="InvalidStateError"}}class h 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 b extends p{constructor(e,t){super({message:e,code:n.VALIDATION_ERROR},t),this.name="ValidationError"}}class _ 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"}}},214:(e,t,r)=>{r.d(t,{NR:()=>s,Wz:()=>i,sC:()=>a});var n=r(568);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.od)(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)}},417:(e,t,r)=>{r.d(t,{x:()=>o});var n=r(568);function o(e){const t="string"==typeof e?(0,n.aT)(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}},487:(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(0|e[t+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 f(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 g(e,t){return(0|e[t+0])>>>0|e[t+1]<<8>>>0|e[t+2]<<16>>>0|e[t+3]<<24>>>0}function E(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,{$l:()=>u,Gs:()=>c,Sw:()=>d,aI:()=>n,bb:()=>f,bc:()=>s,c4:()=>o,gN:()=>l,ml:()=>i,pJ:()=>a,tF:()=>g,ux:()=>E})},561:(e,t,r)=>{r.d(t,{V:()=>a});var n=r(755);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.$.logLevel]<=s[e]}}},568:(e,t,r)=>{r.d(t,{AE:()=>D,AI:()=>B,CZ:()=>x,EL:()=>H,F$:()=>d,Gu:()=>y,Gy:()=>g,H7:()=>o,Hu:()=>F,Id:()=>M,JJ:()=>A,K:()=>f,LF:()=>E,Lw:()=>_,Mh:()=>P,My:()=>L,OR:()=>c,Qs:()=>j,R6:()=>u,ST:()=>S,VI:()=>N,VZ:()=>I,WI:()=>R,aT:()=>U,fz:()=>b,le:()=>s,m5:()=>m,m6:()=>h,od:()=>O,pC:()=>l,qu:()=>V,uU:()=>T,wU:()=>a,wc:()=>i,y6:()=>w,yB:()=>C});var n=r(561);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 f(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 g(){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 E(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 h(){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=h(),s){const t=s[e];if(t)return t}}catch(t){n.V.error(`Error getting object '${e}' from global scope '${s}': ${t}`)}if(t){const t=p(s,e.toString(),r);throw n.V.error(t),new Error(t)}if(o)return{}}function y(e,{throwIfUnavailable:t,usageDesc:r,returnEmptyObject:o}={}){let s;try{s=h()}catch(i){if(n.V.error(`Error getting global scope: ${i}`),t){const t=p(s,e[0].toString(),r);throw n.V.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.V.error(e),new Error(e)}o&&(i[c]={})}}}catch(e){if(t){const e=p(s,c.toString(),r);throw n.V.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(j(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 b(e){return/^0x/i.test(e)?e:`0x${e}`}function _(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 w(e,t=8){return("bigint"==typeof e?e:R(e)).toString(16).padStart(2*t,"0")}function O(e){return parseInt(e,16)}function x(e,t=16){return U(w(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 N(e){return S(BigInt(`0x${L(e)}`),BigInt(8*e.byteLength))}function S(e,t){return function(e,t){return e&BigInt(1)<<t}(e,t-BigInt(1))?e-(BigInt(1)<<t):e}const v=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+=v[r];return t}function U(e){if("string"!=typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);e=(e=_(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 B(e){return(new TextEncoder).encode(e)}function D(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 V(e){return String.fromCharCode.apply(null,e)}function $(e){return!Number.isInteger(e)||e<0||e>255}function F(e){if(e.some($))throw new Error("Some values are invalid bytes.");return new Uint8Array(e)}function M(...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 M(...e.map(e=>"number"==typeof e?F([e]):e instanceof Array?F(e):e))}function j(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 H(e){return 64===(e=_(e)).length&&/^[0-9a-fA-F]+$/.test(e)}},755:(e,t,r)=>{r.d(t,{$:()=>n});const n={network:{layer1:"placeholder"},logLevel:"debug"}},821:(e,t,r)=>{r.d(t,{Hq:()=>h,MW:()=>d,NE:()=>l,_y:()=>g,kO:()=>E,pm:()=>f});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,f=e=>Object.assign(u,e);async function d(e,t){const r={};return Object.assign(r,u,t),await fetch(e,r)}function g(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=>{g(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 h(...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(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}}},832:(e,t,r)=>{r.d(t,{Tj:()=>i,Ze:()=>s,dT:()=>o,o3:()=>n,uc:()=>a,xf:()=>c});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},956:()=>{}},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={};r.r(n),r.d(n,{BLOCKSTACK_HANDLER:()=>a.H7,BadPathError:()=>s.fK,BlockstackError:()=>s.aY,ConflictError:()=>s.y7,DEVNET_URL:()=>c.Ze,DoesNotExist:()=>s._Q,ERROR_CODES:()=>s.OQ,FailedDecryptionError:()=>s.tS,GAIA_URL:()=>c.Tj,GaiaHubError:()=>s.uI,HIRO_MAINNET_URL:()=>c.o3,HIRO_TESTNET_URL:()=>c.dT,InvalidAmountError:()=>s.IA,InvalidDIDError:()=>s.N0,InvalidParameterError:()=>s.dV,InvalidStateError:()=>s.Pp,Logger:()=>i.V,LoginFailedError:()=>s.f6,MissingParameterError:()=>s.In,NoSessionDataError:()=>s.Iz,NotEnoughFundsError:()=>s.Yj,NotEnoughProofError:()=>s.mN,PRIVATE_KEY_BYTES_COMPRESSED:()=>c.uc,PRIVATE_KEY_BYTES_UNCOMPRESSED:()=>c.xf,PayloadTooLargeError:()=>s.O3,PreconditionFailedError:()=>s.k9,RemoteServiceError:()=>s.ER,SignatureVerificationError:()=>s.Ht,ValidationError:()=>s.yI,alloc:()=>f.c4,asciiToBytes:()=>a.Mh,bigIntToBytes:()=>a.CZ,bytesToAscii:()=>a.qu,bytesToHex:()=>a.My,bytesToTwosBigInt:()=>a.VI,bytesToUtf8:()=>a.AE,concatArray:()=>a.yB,concatBytes:()=>a.Id,config:()=>o.$,createApiKeyMiddleware:()=>E.kO,createFetchFn:()=>E.Hq,equals:()=>f.aI,fetchWrapper:()=>E.MW,fromTwos:()=>a.ST,getAesCbcOutputLength:()=>a.R6,getBase64OutputLength:()=>a.pC,getFetchOptions:()=>E.NE,getGlobalObject:()=>a.VZ,getGlobalObjects:()=>a.Gu,getGlobalScope:()=>a.m6,hexToBigInt:()=>a.uU,hexToBytes:()=>a.aT,hexToInt:()=>a.od,hostMatches:()=>E._y,intToBigInt:()=>a.WI,intToBytes:()=>a.m5,intToHex:()=>a.y6,isInstance:()=>a.Qs,isLaterVersion:()=>a.F$,isSameOriginAbsoluteUrl:()=>a.LF,makeUUID4:()=>a.Gy,megabytesToBytes:()=>a.OR,nextHour:()=>a.wU,nextMonth:()=>a.wc,nextYear:()=>a.le,octetsToBytes:()=>a.Hu,parseRecoverableSignatureVrs:()=>u.NR,privateKeyToBytes:()=>l.x,readUInt16BE:()=>f.bc,readUInt16LE:()=>f.$l,readUInt32BE:()=>f.bb,readUInt32LE:()=>f.tF,readUInt8:()=>f.pJ,setFetchOptions:()=>E.pm,signatureRsvToVrs:()=>u.sC,signatureVrsToRsv:()=>u.Wz,toTwos:()=>a.JJ,updateQueryStringParameter:()=>a.K,utf8ToBytes:()=>a.AI,validateHash256:()=>a.EL,with0x:()=>a.fz,without0x:()=>a.Lw,writeUInt16BE:()=>f.ml,writeUInt16LE:()=>f.gN,writeUInt32BE:()=>f.Sw,writeUInt32LE:()=>f.ux,writeUInt8:()=>f.Gs});var o=r(755),s=r(146),i=r(561),a=r(568),c=r(832),u=r(214),l=r(417),f=r(487),d=r(956),g={};for(const e in d)["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]=()=>d[e]);r.d(n,g);var E=r(821);return n})());
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if(typeof define === 'function' && define.amd)
5
+ define([], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["StacksCommon"] = factory();
8
+ else
9
+ root["StacksCommon"] = factory();
10
+ })(this, () => {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ({
14
+
15
+ /***/ "./src/buffer.ts":
16
+ /*!***********************!*\
17
+ !*** ./src/buffer.ts ***!
18
+ \***********************/
19
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
20
+
21
+ __webpack_require__.r(__webpack_exports__);
22
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
23
+ /* harmony export */ alloc: () => (/* binding */ alloc),
24
+ /* harmony export */ equals: () => (/* binding */ equals),
25
+ /* harmony export */ readUInt16BE: () => (/* binding */ readUInt16BE),
26
+ /* harmony export */ readUInt16LE: () => (/* binding */ readUInt16LE),
27
+ /* harmony export */ readUInt32BE: () => (/* binding */ readUInt32BE),
28
+ /* harmony export */ readUInt32LE: () => (/* binding */ readUInt32LE),
29
+ /* harmony export */ readUInt8: () => (/* binding */ readUInt8),
30
+ /* harmony export */ writeUInt16BE: () => (/* binding */ writeUInt16BE),
31
+ /* harmony export */ writeUInt16LE: () => (/* binding */ writeUInt16LE),
32
+ /* harmony export */ writeUInt32BE: () => (/* binding */ writeUInt32BE),
33
+ /* harmony export */ writeUInt32LE: () => (/* binding */ writeUInt32LE),
34
+ /* harmony export */ writeUInt8: () => (/* binding */ writeUInt8)
35
+ /* harmony export */ });
36
+
37
+ function equals(a, b) {
38
+ if (a.byteLength !== b.byteLength) return false;
39
+ for (let i = 0; i < a.byteLength; i++) {
40
+ if (a[i] !== b[i]) return false;
41
+ }
42
+ return true;
43
+ }
44
+ function alloc(length, value) {
45
+ const a = new Uint8Array(length);
46
+ for (let i = 0; i < length; i++) {
47
+ a[i] = value;
48
+ }
49
+ return a;
50
+ }
51
+ function readUInt16BE(source, offset) {
52
+ return (source[offset + 0] << 8 | source[offset + 1]) >>> 0;
53
+ }
54
+ function writeUInt16BE(destination, value, offset = 0) {
55
+ destination[offset + 0] = value >>> 8;
56
+ destination[offset + 1] = value >>> 0;
57
+ return destination;
58
+ }
59
+ function readUInt8(source, offset) {
60
+ return source[offset];
61
+ }
62
+ function writeUInt8(destination, value, offset = 0) {
63
+ destination[offset] = value;
64
+ return destination;
65
+ }
66
+ function readUInt16LE(source, offset) {
67
+ return source[offset + 0] << 0 >>> 0 | source[offset + 1] << 8 >>> 0;
68
+ }
69
+ function writeUInt16LE(destination, value, offset = 0) {
70
+ destination[offset + 0] = value & 255;
71
+ value >>>= 8;
72
+ destination[offset + 1] = value & 255;
73
+ return destination;
74
+ }
75
+ function readUInt32BE(source, offset) {
76
+ return source[offset] * 2 ** 24 + source[offset + 1] * 2 ** 16 + source[offset + 2] * 2 ** 8 + source[offset + 3];
77
+ }
78
+ function writeUInt32BE(destination, value, offset = 0) {
79
+ destination[offset + 3] = value;
80
+ value >>>= 8;
81
+ destination[offset + 2] = value;
82
+ value >>>= 8;
83
+ destination[offset + 1] = value;
84
+ value >>>= 8;
85
+ destination[offset] = value;
86
+ return destination;
87
+ }
88
+ function readUInt32LE(source, offset) {
89
+ return source[offset + 0] << 0 >>> 0 | source[offset + 1] << 8 >>> 0 | source[offset + 2] << 16 >>> 0 | source[offset + 3] << 24 >>> 0;
90
+ }
91
+ function writeUInt32LE(destination, value, offset = 0) {
92
+ destination[offset + 0] = value & 255;
93
+ value >>>= 8;
94
+ destination[offset + 1] = value & 255;
95
+ value >>>= 8;
96
+ destination[offset + 2] = value & 255;
97
+ value >>>= 8;
98
+ destination[offset + 3] = value & 255;
99
+ return destination;
100
+ }
101
+
102
+
103
+ /***/ }),
104
+
105
+ /***/ "./src/config.ts":
106
+ /*!***********************!*\
107
+ !*** ./src/config.ts ***!
108
+ \***********************/
109
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
110
+
111
+ __webpack_require__.r(__webpack_exports__);
112
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
113
+ /* harmony export */ config: () => (/* binding */ config)
114
+ /* harmony export */ });
115
+
116
+ const config = {
117
+ network: {
118
+ layer1: "placeholder"
119
+ },
120
+ logLevel: "debug"
121
+ };
122
+
123
+
124
+
125
+ /***/ }),
126
+
127
+ /***/ "./src/constants.ts":
128
+ /*!**************************!*\
129
+ !*** ./src/constants.ts ***!
130
+ \**************************/
131
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
132
+
133
+ __webpack_require__.r(__webpack_exports__);
134
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
135
+ /* harmony export */ DEVNET_URL: () => (/* binding */ DEVNET_URL),
136
+ /* harmony export */ GAIA_URL: () => (/* binding */ GAIA_URL),
137
+ /* harmony export */ HIRO_MAINNET_URL: () => (/* binding */ HIRO_MAINNET_URL),
138
+ /* harmony export */ HIRO_TESTNET_URL: () => (/* binding */ HIRO_TESTNET_URL),
139
+ /* harmony export */ PRIVATE_KEY_BYTES_COMPRESSED: () => (/* binding */ PRIVATE_KEY_BYTES_COMPRESSED),
140
+ /* harmony export */ PRIVATE_KEY_BYTES_UNCOMPRESSED: () => (/* binding */ PRIVATE_KEY_BYTES_UNCOMPRESSED)
141
+ /* harmony export */ });
142
+
143
+ const HIRO_MAINNET_URL = "https://api.mainnet.hiro.so";
144
+ const HIRO_TESTNET_URL = "https://api.testnet.hiro.so";
145
+ const DEVNET_URL = "http://localhost:3999";
146
+ const GAIA_URL = "https://hub.blockstack.org";
147
+ const PRIVATE_KEY_BYTES_COMPRESSED = 33;
148
+ const PRIVATE_KEY_BYTES_UNCOMPRESSED = 32;
149
+
150
+
151
+ /***/ }),
152
+
153
+ /***/ "./src/errors.ts":
154
+ /*!***********************!*\
155
+ !*** ./src/errors.ts ***!
156
+ \***********************/
157
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
158
+
159
+ __webpack_require__.r(__webpack_exports__);
160
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
161
+ /* harmony export */ BadPathError: () => (/* binding */ BadPathError),
162
+ /* harmony export */ BlockstackError: () => (/* binding */ BlockstackError),
163
+ /* harmony export */ ConflictError: () => (/* binding */ ConflictError),
164
+ /* harmony export */ DoesNotExist: () => (/* binding */ DoesNotExist),
165
+ /* harmony export */ ERROR_CODES: () => (/* binding */ ERROR_CODES),
166
+ /* harmony export */ FailedDecryptionError: () => (/* binding */ FailedDecryptionError),
167
+ /* harmony export */ GaiaHubError: () => (/* binding */ GaiaHubError),
168
+ /* harmony export */ InvalidAmountError: () => (/* binding */ InvalidAmountError),
169
+ /* harmony export */ InvalidDIDError: () => (/* binding */ InvalidDIDError),
170
+ /* harmony export */ InvalidParameterError: () => (/* binding */ InvalidParameterError),
171
+ /* harmony export */ InvalidStateError: () => (/* binding */ InvalidStateError),
172
+ /* harmony export */ LoginFailedError: () => (/* binding */ LoginFailedError),
173
+ /* harmony export */ MissingParameterError: () => (/* binding */ MissingParameterError),
174
+ /* harmony export */ NoSessionDataError: () => (/* binding */ NoSessionDataError),
175
+ /* harmony export */ NotEnoughFundsError: () => (/* binding */ NotEnoughFundsError),
176
+ /* harmony export */ NotEnoughProofError: () => (/* binding */ NotEnoughProofError),
177
+ /* harmony export */ PayloadTooLargeError: () => (/* binding */ PayloadTooLargeError),
178
+ /* harmony export */ PreconditionFailedError: () => (/* binding */ PreconditionFailedError),
179
+ /* harmony export */ RemoteServiceError: () => (/* binding */ RemoteServiceError),
180
+ /* harmony export */ SignatureVerificationError: () => (/* binding */ SignatureVerificationError),
181
+ /* harmony export */ ValidationError: () => (/* binding */ ValidationError)
182
+ /* harmony export */ });
183
+
184
+ const ERROR_CODES = {
185
+ MISSING_PARAMETER: "missing_parameter",
186
+ REMOTE_SERVICE_ERROR: "remote_service_error",
187
+ INVALID_STATE: "invalid_state",
188
+ NO_SESSION_DATA: "no_session_data",
189
+ DOES_NOT_EXIST: "does_not_exist",
190
+ FAILED_DECRYPTION_ERROR: "failed_decryption_error",
191
+ INVALID_DID_ERROR: "invalid_did_error",
192
+ NOT_ENOUGH_FUNDS_ERROR: "not_enough_error",
193
+ INVALID_AMOUNT_ERROR: "invalid_amount_error",
194
+ LOGIN_FAILED_ERROR: "login_failed",
195
+ SIGNATURE_VERIFICATION_ERROR: "signature_verification_failure",
196
+ CONFLICT_ERROR: "conflict_error",
197
+ NOT_ENOUGH_PROOF_ERROR: "not_enough_proof_error",
198
+ BAD_PATH_ERROR: "bad_path_error",
199
+ VALIDATION_ERROR: "validation_error",
200
+ PAYLOAD_TOO_LARGE_ERROR: "payload_too_large_error",
201
+ PRECONDITION_FAILED_ERROR: "precondition_failed_error",
202
+ UNKNOWN: "unknown"
203
+ };
204
+ Object.freeze(ERROR_CODES);
205
+ class BlockstackError extends Error {
206
+ constructor(error) {
207
+ super();
208
+ let message = error.message;
209
+ let bugDetails = `Error Code: ${error.code}`;
210
+ let stack = this.stack;
211
+ if (!stack) {
212
+ try {
213
+ throw new Error();
214
+ } catch (e) {
215
+ stack = e.stack;
216
+ }
217
+ } else {
218
+ bugDetails += `Stack Trace:
219
+ ${stack}`;
220
+ }
221
+ message += `
222
+ If you believe this exception is caused by a bug in stacks.js,
223
+ please file a bug report: https://github.com/blockstack/stacks.js/issues
224
+
225
+ ${bugDetails}`;
226
+ this.message = message;
227
+ this.code = error.code;
228
+ this.parameter = error.parameter ? error.parameter : void 0;
229
+ }
230
+ toString() {
231
+ return `${super.toString()}
232
+ code: ${this.code} param: ${this.parameter ? this.parameter : "n/a"}`;
233
+ }
234
+ }
235
+ class InvalidParameterError extends BlockstackError {
236
+ constructor(parameter, message = "") {
237
+ super({ code: ERROR_CODES.MISSING_PARAMETER, message, parameter });
238
+ this.name = "MissingParametersError";
239
+ }
240
+ }
241
+ class MissingParameterError extends BlockstackError {
242
+ constructor(parameter, message = "") {
243
+ super({ code: ERROR_CODES.MISSING_PARAMETER, message, parameter });
244
+ this.name = "MissingParametersError";
245
+ }
246
+ }
247
+ class RemoteServiceError extends BlockstackError {
248
+ constructor(response, message = "") {
249
+ super({ code: ERROR_CODES.REMOTE_SERVICE_ERROR, message });
250
+ this.response = response;
251
+ }
252
+ }
253
+ class InvalidDIDError extends BlockstackError {
254
+ constructor(message = "") {
255
+ super({ code: ERROR_CODES.INVALID_DID_ERROR, message });
256
+ this.name = "InvalidDIDError";
257
+ }
258
+ }
259
+ class NotEnoughFundsError extends BlockstackError {
260
+ constructor(leftToFund) {
261
+ const message = `Not enough UTXOs to fund. Left to fund: ${leftToFund}`;
262
+ super({ code: ERROR_CODES.NOT_ENOUGH_FUNDS_ERROR, message });
263
+ this.leftToFund = leftToFund;
264
+ this.name = "NotEnoughFundsError";
265
+ this.message = message;
266
+ }
267
+ }
268
+ class InvalidAmountError extends BlockstackError {
269
+ constructor(fees, specifiedAmount) {
270
+ const message = `Not enough coin to fund fees transaction fees. Fees would be ${fees}, specified spend is ${specifiedAmount}`;
271
+ super({ code: ERROR_CODES.INVALID_AMOUNT_ERROR, message });
272
+ this.specifiedAmount = specifiedAmount;
273
+ this.fees = fees;
274
+ this.name = "InvalidAmountError";
275
+ this.message = message;
276
+ }
277
+ }
278
+ class LoginFailedError extends BlockstackError {
279
+ constructor(reason) {
280
+ const message = `Failed to login: ${reason}`;
281
+ super({ code: ERROR_CODES.LOGIN_FAILED_ERROR, message });
282
+ this.message = message;
283
+ this.name = "LoginFailedError";
284
+ }
285
+ }
286
+ class SignatureVerificationError extends BlockstackError {
287
+ constructor(reason) {
288
+ const message = `Failed to verify signature: ${reason}`;
289
+ super({ code: ERROR_CODES.SIGNATURE_VERIFICATION_ERROR, message });
290
+ this.message = message;
291
+ this.name = "SignatureVerificationError";
292
+ }
293
+ }
294
+ class FailedDecryptionError extends BlockstackError {
295
+ constructor(message = "Unable to decrypt cipher object.") {
296
+ super({ code: ERROR_CODES.FAILED_DECRYPTION_ERROR, message });
297
+ this.message = message;
298
+ this.name = "FailedDecryptionError";
299
+ }
300
+ }
301
+ class InvalidStateError extends BlockstackError {
302
+ constructor(message) {
303
+ super({ code: ERROR_CODES.INVALID_STATE, message });
304
+ this.message = message;
305
+ this.name = "InvalidStateError";
306
+ }
307
+ }
308
+ class NoSessionDataError extends BlockstackError {
309
+ constructor(message) {
310
+ super({ code: ERROR_CODES.INVALID_STATE, message });
311
+ this.message = message;
312
+ this.name = "NoSessionDataError";
313
+ }
314
+ }
315
+ class GaiaHubError extends BlockstackError {
316
+ constructor(error, response) {
317
+ super(error);
318
+ if (response) {
319
+ this.hubError = {
320
+ statusCode: response.status,
321
+ statusText: response.statusText
322
+ };
323
+ if (typeof response.body === "string") {
324
+ this.hubError.message = response.body;
325
+ } else if (typeof response.body === "object") {
326
+ Object.assign(this.hubError, response.body);
327
+ }
328
+ }
329
+ }
330
+ }
331
+ class DoesNotExist extends GaiaHubError {
332
+ constructor(message, response) {
333
+ super({ message, code: ERROR_CODES.DOES_NOT_EXIST }, response);
334
+ this.name = "DoesNotExist";
335
+ }
336
+ }
337
+ class ConflictError extends GaiaHubError {
338
+ constructor(message, response) {
339
+ super({ message, code: ERROR_CODES.CONFLICT_ERROR }, response);
340
+ this.name = "ConflictError";
341
+ }
342
+ }
343
+ class NotEnoughProofError extends GaiaHubError {
344
+ constructor(message, response) {
345
+ super({ message, code: ERROR_CODES.NOT_ENOUGH_PROOF_ERROR }, response);
346
+ this.name = "NotEnoughProofError";
347
+ }
348
+ }
349
+ class BadPathError extends GaiaHubError {
350
+ constructor(message, response) {
351
+ super({ message, code: ERROR_CODES.BAD_PATH_ERROR }, response);
352
+ this.name = "BadPathError";
353
+ }
354
+ }
355
+ class ValidationError extends GaiaHubError {
356
+ constructor(message, response) {
357
+ super({ message, code: ERROR_CODES.VALIDATION_ERROR }, response);
358
+ this.name = "ValidationError";
359
+ }
360
+ }
361
+ class PayloadTooLargeError extends GaiaHubError {
362
+ constructor(message, response, maxUploadByteSize) {
363
+ super({ message, code: ERROR_CODES.PAYLOAD_TOO_LARGE_ERROR }, response);
364
+ this.name = "PayloadTooLargeError";
365
+ this.maxUploadByteSize = maxUploadByteSize;
366
+ }
367
+ }
368
+ class PreconditionFailedError extends GaiaHubError {
369
+ constructor(message, response) {
370
+ super({ message, code: ERROR_CODES.PRECONDITION_FAILED_ERROR }, response);
371
+ this.name = "PreconditionFailedError";
372
+ }
373
+ }
374
+
375
+
376
+ /***/ }),
377
+
378
+ /***/ "./src/fetch.ts":
379
+ /*!**********************!*\
380
+ !*** ./src/fetch.ts ***!
381
+ \**********************/
382
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
383
+
384
+ __webpack_require__.r(__webpack_exports__);
385
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
386
+ /* harmony export */ createApiKeyMiddleware: () => (/* binding */ createApiKeyMiddleware),
387
+ /* harmony export */ createFetchFn: () => (/* binding */ createFetchFn),
388
+ /* harmony export */ fetchWrapper: () => (/* binding */ fetchWrapper),
389
+ /* harmony export */ getFetchOptions: () => (/* binding */ getFetchOptions),
390
+ /* harmony export */ hostMatches: () => (/* binding */ hostMatches),
391
+ /* harmony export */ setFetchOptions: () => (/* binding */ setFetchOptions)
392
+ /* harmony export */ });
393
+
394
+ var __defProp = Object.defineProperty;
395
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
396
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
397
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
398
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
399
+ var __spreadValues = (a, b) => {
400
+ for (var prop in b || (b = {}))
401
+ if (__hasOwnProp.call(b, prop))
402
+ __defNormalProp(a, prop, b[prop]);
403
+ if (__getOwnPropSymbols)
404
+ for (var prop of __getOwnPropSymbols(b)) {
405
+ if (__propIsEnum.call(b, prop))
406
+ __defNormalProp(a, prop, b[prop]);
407
+ }
408
+ return a;
409
+ };
410
+ const defaultFetchOpts = {
411
+ // By default referrer value will be client:origin: above reference link
412
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy
413
+ referrerPolicy: "origin",
414
+ // Use origin value for referrer policy
415
+ headers: {
416
+ "x-hiro-product": "stacksjs"
417
+ }
418
+ };
419
+ const getFetchOptions = () => {
420
+ return defaultFetchOpts;
421
+ };
422
+ const setFetchOptions = (ops) => {
423
+ return Object.assign(defaultFetchOpts, ops);
424
+ };
425
+ async function fetchWrapper(input, init) {
426
+ const fetchOpts = {};
427
+ Object.assign(fetchOpts, defaultFetchOpts, init);
428
+ const fetchResult = await fetch(input, fetchOpts);
429
+ return fetchResult;
430
+ }
431
+ function hostMatches(host, pattern) {
432
+ if (typeof pattern === "string") return pattern === host;
433
+ return pattern.exec(host);
434
+ }
435
+ function createApiKeyMiddleware({
436
+ apiKey,
437
+ host = /(.*)api(.*)(\.stacks\.co|\.hiro\.so)$/i,
438
+ httpHeader = "x-api-key"
439
+ }) {
440
+ return {
441
+ pre: (context) => {
442
+ const reqUrl = new URL(context.url);
443
+ if (!hostMatches(reqUrl.host, host)) return;
444
+ const headers = context.init.headers instanceof Headers ? context.init.headers : context.init.headers = new Headers(context.init.headers);
445
+ headers.set(httpHeader, apiKey);
446
+ }
447
+ };
448
+ }
449
+ function argsForCreateFetchFn(args) {
450
+ let fetchLib = fetchWrapper;
451
+ let middlewares = [];
452
+ if (args.length > 0 && typeof args[0] === "function") {
453
+ fetchLib = args.shift();
454
+ }
455
+ if (args.length > 0) {
456
+ middlewares = args;
457
+ }
458
+ return { fetchLib, middlewares };
459
+ }
460
+ function createFetchFn(...args) {
461
+ const { fetchLib, middlewares } = argsForCreateFetchFn(args);
462
+ const fetchFn = async (url, init) => {
463
+ var _a;
464
+ let fetchParams = { url, init: init != null ? init : {} };
465
+ for (const middleware of middlewares) {
466
+ if (typeof middleware.pre === "function") {
467
+ const result = await Promise.resolve(
468
+ middleware.pre(__spreadValues({
469
+ fetch: fetchLib
470
+ }, fetchParams))
471
+ );
472
+ fetchParams = result != null ? result : fetchParams;
473
+ }
474
+ }
475
+ let response = await fetchLib(fetchParams.url, fetchParams.init);
476
+ for (const middleware of middlewares) {
477
+ if (typeof middleware.post === "function") {
478
+ const result = await Promise.resolve(
479
+ middleware.post({
480
+ fetch: fetchLib,
481
+ url: fetchParams.url,
482
+ init: fetchParams.init,
483
+ response: (_a = response == null ? void 0 : response.clone()) != null ? _a : response
484
+ })
485
+ );
486
+ response = result != null ? result : response;
487
+ }
488
+ }
489
+ return response;
490
+ };
491
+ return fetchFn;
492
+ }
493
+
494
+
495
+ /***/ }),
496
+
497
+ /***/ "./src/keys.ts":
498
+ /*!*********************!*\
499
+ !*** ./src/keys.ts ***!
500
+ \*********************/
501
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
502
+
503
+ __webpack_require__.r(__webpack_exports__);
504
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
505
+ /* harmony export */ privateKeyToBytes: () => (/* binding */ privateKeyToBytes)
506
+ /* harmony export */ });
507
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./src/utils.ts");
508
+
509
+
510
+ function privateKeyToBytes(privateKey) {
511
+ const privateKeyBuffer = typeof privateKey === "string" ? (0,_utils__WEBPACK_IMPORTED_MODULE_0__.hexToBytes)(privateKey) : privateKey;
512
+ if (privateKeyBuffer.length != 32 && privateKeyBuffer.length != 33) {
513
+ throw new Error(
514
+ `Improperly formatted private-key. Private-key byte length should be 32 or 33. Length provided: ${privateKeyBuffer.length}`
515
+ );
516
+ }
517
+ if (privateKeyBuffer.length == 33 && privateKeyBuffer[32] !== 1) {
518
+ throw new Error(
519
+ "Improperly formatted private-key. 33 bytes indicate compressed key, but the last byte must be == 01"
520
+ );
521
+ }
522
+ return privateKeyBuffer;
523
+ }
524
+
525
+
526
+ /***/ }),
527
+
528
+ /***/ "./src/logger.ts":
529
+ /*!***********************!*\
530
+ !*** ./src/logger.ts ***!
531
+ \***********************/
532
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
533
+
534
+ __webpack_require__.r(__webpack_exports__);
535
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
536
+ /* harmony export */ Logger: () => (/* binding */ Logger)
537
+ /* harmony export */ });
538
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./config */ "./src/config.ts");
539
+
540
+
541
+ const levels = ["debug", "info", "warn", "error", "none"];
542
+ const levelToInt = {};
543
+ const intToLevel = {};
544
+ for (let index = 0; index < levels.length; index++) {
545
+ const level = levels[index];
546
+ levelToInt[level] = index;
547
+ intToLevel[index] = level;
548
+ }
549
+ class Logger {
550
+ static error(message) {
551
+ if (!this.shouldLog("error")) return;
552
+ console.error(this.logMessage("error", message));
553
+ }
554
+ static warn(message) {
555
+ if (!this.shouldLog("warn")) return;
556
+ console.warn(this.logMessage("warn", message));
557
+ }
558
+ static info(message) {
559
+ if (!this.shouldLog("info")) return;
560
+ console.log(this.logMessage("info", message));
561
+ }
562
+ static debug(message) {
563
+ if (!this.shouldLog("debug")) return;
564
+ console.log(this.logMessage("debug", message));
565
+ }
566
+ static logMessage(level, message) {
567
+ return `[${level.toUpperCase()}] ${message}`;
568
+ }
569
+ static shouldLog(level) {
570
+ const currentLevel = levelToInt[_config__WEBPACK_IMPORTED_MODULE_0__.config.logLevel];
571
+ return currentLevel <= levelToInt[level];
572
+ }
573
+ }
574
+
575
+
576
+ /***/ }),
577
+
578
+ /***/ "./src/signatures.ts":
579
+ /*!***************************!*\
580
+ !*** ./src/signatures.ts ***!
581
+ \***************************/
582
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
583
+
584
+ __webpack_require__.r(__webpack_exports__);
585
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
586
+ /* harmony export */ parseRecoverableSignatureVrs: () => (/* binding */ parseRecoverableSignatureVrs),
587
+ /* harmony export */ signatureRsvToVrs: () => (/* binding */ signatureRsvToVrs),
588
+ /* harmony export */ signatureVrsToRsv: () => (/* binding */ signatureVrsToRsv)
589
+ /* harmony export */ });
590
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./src/utils.ts");
591
+
592
+
593
+ const COORDINATE_BYTES = 32;
594
+ function parseRecoverableSignatureVrs(signature) {
595
+ if (signature.length < COORDINATE_BYTES * 2 * 2 + 1) {
596
+ throw new Error("Invalid signature");
597
+ }
598
+ const recoveryIdHex = signature.slice(0, 2);
599
+ const r = signature.slice(2, 2 + COORDINATE_BYTES * 2);
600
+ const s = signature.slice(2 + COORDINATE_BYTES * 2);
601
+ return {
602
+ recoveryId: (0,_utils__WEBPACK_IMPORTED_MODULE_0__.hexToInt)(recoveryIdHex),
603
+ r,
604
+ s
605
+ };
606
+ }
607
+ function signatureVrsToRsv(signature) {
608
+ return signature.slice(2) + signature.slice(0, 2);
609
+ }
610
+ function signatureRsvToVrs(signature) {
611
+ return signature.slice(-2) + signature.slice(0, -2);
612
+ }
613
+
614
+
615
+ /***/ }),
616
+
617
+ /***/ "./src/types.ts":
618
+ /*!**********************!*\
619
+ !*** ./src/types.ts ***!
620
+ \**********************/
621
+ /***/ (() => {
622
+
623
+
624
+
625
+
626
+ /***/ }),
627
+
628
+ /***/ "./src/utils.ts":
629
+ /*!**********************!*\
630
+ !*** ./src/utils.ts ***!
631
+ \**********************/
632
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
633
+
634
+ __webpack_require__.r(__webpack_exports__);
635
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
636
+ /* harmony export */ BLOCKSTACK_HANDLER: () => (/* binding */ BLOCKSTACK_HANDLER),
637
+ /* harmony export */ asciiToBytes: () => (/* binding */ asciiToBytes),
638
+ /* harmony export */ bigIntToBytes: () => (/* binding */ bigIntToBytes),
639
+ /* harmony export */ bytesToAscii: () => (/* binding */ bytesToAscii),
640
+ /* harmony export */ bytesToHex: () => (/* binding */ bytesToHex),
641
+ /* harmony export */ bytesToTwosBigInt: () => (/* binding */ bytesToTwosBigInt),
642
+ /* harmony export */ bytesToUtf8: () => (/* binding */ bytesToUtf8),
643
+ /* harmony export */ concatArray: () => (/* binding */ concatArray),
644
+ /* harmony export */ concatBytes: () => (/* binding */ concatBytes),
645
+ /* harmony export */ fromTwos: () => (/* binding */ fromTwos),
646
+ /* harmony export */ getAesCbcOutputLength: () => (/* binding */ getAesCbcOutputLength),
647
+ /* harmony export */ getBase64OutputLength: () => (/* binding */ getBase64OutputLength),
648
+ /* harmony export */ getGlobalObject: () => (/* binding */ getGlobalObject),
649
+ /* harmony export */ getGlobalObjects: () => (/* binding */ getGlobalObjects),
650
+ /* harmony export */ getGlobalScope: () => (/* binding */ getGlobalScope),
651
+ /* harmony export */ hexToBigInt: () => (/* binding */ hexToBigInt),
652
+ /* harmony export */ hexToBytes: () => (/* binding */ hexToBytes),
653
+ /* harmony export */ hexToInt: () => (/* binding */ hexToInt),
654
+ /* harmony export */ intToBigInt: () => (/* binding */ intToBigInt),
655
+ /* harmony export */ intToBytes: () => (/* binding */ intToBytes),
656
+ /* harmony export */ intToHex: () => (/* binding */ intToHex),
657
+ /* harmony export */ isInstance: () => (/* binding */ isInstance),
658
+ /* harmony export */ isLaterVersion: () => (/* binding */ isLaterVersion),
659
+ /* harmony export */ isSameOriginAbsoluteUrl: () => (/* binding */ isSameOriginAbsoluteUrl),
660
+ /* harmony export */ makeUUID4: () => (/* binding */ makeUUID4),
661
+ /* harmony export */ megabytesToBytes: () => (/* binding */ megabytesToBytes),
662
+ /* harmony export */ nextHour: () => (/* binding */ nextHour),
663
+ /* harmony export */ nextMonth: () => (/* binding */ nextMonth),
664
+ /* harmony export */ nextYear: () => (/* binding */ nextYear),
665
+ /* harmony export */ octetsToBytes: () => (/* binding */ octetsToBytes),
666
+ /* harmony export */ toTwos: () => (/* binding */ toTwos),
667
+ /* harmony export */ updateQueryStringParameter: () => (/* binding */ updateQueryStringParameter),
668
+ /* harmony export */ utf8ToBytes: () => (/* binding */ utf8ToBytes),
669
+ /* harmony export */ validateHash256: () => (/* binding */ validateHash256),
670
+ /* harmony export */ with0x: () => (/* binding */ with0x),
671
+ /* harmony export */ without0x: () => (/* binding */ without0x)
672
+ /* harmony export */ });
673
+ /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./logger */ "./src/logger.ts");
674
+
675
+
676
+ const BLOCKSTACK_HANDLER = "blockstack";
677
+ function nextYear() {
678
+ return new Date((/* @__PURE__ */ new Date()).setFullYear((/* @__PURE__ */ new Date()).getFullYear() + 1));
679
+ }
680
+ function nextMonth() {
681
+ return new Date((/* @__PURE__ */ new Date()).setMonth((/* @__PURE__ */ new Date()).getMonth() + 1));
682
+ }
683
+ function nextHour() {
684
+ return new Date((/* @__PURE__ */ new Date()).setHours((/* @__PURE__ */ new Date()).getHours() + 1));
685
+ }
686
+ function megabytesToBytes(megabytes) {
687
+ if (!Number.isFinite(megabytes)) {
688
+ return 0;
689
+ }
690
+ return Math.floor(megabytes * 1024 * 1024);
691
+ }
692
+ function getAesCbcOutputLength(inputByteLength) {
693
+ const cipherTextLength = (Math.floor(inputByteLength / 16) + 1) * 16;
694
+ return cipherTextLength;
695
+ }
696
+ function getBase64OutputLength(inputByteLength) {
697
+ const encodedLength = Math.ceil(inputByteLength / 3) * 4;
698
+ return encodedLength;
699
+ }
700
+ function updateQueryStringParameter(uri, key, value) {
701
+ const re = new RegExp(`([?&])${key}=.*?(&|$)`, "i");
702
+ const separator = uri.indexOf("?") !== -1 ? "&" : "?";
703
+ if (uri.match(re)) {
704
+ return uri.replace(re, `$1${key}=${value}$2`);
705
+ } else {
706
+ return `${uri}${separator}${key}=${value}`;
707
+ }
708
+ }
709
+ function isLaterVersion(v1, v2) {
710
+ if (v1 === void 0 || v1 === "") {
711
+ v1 = "0.0.0";
712
+ }
713
+ if (v2 === void 0 || v1 === "") {
714
+ v2 = "0.0.0";
715
+ }
716
+ const v1tuple = v1.split(".").map((x) => parseInt(x, 10));
717
+ const v2tuple = v2.split(".").map((x) => parseInt(x, 10));
718
+ for (let index = 0; index < v2.length; index++) {
719
+ if (index >= v1.length) {
720
+ v2tuple.push(0);
721
+ }
722
+ if (v1tuple[index] < v2tuple[index]) {
723
+ return false;
724
+ }
725
+ }
726
+ return true;
727
+ }
728
+ function makeUUID4() {
729
+ let d = (/* @__PURE__ */ new Date()).getTime();
730
+ if (typeof performance !== "undefined" && typeof performance.now === "function") {
731
+ d += performance.now();
732
+ }
733
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
734
+ const r = (d + Math.random() * 16) % 16 | 0;
735
+ d = Math.floor(d / 16);
736
+ return (c === "x" ? r : r & 3 | 8).toString(16);
737
+ });
738
+ }
739
+ function isSameOriginAbsoluteUrl(uri1, uri2) {
740
+ try {
741
+ const parsedUri1 = new URL(uri1);
742
+ const parsedUri2 = new URL(uri2);
743
+ const port1 = parseInt(parsedUri1.port || "0", 10) | 0 || (parsedUri1.protocol === "https:" ? 443 : 80);
744
+ const port2 = parseInt(parsedUri2.port || "0", 10) | 0 || (parsedUri2.protocol === "https:" ? 443 : 80);
745
+ const match = {
746
+ scheme: parsedUri1.protocol === parsedUri2.protocol,
747
+ hostname: parsedUri1.hostname === parsedUri2.hostname,
748
+ port: port1 === port2,
749
+ absolute: (uri1.includes("http://") || uri1.includes("https://")) && (uri2.includes("http://") || uri2.includes("https://"))
750
+ };
751
+ return match.scheme && match.hostname && match.port && match.absolute;
752
+ } catch (error) {
753
+ console.log(error);
754
+ console.log("Parsing error in same URL origin check");
755
+ return false;
756
+ }
757
+ }
758
+ function getGlobalScope() {
759
+ if (typeof self !== "undefined") {
760
+ return self;
761
+ }
762
+ if (typeof window !== "undefined") {
763
+ return window;
764
+ }
765
+ if (typeof __webpack_require__.g !== "undefined") {
766
+ return __webpack_require__.g;
767
+ }
768
+ throw new Error(
769
+ "Unexpected runtime environment - no supported global scope (`window`, `self`, `global`) available"
770
+ );
771
+ }
772
+ function getAPIUsageErrorMessage(scopeObject, apiName, usageDesc) {
773
+ if (usageDesc) {
774
+ return `Use of '${usageDesc}' requires \`${apiName}\` which is unavailable on the '${scopeObject}' object within the currently executing environment.`;
775
+ } else {
776
+ return `\`${apiName}\` is unavailable on the '${scopeObject}' object within the currently executing environment.`;
777
+ }
778
+ }
779
+ function getGlobalObject(name, { throwIfUnavailable, usageDesc, returnEmptyObject } = {}) {
780
+ let globalScope = void 0;
781
+ try {
782
+ globalScope = getGlobalScope();
783
+ if (globalScope) {
784
+ const obj = globalScope[name];
785
+ if (obj) {
786
+ return obj;
787
+ }
788
+ }
789
+ } catch (error) {
790
+ _logger__WEBPACK_IMPORTED_MODULE_0__.Logger.error(`Error getting object '${name}' from global scope '${globalScope}': ${error}`);
791
+ }
792
+ if (throwIfUnavailable) {
793
+ const errMsg = getAPIUsageErrorMessage(globalScope, name.toString(), usageDesc);
794
+ _logger__WEBPACK_IMPORTED_MODULE_0__.Logger.error(errMsg);
795
+ throw new Error(errMsg);
796
+ }
797
+ if (returnEmptyObject) {
798
+ return {};
799
+ }
800
+ return void 0;
801
+ }
802
+ function getGlobalObjects(names, { throwIfUnavailable, usageDesc, returnEmptyObject } = {}) {
803
+ let globalScope;
804
+ try {
805
+ globalScope = getGlobalScope();
806
+ } catch (error) {
807
+ _logger__WEBPACK_IMPORTED_MODULE_0__.Logger.error(`Error getting global scope: ${error}`);
808
+ if (throwIfUnavailable) {
809
+ const errMsg = getAPIUsageErrorMessage(globalScope, names[0].toString(), usageDesc);
810
+ _logger__WEBPACK_IMPORTED_MODULE_0__.Logger.error(errMsg);
811
+ throw errMsg;
812
+ } else if (returnEmptyObject) {
813
+ globalScope = {};
814
+ }
815
+ }
816
+ const result = {};
817
+ for (let i = 0; i < names.length; i++) {
818
+ const name = names[i];
819
+ try {
820
+ if (globalScope) {
821
+ const obj = globalScope[name];
822
+ if (obj) {
823
+ result[name] = obj;
824
+ } else if (throwIfUnavailable) {
825
+ const errMsg = getAPIUsageErrorMessage(globalScope, name.toString(), usageDesc);
826
+ _logger__WEBPACK_IMPORTED_MODULE_0__.Logger.error(errMsg);
827
+ throw new Error(errMsg);
828
+ } else if (returnEmptyObject) {
829
+ result[name] = {};
830
+ }
831
+ }
832
+ } catch (error) {
833
+ if (throwIfUnavailable) {
834
+ const errMsg = getAPIUsageErrorMessage(globalScope, name.toString(), usageDesc);
835
+ _logger__WEBPACK_IMPORTED_MODULE_0__.Logger.error(errMsg);
836
+ throw new Error(errMsg);
837
+ }
838
+ }
839
+ }
840
+ return result;
841
+ }
842
+ function intToBytes(value, byteLength) {
843
+ return bigIntToBytes(intToBigInt(value), byteLength);
844
+ }
845
+ function intToBigInt(value) {
846
+ if (typeof value === "bigint") return value;
847
+ if (typeof value === "string") return BigInt(value);
848
+ if (typeof value === "number") {
849
+ if (!Number.isInteger(value)) {
850
+ throw new RangeError(`Invalid value. Values of type 'number' must be an integer.`);
851
+ }
852
+ if (value > Number.MAX_SAFE_INTEGER) {
853
+ throw new RangeError(
854
+ `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.`
855
+ );
856
+ }
857
+ return BigInt(value);
858
+ }
859
+ if (isInstance(value, Uint8Array)) return BigInt(`0x${bytesToHex(value)}`);
860
+ throw new TypeError(
861
+ `intToBigInt: Invalid value type. Must be a number, bigint, BigInt-compatible string, or Uint8Array.`
862
+ );
863
+ }
864
+ function with0x(value) {
865
+ return /^0x/i.test(value) ? value : `0x${value}`;
866
+ }
867
+ function without0x(value) {
868
+ return /^0x/i.test(value) ? value.slice(2) : value;
869
+ }
870
+ function hexToBigInt(hex) {
871
+ if (typeof hex !== "string")
872
+ throw new TypeError(`hexToBigInt: expected string, got ${typeof hex}`);
873
+ return BigInt(`0x${hex}`);
874
+ }
875
+ function intToHex(integer, byteLength = 8) {
876
+ const value = typeof integer === "bigint" ? integer : intToBigInt(integer);
877
+ return value.toString(16).padStart(byteLength * 2, "0");
878
+ }
879
+ function hexToInt(hex) {
880
+ return parseInt(hex, 16);
881
+ }
882
+ function bigIntToBytes(value, length = 16) {
883
+ const hex = intToHex(value, length);
884
+ return hexToBytes(hex);
885
+ }
886
+ function toTwos(value, width) {
887
+ if (value < -(BigInt(1) << width - BigInt(1)) || (BigInt(1) << width - BigInt(1)) - BigInt(1) < value) {
888
+ throw `Unable to represent integer in width: ${width}`;
889
+ }
890
+ if (value >= BigInt(0)) {
891
+ return BigInt(value);
892
+ }
893
+ return value + (BigInt(1) << width);
894
+ }
895
+ function nthBit(value, n) {
896
+ return value & BigInt(1) << n;
897
+ }
898
+ function bytesToTwosBigInt(bytes) {
899
+ return fromTwos(BigInt(`0x${bytesToHex(bytes)}`), BigInt(bytes.byteLength * 8));
900
+ }
901
+ function fromTwos(value, width) {
902
+ if (nthBit(value, width - BigInt(1))) {
903
+ return value - (BigInt(1) << width);
904
+ }
905
+ return value;
906
+ }
907
+ const hexes = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
908
+ function bytesToHex(uint8a) {
909
+ if (!(uint8a instanceof Uint8Array)) throw new Error("Uint8Array expected");
910
+ let hex = "";
911
+ for (const u of uint8a) {
912
+ hex += hexes[u];
913
+ }
914
+ return hex;
915
+ }
916
+ function hexToBytes(hex) {
917
+ if (typeof hex !== "string") {
918
+ throw new TypeError(`hexToBytes: expected string, got ${typeof hex}`);
919
+ }
920
+ hex = without0x(hex);
921
+ hex = hex.length % 2 ? `0${hex}` : hex;
922
+ const array = new Uint8Array(hex.length / 2);
923
+ for (let i = 0; i < array.length; i++) {
924
+ const j = i * 2;
925
+ const hexByte = hex.slice(j, j + 2);
926
+ const byte = Number.parseInt(hexByte, 16);
927
+ if (Number.isNaN(byte) || byte < 0) throw new Error("Invalid byte sequence");
928
+ array[i] = byte;
929
+ }
930
+ return array;
931
+ }
932
+ function utf8ToBytes(str) {
933
+ return new TextEncoder().encode(str);
934
+ }
935
+ function bytesToUtf8(arr) {
936
+ return new TextDecoder().decode(arr);
937
+ }
938
+ function asciiToBytes(str) {
939
+ const byteArray = [];
940
+ for (let i = 0; i < str.length; i++) {
941
+ byteArray.push(str.charCodeAt(i) & 255);
942
+ }
943
+ return new Uint8Array(byteArray);
944
+ }
945
+ function bytesToAscii(arr) {
946
+ return String.fromCharCode.apply(null, arr);
947
+ }
948
+ function isNotOctet(octet) {
949
+ return !Number.isInteger(octet) || octet < 0 || octet > 255;
950
+ }
951
+ function octetsToBytes(numbers) {
952
+ if (numbers.some(isNotOctet)) throw new Error("Some values are invalid bytes.");
953
+ return new Uint8Array(numbers);
954
+ }
955
+ function concatBytes(...arrays) {
956
+ if (!arrays.every((a) => a instanceof Uint8Array)) throw new Error("Uint8Array list expected");
957
+ if (arrays.length === 1) return arrays[0];
958
+ const length = arrays.reduce((a, arr) => a + arr.length, 0);
959
+ const result = new Uint8Array(length);
960
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
961
+ const arr = arrays[i];
962
+ result.set(arr, pad);
963
+ pad += arr.length;
964
+ }
965
+ return result;
966
+ }
967
+ function concatArray(elements) {
968
+ return concatBytes(
969
+ ...elements.map((e) => {
970
+ if (typeof e === "number") return octetsToBytes([e]);
971
+ if (e instanceof Array) return octetsToBytes(e);
972
+ return e;
973
+ })
974
+ );
975
+ }
976
+ function isInstance(object, clazz) {
977
+ var _a, _b;
978
+ return object instanceof clazz || ((_b = (_a = object == null ? void 0 : object.constructor) == null ? void 0 : _a.name) == null ? void 0 : _b.toLowerCase()) === clazz.name;
979
+ }
980
+ function validateHash256(hex) {
981
+ hex = without0x(hex);
982
+ if (hex.length !== 64) return false;
983
+ return /^[0-9a-fA-F]+$/.test(hex);
984
+ }
985
+
986
+
987
+ /***/ })
988
+
989
+ /******/ });
990
+ /************************************************************************/
991
+ /******/ // The module cache
992
+ /******/ var __webpack_module_cache__ = {};
993
+ /******/
994
+ /******/ // The require function
995
+ /******/ function __webpack_require__(moduleId) {
996
+ /******/ // Check if module is in cache
997
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
998
+ /******/ if (cachedModule !== undefined) {
999
+ /******/ return cachedModule.exports;
1000
+ /******/ }
1001
+ /******/ // Create a new module (and put it into the cache)
1002
+ /******/ var module = __webpack_module_cache__[moduleId] = {
1003
+ /******/ // no module.id needed
1004
+ /******/ // no module.loaded needed
1005
+ /******/ exports: {}
1006
+ /******/ };
1007
+ /******/
1008
+ /******/ // Execute the module function
1009
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
1010
+ /******/
1011
+ /******/ // Return the exports of the module
1012
+ /******/ return module.exports;
1013
+ /******/ }
1014
+ /******/
1015
+ /************************************************************************/
1016
+ /******/ /* webpack/runtime/compat get default export */
1017
+ /******/ (() => {
1018
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
1019
+ /******/ __webpack_require__.n = (module) => {
1020
+ /******/ var getter = module && module.__esModule ?
1021
+ /******/ () => (module['default']) :
1022
+ /******/ () => (module);
1023
+ /******/ __webpack_require__.d(getter, { a: getter });
1024
+ /******/ return getter;
1025
+ /******/ };
1026
+ /******/ })();
1027
+ /******/
1028
+ /******/ /* webpack/runtime/define property getters */
1029
+ /******/ (() => {
1030
+ /******/ // define getter functions for harmony exports
1031
+ /******/ __webpack_require__.d = (exports, definition) => {
1032
+ /******/ for(var key in definition) {
1033
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
1034
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
1035
+ /******/ }
1036
+ /******/ }
1037
+ /******/ };
1038
+ /******/ })();
1039
+ /******/
1040
+ /******/ /* webpack/runtime/global */
1041
+ /******/ (() => {
1042
+ /******/ __webpack_require__.g = (function() {
1043
+ /******/ if (typeof globalThis === 'object') return globalThis;
1044
+ /******/ try {
1045
+ /******/ return this || new Function('return this')();
1046
+ /******/ } catch (e) {
1047
+ /******/ if (typeof window === 'object') return window;
1048
+ /******/ }
1049
+ /******/ })();
1050
+ /******/ })();
1051
+ /******/
1052
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
1053
+ /******/ (() => {
1054
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
1055
+ /******/ })();
1056
+ /******/
1057
+ /******/ /* webpack/runtime/make namespace object */
1058
+ /******/ (() => {
1059
+ /******/ // define __esModule on exports
1060
+ /******/ __webpack_require__.r = (exports) => {
1061
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1062
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1063
+ /******/ }
1064
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
1065
+ /******/ };
1066
+ /******/ })();
1067
+ /******/
1068
+ /************************************************************************/
1069
+ var __webpack_exports__ = {};
1070
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
1071
+ (() => {
1072
+ /*!**********************!*\
1073
+ !*** ./src/index.ts ***!
1074
+ \**********************/
1075
+ __webpack_require__.r(__webpack_exports__);
1076
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1077
+ /* harmony export */ BLOCKSTACK_HANDLER: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.BLOCKSTACK_HANDLER),
1078
+ /* harmony export */ BadPathError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.BadPathError),
1079
+ /* harmony export */ BlockstackError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.BlockstackError),
1080
+ /* harmony export */ ConflictError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.ConflictError),
1081
+ /* harmony export */ DEVNET_URL: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_4__.DEVNET_URL),
1082
+ /* harmony export */ DoesNotExist: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.DoesNotExist),
1083
+ /* harmony export */ ERROR_CODES: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.ERROR_CODES),
1084
+ /* harmony export */ FailedDecryptionError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.FailedDecryptionError),
1085
+ /* harmony export */ GAIA_URL: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_4__.GAIA_URL),
1086
+ /* harmony export */ GaiaHubError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.GaiaHubError),
1087
+ /* harmony export */ HIRO_MAINNET_URL: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_4__.HIRO_MAINNET_URL),
1088
+ /* harmony export */ HIRO_TESTNET_URL: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_4__.HIRO_TESTNET_URL),
1089
+ /* harmony export */ InvalidAmountError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.InvalidAmountError),
1090
+ /* harmony export */ InvalidDIDError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.InvalidDIDError),
1091
+ /* harmony export */ InvalidParameterError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.InvalidParameterError),
1092
+ /* harmony export */ InvalidStateError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.InvalidStateError),
1093
+ /* harmony export */ Logger: () => (/* reexport safe */ _logger__WEBPACK_IMPORTED_MODULE_2__.Logger),
1094
+ /* harmony export */ LoginFailedError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.LoginFailedError),
1095
+ /* harmony export */ MissingParameterError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.MissingParameterError),
1096
+ /* harmony export */ NoSessionDataError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.NoSessionDataError),
1097
+ /* harmony export */ NotEnoughFundsError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.NotEnoughFundsError),
1098
+ /* harmony export */ NotEnoughProofError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.NotEnoughProofError),
1099
+ /* harmony export */ PRIVATE_KEY_BYTES_COMPRESSED: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_4__.PRIVATE_KEY_BYTES_COMPRESSED),
1100
+ /* harmony export */ PRIVATE_KEY_BYTES_UNCOMPRESSED: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_4__.PRIVATE_KEY_BYTES_UNCOMPRESSED),
1101
+ /* harmony export */ PayloadTooLargeError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.PayloadTooLargeError),
1102
+ /* harmony export */ PreconditionFailedError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.PreconditionFailedError),
1103
+ /* harmony export */ RemoteServiceError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.RemoteServiceError),
1104
+ /* harmony export */ SignatureVerificationError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.SignatureVerificationError),
1105
+ /* harmony export */ ValidationError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_1__.ValidationError),
1106
+ /* harmony export */ alloc: () => (/* reexport safe */ _buffer__WEBPACK_IMPORTED_MODULE_7__.alloc),
1107
+ /* harmony export */ asciiToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.asciiToBytes),
1108
+ /* harmony export */ bigIntToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.bigIntToBytes),
1109
+ /* harmony export */ bytesToAscii: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.bytesToAscii),
1110
+ /* harmony export */ bytesToHex: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.bytesToHex),
1111
+ /* harmony export */ bytesToTwosBigInt: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.bytesToTwosBigInt),
1112
+ /* harmony export */ bytesToUtf8: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.bytesToUtf8),
1113
+ /* harmony export */ concatArray: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.concatArray),
1114
+ /* harmony export */ concatBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.concatBytes),
1115
+ /* harmony export */ config: () => (/* reexport safe */ _config__WEBPACK_IMPORTED_MODULE_0__.config),
1116
+ /* harmony export */ createApiKeyMiddleware: () => (/* reexport safe */ _fetch__WEBPACK_IMPORTED_MODULE_9__.createApiKeyMiddleware),
1117
+ /* harmony export */ createFetchFn: () => (/* reexport safe */ _fetch__WEBPACK_IMPORTED_MODULE_9__.createFetchFn),
1118
+ /* harmony export */ equals: () => (/* reexport safe */ _buffer__WEBPACK_IMPORTED_MODULE_7__.equals),
1119
+ /* harmony export */ fetchWrapper: () => (/* reexport safe */ _fetch__WEBPACK_IMPORTED_MODULE_9__.fetchWrapper),
1120
+ /* harmony export */ fromTwos: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.fromTwos),
1121
+ /* harmony export */ getAesCbcOutputLength: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.getAesCbcOutputLength),
1122
+ /* harmony export */ getBase64OutputLength: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.getBase64OutputLength),
1123
+ /* harmony export */ getFetchOptions: () => (/* reexport safe */ _fetch__WEBPACK_IMPORTED_MODULE_9__.getFetchOptions),
1124
+ /* harmony export */ getGlobalObject: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.getGlobalObject),
1125
+ /* harmony export */ getGlobalObjects: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.getGlobalObjects),
1126
+ /* harmony export */ getGlobalScope: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.getGlobalScope),
1127
+ /* harmony export */ hexToBigInt: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.hexToBigInt),
1128
+ /* harmony export */ hexToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.hexToBytes),
1129
+ /* harmony export */ hexToInt: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.hexToInt),
1130
+ /* harmony export */ hostMatches: () => (/* reexport safe */ _fetch__WEBPACK_IMPORTED_MODULE_9__.hostMatches),
1131
+ /* harmony export */ intToBigInt: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.intToBigInt),
1132
+ /* harmony export */ intToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.intToBytes),
1133
+ /* harmony export */ intToHex: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.intToHex),
1134
+ /* harmony export */ isInstance: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.isInstance),
1135
+ /* harmony export */ isLaterVersion: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.isLaterVersion),
1136
+ /* harmony export */ isSameOriginAbsoluteUrl: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.isSameOriginAbsoluteUrl),
1137
+ /* harmony export */ makeUUID4: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.makeUUID4),
1138
+ /* harmony export */ megabytesToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.megabytesToBytes),
1139
+ /* harmony export */ nextHour: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.nextHour),
1140
+ /* harmony export */ nextMonth: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.nextMonth),
1141
+ /* harmony export */ nextYear: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.nextYear),
1142
+ /* harmony export */ octetsToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.octetsToBytes),
1143
+ /* harmony export */ parseRecoverableSignatureVrs: () => (/* reexport safe */ _signatures__WEBPACK_IMPORTED_MODULE_5__.parseRecoverableSignatureVrs),
1144
+ /* harmony export */ privateKeyToBytes: () => (/* reexport safe */ _keys__WEBPACK_IMPORTED_MODULE_6__.privateKeyToBytes),
1145
+ /* harmony export */ readUInt16BE: () => (/* reexport safe */ _buffer__WEBPACK_IMPORTED_MODULE_7__.readUInt16BE),
1146
+ /* harmony export */ readUInt16LE: () => (/* reexport safe */ _buffer__WEBPACK_IMPORTED_MODULE_7__.readUInt16LE),
1147
+ /* harmony export */ readUInt32BE: () => (/* reexport safe */ _buffer__WEBPACK_IMPORTED_MODULE_7__.readUInt32BE),
1148
+ /* harmony export */ readUInt32LE: () => (/* reexport safe */ _buffer__WEBPACK_IMPORTED_MODULE_7__.readUInt32LE),
1149
+ /* harmony export */ readUInt8: () => (/* reexport safe */ _buffer__WEBPACK_IMPORTED_MODULE_7__.readUInt8),
1150
+ /* harmony export */ setFetchOptions: () => (/* reexport safe */ _fetch__WEBPACK_IMPORTED_MODULE_9__.setFetchOptions),
1151
+ /* harmony export */ signatureRsvToVrs: () => (/* reexport safe */ _signatures__WEBPACK_IMPORTED_MODULE_5__.signatureRsvToVrs),
1152
+ /* harmony export */ signatureVrsToRsv: () => (/* reexport safe */ _signatures__WEBPACK_IMPORTED_MODULE_5__.signatureVrsToRsv),
1153
+ /* harmony export */ toTwos: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.toTwos),
1154
+ /* harmony export */ updateQueryStringParameter: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.updateQueryStringParameter),
1155
+ /* harmony export */ utf8ToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.utf8ToBytes),
1156
+ /* harmony export */ validateHash256: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.validateHash256),
1157
+ /* harmony export */ with0x: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.with0x),
1158
+ /* harmony export */ without0x: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.without0x),
1159
+ /* harmony export */ writeUInt16BE: () => (/* reexport safe */ _buffer__WEBPACK_IMPORTED_MODULE_7__.writeUInt16BE),
1160
+ /* harmony export */ writeUInt16LE: () => (/* reexport safe */ _buffer__WEBPACK_IMPORTED_MODULE_7__.writeUInt16LE),
1161
+ /* harmony export */ writeUInt32BE: () => (/* reexport safe */ _buffer__WEBPACK_IMPORTED_MODULE_7__.writeUInt32BE),
1162
+ /* harmony export */ writeUInt32LE: () => (/* reexport safe */ _buffer__WEBPACK_IMPORTED_MODULE_7__.writeUInt32LE),
1163
+ /* harmony export */ writeUInt8: () => (/* reexport safe */ _buffer__WEBPACK_IMPORTED_MODULE_7__.writeUInt8)
1164
+ /* harmony export */ });
1165
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./config */ "./src/config.ts");
1166
+ /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./errors */ "./src/errors.ts");
1167
+ /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./logger */ "./src/logger.ts");
1168
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils */ "./src/utils.ts");
1169
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./constants */ "./src/constants.ts");
1170
+ /* harmony import */ var _signatures__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./signatures */ "./src/signatures.ts");
1171
+ /* harmony import */ var _keys__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./keys */ "./src/keys.ts");
1172
+ /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./src/buffer.ts");
1173
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./types */ "./src/types.ts");
1174
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_types__WEBPACK_IMPORTED_MODULE_8__);
1175
+ /* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
1176
+ /* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in _types__WEBPACK_IMPORTED_MODULE_8__) if(["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(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => _types__WEBPACK_IMPORTED_MODULE_8__[__WEBPACK_IMPORT_KEY__]
1177
+ /* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
1178
+ /* harmony import */ var _fetch__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./fetch */ "./src/fetch.ts");
1179
+
1180
+
1181
+
1182
+
1183
+
1184
+
1185
+
1186
+
1187
+
1188
+
1189
+
1190
+
1191
+ })();
1192
+
1193
+ /******/ return __webpack_exports__;
1194
+ /******/ })()
1195
+ ;
1196
+ });
2
1197
  //# sourceMappingURL=index.js.map