Skip to content

Commit 9908cf4

Browse files
authored
Merge pull request #369 from bsv-blockchain/fix/default-fetch-binding
Fix/default fetch binding
2 parents 862ed89 + 886ea78 commit 9908cf4

File tree

6 files changed

+43
-7
lines changed

6 files changed

+43
-7
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. The format
55
## Table of Contents
66

77
- [Unreleased](#unreleased)
8+
- [1.8.9 - 2025-10-27](#189---2025-10-27)
89
- [1.8.8 - 2025-10-22](#188---2025-10-22)
910
- [1.8.7 - 2025-10-22](#187---2025-10-22)
1011
- [1.8.5 - 2025-10-21](#185---2025-10-21)
@@ -168,6 +169,14 @@ All notable changes to this project will be documented in this file. The format
168169

169170
---
170171

172+
### [1.8.9] - 2025-10-27
173+
174+
### Fixed
175+
176+
- Default fetch binding now works in more environments.
177+
178+
---
179+
171180
### [1.8.8] - 2025-10-22
172181

173182
### Added

docs/reference/kvstore.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ export interface KVStoreQuery {
248248
controller?: PubKeyHex;
249249
protocolID?: WalletProtocol;
250250
tags?: string[];
251+
tagQueryMode?: "all" | "any";
251252
limit?: number;
252253
skip?: number;
253254
sortOrder?: "asc" | "desc";
@@ -256,6 +257,16 @@ export interface KVStoreQuery {
256257

257258
See also: [PubKeyHex](./wallet.md#type-pubkeyhex), [WalletProtocol](./wallet.md#type-walletprotocol)
258259

260+
#### Property tagQueryMode
261+
262+
Controls tag matching behavior when tags are specified.
263+
- 'all': Requires all specified tags to be present (default)
264+
- 'any': Requires at least one of the specified tags to be present
265+
266+
```ts
267+
tagQueryMode?: "all" | "any"
268+
```
269+
259270
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
260271

261272
---

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bsv/sdk",
3-
"version": "1.8.8",
3+
"version": "1.8.9",
44
"type": "module",
55
"description": "BSV Blockchain Software Development Kit",
66
"main": "dist/cjs/mod.js",

src/auth/transports/SimplifiedFetchTransport.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import { AuthMessage, RequestedCertificateSet, Transport } from '../types.js'
44
import * as Utils from '../../primitives/utils.js'
55

6-
// Only bind window.fetch in the browser
7-
const defaultFetch = typeof window !== 'undefined' ? fetch.bind(window) : fetch
6+
const defaultFetch: typeof fetch =
7+
typeof globalThis !== 'undefined' && typeof globalThis.fetch === 'function'
8+
? globalThis.fetch.bind(globalThis)
9+
: fetch
810

911
/**
1012
* Implements an HTTP-specific transport for handling Peer mutual authentication messages.
@@ -21,6 +23,12 @@ export class SimplifiedFetchTransport implements Transport {
2123
* @param fetchClient - A fetch implementation to use for HTTP requests (default: global fetch).
2224
*/
2325
constructor (baseUrl: string, fetchClient = defaultFetch) {
26+
if (typeof fetchClient !== 'function') {
27+
throw new Error(
28+
'SimplifiedFetchTransport requires a fetch implementation. ' +
29+
'In environments without fetch, provide a polyfill or custom implementation.'
30+
)
31+
}
2432
this.fetchClient = fetchClient
2533
this.baseUrl = baseUrl
2634
}

src/overlay-tools/LookupResolver.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { Transaction } from '../transaction/index.js'
22
import OverlayAdminTokenTemplate from './OverlayAdminTokenTemplate.js'
33
import * as Utils from '../primitives/utils.js'
44

5-
// Only bind window.fetch in the browser
6-
const defaultFetch = typeof window !== 'undefined' ? fetch.bind(window) : fetch
5+
const defaultFetch: typeof fetch =
6+
typeof globalThis !== 'undefined' && typeof globalThis.fetch === 'function'
7+
? globalThis.fetch.bind(globalThis)
8+
: fetch
79

810
/**
911
* The question asked to the Overlay Services Engine when a consumer of state wishes to look up information.
@@ -113,6 +115,12 @@ export class HTTPSOverlayLookupFacilitator implements OverlayLookupFacilitator {
113115
allowHTTP: boolean
114116

115117
constructor (httpClient = defaultFetch, allowHTTP: boolean = false) {
118+
if (typeof httpClient !== 'function') {
119+
throw new Error(
120+
'HTTPSOverlayLookupFacilitator requires a fetch implementation. ' +
121+
'In environments without fetch, provide a polyfill or custom implementation.'
122+
)
123+
}
116124
this.fetchClient = httpClient
117125
this.allowHTTP = allowHTTP
118126
}

0 commit comments

Comments
 (0)