Skip to content

Conversation

@wjmelements
Copy link
Collaborator

Reviewer @rvagg
This allows the user to enter a hex string prefixed with 0x and it will be encoded as bytes.
Hex encoding is good for:

Changes

If a capability value string is hex, encode the bytes directly rather than as utf8

@wjmelements wjmelements requested a review from a team as a code owner November 25, 2025 21:34
@wjmelements wjmelements requested a review from rvagg November 25, 2025 21:34
@wjmelements wjmelements added enhancement New feature or request team/fs-wg Items being worked on or tracked by the "FS Working Group". See FilOzone/github-mgmt #10 labels Nov 25, 2025
@FilOzzy FilOzzy added this to FS Nov 25, 2025
@github-project-automation github-project-automation bot moved this to 📌 Triage in FS Nov 25, 2025
@wjmelements wjmelements changed the title feat: Hex Capabilities feat!(ServiceProviderRegistry): Hex Capabilities Nov 26, 2025
@wjmelements wjmelements requested a review from Kubuxu November 26, 2025 09:17
@Kubuxu
Copy link
Collaborator

Kubuxu commented Nov 26, 2025

What about the decode? It seems to me that UI might try displaying garbage or messing (UTF normalisation) with it, resulting in the capability getting corrupted on a round-trip.

@wjmelements
Copy link
Collaborator Author

What about the decode? It seems to me that UI might try displaying garbage or messing (UTF normalisation) with it, resulting in the capability getting corrupted on a round-trip.

This is a good point. Indeed it is hard to know the types of additional fields. Etherscan handles this by showing untyped data in hex by default and providing buttons for the user to decode it via utf8 or bigendian. Let me know what you think!

@Kubuxu
Copy link
Collaborator

Kubuxu commented Nov 26, 2025

The issue is as follows:

  • user adds endoresment, it gets decoded and submitted on chain (endoresement is valid)
  • user wants to modify another capability, this leads to us fetching capabilities, and putting them into JS strings, which corrupts them (https://kagi.com/assistant/43fe3cd4-4ca0-4dee-9b5c-ff122d8b8fa8)
  • user submits that edit (endoresement becomes invalid as it was corrupted

I think the simplest way to avoid this, is to keep raw bytes of unedited keys.

@github-project-automation github-project-automation bot moved this from 📌 Triage to ✔️ Approved by reviewer in FS Dec 1, 2025
@rvagg
Copy link
Member

rvagg commented Dec 1, 2025

ok, approved without reading the full thread, good points

I think the simplest way to avoid this, is to keep raw bytes of unedited keys

how do you propose to do this? we'd need to plumb through an "edited" status which complicates the UI somewhat

how about just using unicode.IsPrint to figure out if a string has printable characters, if it doesn't, hex it to display it, then the round-trip should ~work. If the certificate happens to be printable then that's fine too, no need to hex for a round-trip.

@rvagg
Copy link
Member

rvagg commented Dec 1, 2025

Or here's an alternative - do it in the UI, pass all of the capabilities to the UI (whatever's easiest to get a Uint8Array into the browser using the stack Curio uses to pass that), then do a round-trip in the browser using TextEncoder and TextDecoder, if the round-trip doesn't yield the original bytes then hex display the bytes, otherwise the stringified version.

@wjmelements
Copy link
Collaborator Author

I don't think any certs will be printable because they have zero-bytes which decode into the null terminator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request team/fs-wg Items being worked on or tracked by the "FS Working Group". See FilOzone/github-mgmt #10

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants