Repository navigation
BSVAuth and wallet crypto accept 16 MiB payloads, as the TS AuthFetch does - #19
Merged
Merged
Conversation
… does AuthLimits.maximumPayloadBytes and BRC104Limits.maximumPayloadBytes defaulted to 1 MiB, so a wallet storage reply over 1 MiB was refused with BRC104HTTPFramingError.resourceLimit before it was read. After a 180 KB image inscription the harness saw createAction and beginActionBatch replies of 1,328,943 and 1,330,479 bytes. TS AuthFetch sends request frames up to 16 MiB (MAX_AUTH_HTTP_REQUEST_FRAME_BYTES), reads response bodies up to 16 MiB (DEFAULT_SIMPLIFIED_FETCH_MAX_RESPONSE_BYTES), and MAX_AUTH_MESSAGE_BYTES is 16 MiB. Both defaults are now 16 MiB. BRC-103 signs and verifies each general message's whole payload through the wallet, and WalletCryptoLimits capped signature data at 1 MiB, so a larger payload still failed with payloadTooLarge. The TS ProtoWallet sets no bound there; the default is now 16 MiB as well.
On Darwin an XCTestCase is an NSObject, whose hash is an Int, so a [UInt8] property named hash cannot override it. Linux builds it because there XCTestCase is not an NSObject.
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
After a large image inscribe (180 KB), the next action failed with
BSVAuth.BRC104HTTPFramingError.resourceLimit. The live harness (swift-1sat-sdk PR #55) loggedcreateActionandbeginActionBatchreplies of 1,328,943 and 1,330,479 bytes.AuthLimits.maximumPayloadBytesandBRC104Limits.maximumPayloadBytesboth defaulted to1 << 20, soBRC104HTTPResponseFramerefused any body over 1 MiB before reading it.With the framing raised alone, a payload over 1 MiB still failed. BRC-103 signs and verifies each general message's whole payload through the wallet, and
WalletCryptoLimits.standardcapped signature data at 1 MiB. The test below then hitpayloadTooLarge(actual: 1048679, maximum: 1048576).After
The defaults now follow the TS SDK (
@bsv/sdk4.1.0):AuthLimits.maximumPayloadBytesMAX_AUTH_MESSAGE_BYTES,MAX_AUTH_HTTP_REQUEST_FRAME_BYTESBRC104Limits.maximumPayloadBytes(and soBRC104HTTPFramingLimits.standard)DEFAULT_SIMPLIFIED_FETCH_MAX_RESPONSE_BYTESWalletCryptoLimits.maximumPayloadByteCount(ciphertext = payload + 48)ProtoWallet.createSignature/verifySignatureset no boundThe toolbox fix (swift-wallet-toolbox PR #56) keeps these replies small in the first place by asking for base64 bytes on every call. This change makes a reply TS accepts acceptable here too.
Other framing differences from TS (found, not changed here)
BRC104Limits). Swift allows 64 headers, 256-byte names, 8 KiB values and 64 KiB in total.AuthFetchandSimplifiedFetchTransportallow 512, 1,024 bytes, 32 KiB and 256 KiB. Swift is stricter.BRC104HTTPFramingLimits). Swift also bounds every HTTP header, signed or not: 128 headers, 256-byte names. TS bounds only the signed ones.maxResponseBytes+ 512 KiB of framing (MAX_AUTH_RESPONSE_FRAME_OVERHEAD_BYTES). Swift uses one 16 MiB cap for the whole payload, so a response body within a few hundred bytes of 16 MiB is refused here.AuthLimits.maximumJSONBytesis 8 MiB. TS caps the handshake response at 1 MiB (DEFAULT_SIMPLIFIED_FETCH_MAX_HANDSHAKE_RESPONSE_BYTES).PeerAuthenticator.makeGeneralMessagethrowsnotAuthenticated, notresourceLimit.None of these affects wallet storage traffic today.
How
AuthModels.swift,BRC104Payload.swiftandWalletCryptoLimits.swift. Each has a doc comment naming the TS constant it follows.BRC104HTTPFramingTests:payloadsOverOneMebibyte: a 1 MiB + 1 request body and a 1,330,479-byte response body are signed, framed, decoded and verified throughPeerAuthenticatorandProtoWalletwith default limits.sixteenMebibyteBoundary: a response payload of exactly 16 MiB encodes and decodes. One byte more is refused by the codec and byBRC104HTTPResponseFrame.testCryptoLimitsValidationchecks the new standard.ProtoWalletwith an explicit 1 MiB limit, so it still exercises that path.UHRPAdvertisementTestsdeclared aprivate let hash: [UInt8]. On Darwin,XCTestCaseis anNSObject, so this clashed withNSObject.hash: Int, and the test target did not compile (property 'hash' with type '[UInt8]' cannot override a property with type 'Int').main614a838 failsSwift 6.1 / macos-15the same way. The property is nowcontentHash. Linux was never affected.swift testinswift:6.1-noble(docker): 878 Swift Testing tests passed (3 skipped: live network and scale tests), and 154 XCTest tests with 0 failures.