@bsv/sdk 1.7.2 → 1.7.3

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.
@@ -324,7 +324,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
324
324
  export class HTTPSOverlayLookupFacilitator implements OverlayLookupFacilitator {
325
325
  fetchClient: typeof fetch;
326
326
  allowHTTP: boolean;
327
- constructor(httpClient = fetch, allowHTTP: boolean = false)
327
+ constructor(httpClient = defaultFetch, allowHTTP: boolean = false)
328
328
  async lookup(url: string, question: LookupQuestion, timeout: number = 5000): Promise<LookupAnswer>
329
329
  }
330
330
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/sdk",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "type": "module",
5
5
  "description": "BSV Blockchain Software Development Kit",
6
6
  "main": "dist/cjs/mod.js",
@@ -1,6 +1,9 @@
1
1
  import { Transaction } from '../transaction/index.js'
2
2
  import OverlayAdminTokenTemplate from './OverlayAdminTokenTemplate.js'
3
3
 
4
+ // Only bind window.fetch in the browser
5
+ const defaultFetch = typeof window !== 'undefined' ? fetch.bind(window) : fetch
6
+
4
7
  /**
5
8
  * The question asked to the Overlay Services Engine when a consumer of state wishes to look up information.
6
9
  */
@@ -108,7 +111,7 @@ export class HTTPSOverlayLookupFacilitator implements OverlayLookupFacilitator {
108
111
  fetchClient: typeof fetch
109
112
  allowHTTP: boolean
110
113
 
111
- constructor (httpClient = fetch, allowHTTP: boolean = false) {
114
+ constructor (httpClient = defaultFetch, allowHTTP: boolean = false) {
112
115
  this.fetchClient = httpClient
113
116
  this.allowHTTP = allowHTTP
114
117
  }
@@ -368,7 +371,7 @@ export default class LookupResolver {
368
371
  }
369
372
 
370
373
  /** Evict an arbitrary “oldest” entry from a Map (iteration order). */
371
- private evictOldest<T> (m: Map<string, T>): void {
374
+ private evictOldest<T>(m: Map<string, T>): void {
372
375
  const firstKey = m.keys().next().value
373
376
  if (firstKey !== undefined) m.delete(firstKey)
374
377
  }