Skip to content

feat: add networkPrivacy user setting for NYM Mixfetch#100

Merged
samholmes merged 3 commits intomasterfrom
sam/privacy-fetch
Jan 28, 2026
Merged

feat: add networkPrivacy user setting for NYM Mixfetch#100
samholmes merged 3 commits intomasterfrom
sam/privacy-fetch

Conversation

@samholmes
Copy link
Copy Markdown
Collaborator

@samholmes samholmes commented Jan 23, 2026

Add infrastructure to enable privacy-enhanced fetch requests:

  • Add networkPrivacy field to MoneroUserSettings ('none' | 'nym')
  • Add makeEngineFetch utility to wrap fetch with dynamic options
  • Pass engineFetch to MyMoneroApi for all network requests
  • Add networkPrivacy to defaultSettings in currencyInfo

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

none

Note

Introduces optional privacy routing for network requests.

  • Adds networkPrivacy user setting ('none' | 'nym') with default 'none' to moneroTypes and moneroInfo default settings
  • Implements engineFetch in MoneroEngine to pass { privacy: 'nym' } to io.fetch when enabled; wires it into MyMoneroApi
  • Updates tests to include new callback signatures; housekeeping adds .prettierrc and CHANGELOG entry
  • Bumps edge-core-js to ^2.41.0 (and lockfile), pulling in @nymproject/mix-fetch support

Written by Cursor Bugbot for commit 94390ca. This will update automatically on new commits. Configure here.


Comment on lines +125 to +126
// Type assertion for WIP mixfetch feature in edge-core-js
return networkPrivacy === 'nym' ? ({ privacy: 'nym' } as any) : {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updot edge-core-js before merging, and then the any can go away.

src/utils.ts Outdated
Comment on lines +13 to +19
export function makeEngineFetch(
io: EdgeIo,
getInitOverload: () => EdgeFetchOptions = () => ({})
): EdgeFetchFunction {
return async (input, init) => {
const initOverload = getInitOverload()
const enhancedInit = { ...initOverload, ...init }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this guy is only called in one place, I would just put it inline in the constructor:

this.engineFetch = async (url, init) => await this.io.fetch(url, {
  ...init,
  privacy: this.currentSettings.privacy ? ...
})

It's like 1 line rather than 20, and much easier to understand.

Copy link
Copy Markdown
Contributor

@swansontec swansontec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a one-liner left to fix.


this.engineFetch = makeEngineFetch(env.io, () => {
this.engineFetch = async (uri, init) => {
const { networkPrivacy } = this.currentSettings
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in the other PR, this.currentSettings?.networkPrivacy would be safer.

@samholmes samholmes force-pushed the sam/privacy-fetch branch 2 times, most recently from c409480 to d717e77 Compare January 28, 2026 00:03
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

...(networkPrivacy === 'nym' ? { privacy: 'nym' } : {}),
...init
})
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Privacy setting can be overridden by init options

Low Severity

The engineFetch wrapper spreads the privacy option before init, allowing any privacy field in init to override the user's networkPrivacy setting. The spread order is backwards—the user's privacy preference from currentSettings should take precedence by being spread after init, not before. While MyMoneroApi currently doesn't pass a privacy field in its init object, this doesn't match the intended behavior where the user's setting should always apply.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature not a bug.

Add infrastructure to enable privacy-enhanced fetch requests:
- Add networkPrivacy field to MoneroUserSettings ('none' | 'nym')
- Add makeEngineFetch utility to wrap fetch with dynamic options
- Pass engineFetch to MyMoneroApi for all network requests
- Add networkPrivacy to defaultSettings in currencyInfo
@samholmes samholmes merged commit 46c00d5 into master Jan 28, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants