Repository navigation
Match @bsv/sdk 4.1.1 UHRP, registry, identity and KVStore tokens - #17
Merged
Merged
Conversation
Live overlay hosts run the TypeScript topic managers, so the token shapes now follow @bsv/sdk 4.1.1. - UHRP: new UHRPAdvertisement decodes the six-field signed advertisement (host key, hash, URL, expiry, size, signature) and checks the BRC-42 link to the host under [2, "uhrp advertisement"]. The downloader uses it and sends limit and offset in the ls_uhrp query. uhrp:<id> now parses. - Registry: tokens carry the operator signature (7/7/8 fields) under [1, "basketmap"|"protomap"|"certmap"], key ID "1", counterparty anyone. Decoding checks key linkage and signature; encoding signs with the wallet. Certificate field JSON is read in any key order. - Identity: default protocol is [1, "identity"] and public reveal always proves to the anyone key. Badge links match TypeScript. - KVStore: tokens are [value, signature] under [2, context], key, self, with a 2 MiB value limit. One-field tokens are rejected.
…tail - Registry decode and encode apply the TypeScript token bounds (16 KiB per field, 64 KiB total, signature included) whatever RegistryLimits says. - A registry data field written as OP_0 is rejected, as TypeScript reads it as "\0" and refuses it. Empty-field errors name the field. - UHRP, registry and KVStore verification accept high-S signatures, as TypeScript does. DER stays strict. - UHRPDownloader keeps why each advertisement was skipped and why each host failed. advertisements(for:) returns both lists; noAvailableHosts and allHostsFailed carry them, with a short description and the full list in debugDescription. - RegistryError.pushDropFailure carries its PushDropError, and a failed round-trip throws roundTripMismatch instead of invalidSignature. - KVStore locator wallet conversions throw invalidWalletLocator, and the unowned decode overload says plainly that it proves no ownership. - Superseded one-field KVStore text in COMP-056, GoSDK-v1.3.3.md and Roadmap.md is marked or updated.
Frozen scripts produced by @bsv/sdk 4.1.1 (ts-stack 3b1abc569) under bun with PrivateKey(42), each checked by the TypeScript validator: a UHRP advertisement, basket, protocol and certificate registry tokens (with certificate field JSON out of byte order), a LocalKVStore token, and the [1, "identity"] reveal locking key. The generating TypeScript is in each test's doc comment. Swift decodes every script, and its wallet path derives the same locking key. The basket, protocol and KVStore scripts Swift writes are byte for byte the TypeScript ones.
Brings in plain-word error descriptions with full logs (PR 15) and the merkle path and ASM compatibility work (PR 16). UHRPDownloader keeps both sides: each failed host and each skipped advertisement is logged through NetworkLog and also kept in the noAvailableHosts(rejected:) and allHostsFailed(_:) payloads. Following PR 15, UHRPDownloadError, UHRPAdvertisementError, RegistryError and KVStoreError now give a short plain sentence as errorDescription, while String(reflecting:) keeps the full detail for logs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: Swift's UHRP advertisements, registry entries, identity reveals and KVStore tokens used layouts that the TS topic managers reject, so files, registry definitions and identities published from Swift did not show up for TS clients and the reverse.
After: all four token types use the @bsv/sdk 4.1.1 layouts, and Swift decodes six token scripts generated by TS 4.1.1 (and writes byte-identical basket, protocol and KVStore tokens).
How: new signed codecs that follow the TS validators, wallet-signed encoders, and frozen TS vectors in the tests.
Behaviour changes
BSVStorage.UHRPAdvertisementwith the TS six-field signed layout (host key, hash, HTTPS URL, expiry, size, signature; locking key linked to the host under2-uhrp advertisement-1).UHRPDownloaderchecks hash and expiry and sends{"uhrpUrl","limit","offset"}.UHRPURLacceptsuhrp:<id>.IdentityClientOptionsdefaults to[1,"identity"]; public reveals always prove to the anyone key (verifier:parameter removed); badge links match TS.[value, signature]under[2, context], one-field tokens are rejected, values are capped at 2 MiB; new async wallet write and owner-checked decode.API breaks
noAvailableHosts→noAvailableHosts(rejected:),allHostsFailed→allHostsFailed(_:). NewUHRPAdvertisementRejection,UHRPHostFailure,UHRPAdvertisementLookup,advertisements(for:).pushDropFailurecarries itsPushDropError; newroundTripMismatch,emptyField(name:),textTooLong,aggregateTooLarge,maximumTokenFieldByteCount,maximumTokenPayloadByteCount,fieldNames(for:); encoders are async.invalidWalletLocator.publiclyRevealAttributes(Simple)lose theverifier:parameter.All new and changed errors have plain-word
errorDescriptions in the style of PR 15, with full detail kept for logs.Testing
swift testin swift:6.1 (Linux) after merging main: 876 tests passed, XCTest 154 passed, 0 failures; only live and opt-in tests skipped.check-public-api.shclean.