edge-core-js 2.43.2 → 2.43.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.
@@ -3,7 +3,7 @@
3
3
  import { makeLog } from '../../core/log/log'
4
4
 
5
5
  import { scrypt } from '../../util/crypto/scrypt'
6
- import { initMixFetch, queueMixFetch } from '../../util/nym'
6
+ import { queueMixFetch } from '../../util/nym'
7
7
  import { fetchCorsProxy } from './fetch-cors-proxy'
8
8
 
9
9
  // Only try CORS proxy/bridge techniques up to 5 times
@@ -49,13 +49,16 @@ export function makeBrowserIo(logBackend) {
49
49
  const { corsBypass = 'auto', privacy = 'none' } = _nullishCoalesce(opts, () => ( {}))
50
50
 
51
51
  if (privacy === 'nym') {
52
- // Ensure mixFetch is initialized before use
53
- await initMixFetch(log)
54
52
  // Use queued fetch to handle mixFetch's one-request-per-host limitation
55
- return await queueMixFetch(uri, {
56
- ...opts,
57
- mode: 'unsafe-ignore-cors'
58
- })
53
+ // initMixFetch is called within queueMixFetch
54
+ return await queueMixFetch(
55
+ uri,
56
+ {
57
+ ...opts,
58
+ mode: 'unsafe-ignore-cors'
59
+ },
60
+ log
61
+ )
59
62
  }
60
63
  if (corsBypass === 'always') {
61
64
  return await fetchCorsProxy(uri, opts)
@@ -17,7 +17,7 @@ import { makeLog } from '../../core/log/log'
17
17
 
18
18
 
19
19
 
20
- import { initMixFetch, queueMixFetch } from '../../util/nym'
20
+ import { queueMixFetch } from '../../util/nym'
21
21
  import { hideProperties } from '../hidden-properties'
22
22
  import { makeNativeBridge } from './native-bridge'
23
23
  import { YAOB_THROTTLE_MS } from './react-native-types'
@@ -176,13 +176,16 @@ async function makeIo(logBackend) {
176
176
  const { corsBypass = 'auto', privacy = 'none' } = _nullishCoalesce(opts, () => ( {}))
177
177
 
178
178
  if (privacy === 'nym') {
179
- // Ensure mixFetch is initialized before use
180
- await initMixFetch(log)
181
179
  // Use queued fetch to handle mixFetch's one-request-per-host limitation
182
- const response = await queueMixFetch(uri, {
183
- ...opts,
184
- mode: 'unsafe-ignore-cors'
185
- })
180
+ // initMixFetch is called within queueMixFetch
181
+ const response = await queueMixFetch(
182
+ uri,
183
+ {
184
+ ...opts,
185
+ mode: 'unsafe-ignore-cors'
186
+ },
187
+ log
188
+ )
186
189
  return response
187
190
  }
188
191
  if (corsBypass === 'always') {
package/lib/util/nym.js CHANGED
@@ -1,7 +1,8 @@
1
1
  function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }import {
2
2
  createMixFetch,
3
+ disconnectMixFetch,
4
+
3
5
 
4
- mixFetch,
5
6
 
6
7
  } from '@nymproject/mix-fetch'
7
8
 
@@ -11,6 +12,7 @@
11
12
  * Configuration options for the NYM mixFetch client.
12
13
  */
13
14
  export const mixFetchOptions = {
15
+ clientId: 'edge-core-js-2026-03-10',
14
16
  preferredGateway: '5rXcNe2a44vXisK3uqLHCzpzvEwcnsijDMU7hg4fcYk8', // with WSS
15
17
  preferredNetworkRequester:
16
18
  '5x6q9UfVHs5AohKMUqeivj7a556kVVy7QwoKige8xHxh.6CFoB3kJaDbYz6oafPJxNxNjzahpT2NtgtytcSyN9EvF@5rXcNe2a44vXisK3uqLHCzpzvEwcnsijDMU7hg4fcYk8',
@@ -46,21 +48,29 @@ function getHostKey(uri) {
46
48
  * Safe to call multiple times - subsequent calls return the same promise.
47
49
  */
48
50
  export async function initMixFetch(log) {
49
- // Return existing promise if already initializing or initialized
50
51
  if (mixFetchInitPromise == null) {
51
52
  log('Initializing mixFetch...')
52
53
  mixFetchInitPromise = createMixFetch(mixFetchOptions)
53
- .then(mixFetch => {
54
+ .then(mixFetchModule => {
54
55
  log('mixFetch initialized successfully')
55
- return mixFetch
56
+ return mixFetchModule
56
57
  })
57
- .catch(error => {
58
+ .catch(async error => {
59
+ // Clean up stale global state left by the failed init so the
60
+ // next createMixFetch call starts fresh instead of reusing a
61
+ // broken singleton.
62
+ try {
63
+ await disconnectMixFetch()
64
+ } catch (e2) {}
65
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
66
+ delete (window ).__mixFetchGlobal
58
67
  mixFetchInitPromise = null
59
68
  log.error('mixFetch initialization failed:', error)
60
69
  throw error
61
70
  })
62
71
  }
63
- return await mixFetchInitPromise
72
+ const mixFetchModule = await mixFetchInitPromise
73
+ return mixFetchModule.mixFetch
64
74
  }
65
75
 
66
76
  /**
@@ -69,7 +79,8 @@ export async function initMixFetch(log) {
69
79
  */
70
80
  export async function queueMixFetch(
71
81
  uri,
72
- opts
82
+ opts,
83
+ log
73
84
  ) {
74
85
  const hostKey = getHostKey(uri)
75
86
 
@@ -79,7 +90,14 @@ export async function queueMixFetch(
79
90
  // Chain our request after the previous one
80
91
  const ourWork = previousChain
81
92
  .catch(() => {}) // Ignore errors from previous request
82
- .then(async () => await mixFetch(uri, opts, mixFetchOptions))
93
+ .then(async () => {
94
+ const nymMixFetch = await initMixFetch(log)
95
+ return await nymMixFetch(uri, opts, mixFetchOptions)
96
+ })
97
+ .catch(error => {
98
+ log.error(`Error in queueMixFetch for host ${hostKey}:`, error)
99
+ throw error
100
+ })
83
101
  .finally(() => {
84
102
  // Clean up if we're still the chain tail
85
103
  if (hostRequestChains.get(hostKey) === ourWork) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-core-js",
3
- "version": "2.43.2",
3
+ "version": "2.43.3",
4
4
  "description": "Edge account & wallet management library",
5
5
  "keywords": [
6
6
  "bitcoin",