11// @ts -ignore
2- import { Buffer } from '@stacks/common' ;
2+ import { Buffer , fetchPrivate } from '@stacks/common' ;
33import { TokenSigner , Json } from 'jsontokens' ;
44import { getPublicKeyFromPrivate , publicKeyToAddress } from '@stacks/encryption' ;
55import randomBytes from 'randombytes' ;
@@ -13,7 +13,7 @@ interface HubInfo {
1313}
1414
1515export const getHubInfo = async ( hubUrl : string ) => {
16- const response = await fetch ( `${ hubUrl } /hub_info` ) ;
16+ const response = await fetchPrivate ( `${ hubUrl } /hub_info` ) ;
1717 const data : HubInfo = await response . json ( ) ;
1818 return data ;
1919} ;
@@ -115,16 +115,19 @@ export const uploadToGaiaHub = async (
115115) : Promise < string > => {
116116 const contentType = 'application/json' ;
117117
118- const response = await fetch ( `${ hubConfig . server } /store/${ hubConfig . address } /${ filename } ` , {
119- method : 'POST' ,
120- headers : {
121- 'Content-Type' : contentType ,
122- Authorization : `bearer ${ hubConfig . token } ` ,
123- } ,
124- body : contents ,
125- referrer : 'no-referrer' ,
126- referrerPolicy : 'no-referrer' ,
127- } ) ;
118+ const response = await fetchPrivate (
119+ `${ hubConfig . server } /store/${ hubConfig . address } /${ filename } ` ,
120+ {
121+ method : 'POST' ,
122+ headers : {
123+ 'Content-Type' : contentType ,
124+ Authorization : `bearer ${ hubConfig . token } ` ,
125+ } ,
126+ body : contents ,
127+ referrer : 'no-referrer' ,
128+ referrerPolicy : 'no-referrer' ,
129+ }
130+ ) ;
128131 const { publicURL } = await response . json ( ) ;
129132 return publicURL ;
130133} ;
0 commit comments