Skip to content

Fix Draft 4 wire, transport, stream and handshake conformance gaps - #4

Open
prateekbhujel wants to merge 1 commit into
NativePHP:mainfrom
prateekbhujel:fix/wire-transport-conformance
Open

prateekbhujel wants to merge 1 commit into
NativePHP:mainfrom
prateekbhujel:fix/wire-transport-conformance

Conversation

@prateekbhujel

Copy link
Copy Markdown

Closes a set of Asgard Protocol Draft 4 conformance gaps in the wire, transport, stream and handshake layer:

  1. Early rejections 415 and 422 (§6.3, §7.3, §8)
    AsgardClient::EARLY_REJECTIONS omitted 415 unsupported_coding and 422 unsupported_protocol (with a protocols list). During the QUERY transport probe, those unsigned rejections triggered a forbidden POST retry and were classified as invalid instead of server.

  2. Empty state encoded as {} on /render, /call and /upload (§5.1)
    RegionStreams::open() already casts empty state to (object) so it encodes as {}, but AsgardClient::call() and AsgardClient::frame() encoded PHP [] as JSON "state":[]. Both now encode empty state as {}.

  3. 419 verification failures and probe fallback session handling (§6.3, §8)
    AsgardClient::send() no longer re-handshakes and retries when a 419 response failed signature verification. During an unsettled QUERY probe, a non-Asgard 419 page no longer evicts the cached session before falling back to POST.

  4. Asgard-Cache: invalidate with cached: true, list chrome, and protocol version checks (§6.2, §7.3, §8.3, §11)
    AsgardClient now refuses {"cached": true} parts when Asgard-Cache: invalidate is set, refuses list-shaped chrome, and checks protocol === 1 on render, call, upload and routes answers. Wire::openResponse() now checks that the signed Asgard-Protocol header matches 1.

  5. SSE event envelope key order and unknown members (§5.3, §8.1)
    Wire::openEvent() required array_keys($json) === ['body', 'enc', 'sig'], rejecting events with reordered keys or extra members. It now checks required member presence and types and ignores key order and unknown members.

  6. Handshake elements limits (§6.1)
    FragmentTypes::advertised() now enforces the 64-character name limit and the 256-entry cap.

  7. Push stream version tracking and event validation (§8.1, §9.4)
    RegionStreams::receive() now advances the held subscription version only when $this->pusher returns > 0 (matching patch()), and validates event protocol, version, and from tokens.

  8. Call and upload failure reasons and delta type mismatches (§5.3, §5.4, §10.2, §10.5, §10.6)
    HttpServerTransport::answered() (shared with HttpUploadTransport) now forwards HttpFragmentSource::reasonFor() so ServerActionFailed surfaces verification failures and malformed 200 answers as invalid rather than server. ServerMethods::reconcile() catches TypeError when a delta value does not fit a typed property, refusing and logging it instead of aborting delivery.

Verification:

  • vendor/bin/pest: 955 passed, 1 skipped (4375 assertions)
  • vendor/bin/pint --test: 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.

1 participant