Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 25 additions & 20 deletions openapi/Swarm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -979,9 +979,12 @@ paths:
get:
summary: Subscribe to a BPS cohort
description: |
WebSocket. The node joins the cohort `keccak256(keccak256("bps-claim" | topic) | owner)`
at `broker` and sends every broadcast as a binary frame with the full SOC bytes
(`id | signature | span | payload`). Broadcasts not signed by `owner` are dropped.
WebSocket. The node joins the BPS-lite (SWIP-74) cohort `{topic, FEED_TOPIC, owner}`
at `broker` as `identity` and sends every update as a binary frame
`challenge (32) | index (8, big-endian) | soc`, where `soc` is the full single-owner
chunk (`id | signature | span | payload`) signed by `owner` with
`id = keccak256(keccak256(topic | challenge) | index)`. Updates that do not verify,
or whose index is below the subscriber's cursor, are dropped.
The endpoint is read-only: any client frame closes the socket with 4002.
Close codes: 4002 invalid message, 4003 broker stream closed.
tags:
Expand Down Expand Up @@ -1011,6 +1014,12 @@ paths:
$ref: "SwarmCommon.yaml#/components/schemas/EthereumAddress"
required: true
description: Ethereum address identifying the joiner.
- in: query
name: cursor
schema:
type: integer
required: false
description: Lowest update index to deliver. Defaults to 0.
responses:
"200":
description: Establishes a WebSocket subscription for incoming broadcasts
Expand All @@ -1025,20 +1034,22 @@ paths:

"/bps/publish/{owner}/{topic}":
get:
summary: Claim and publish to a BPS cohort
summary: Publish to a BPS cohort as its principal
description: |
WebSocket. Text frames carry JSON control messages; binary frames carry SOCs.
WebSocket. The node joins the BPS-lite (SWIP-74) cohort `{topic, FEED_TOPIC, owner}`
at `broker` declaring `owner` as its address.

1. Server sends `{"type":"challenge","challenge":"<hex>","broker":"<hex>","id":"<hex>"}`.
2. Client signs a SOC with `id` wrapping the payload `challenge | broker` and sends
`{"type":"claim","signature":"<hex 65 bytes, no 0x prefix>"}` within 30 seconds.
3. Server verifies the claim locally, forwards it to the broker and sends
`{"type":"claim_sent"}`. This does not mean the broker accepted it; a rejection
closes the socket with 4003.
4. Client sends each broadcast as a binary frame containing a full SOC at the cohort address.
1. Server sends `{"type":"challenge","challenge":"<hex>","broker":"<hex>","dataTopic":"<hex>","authTopic":"<hex>"}`.
`dataTopic` is `keccak256(topic | challenge)`, the session feed for updates;
`authTopic` is `keccak256("bps-service:v1" | 0x02 | topic | challenge)`.
2. Client sends binary frames `kind (1) | index (8, big-endian) | soc`, where `kind` is
1 (DATA) or 2 (AUTH) and `soc` is a single-owner chunk signed by `owner` with
`id = keccak256(sessionTopic | index)`. An AUTH chunk is empty and only authenticates
the stream. The first frame must arrive within 30 seconds. Indexes must not be reused
across sessions; frames below the broker's cursor are dropped silently.

Close codes: 4001 invalid claim, 4002 invalid message (bad SOC, wrong frame type,
claim timeout), 4003 broker stream closed.
Close codes: 4001 invalid soc, 4002 invalid message (wrong frame type, unknown kind,
auth timeout), 4003 broker stream closed.
tags:
- BPS
parameters:
Expand All @@ -1060,12 +1071,6 @@ paths:
$ref: "SwarmCommon.yaml#/components/schemas/SwarmAddress"
required: true
description: Overlay address of the broker node. Must not be this node.
- in: query
name: identity
schema:
$ref: "SwarmCommon.yaml#/components/schemas/EthereumAddress"
required: true
description: Ethereum address identifying the joiner.
responses:
"200":
description: Establishes a WebSocket subscription for publishing broadcasts
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
mockac "github.com/ethersphere/bee/v2/pkg/accesscontrol/mock"
accountingmock "github.com/ethersphere/bee/v2/pkg/accounting/mock"
"github.com/ethersphere/bee/v2/pkg/api"
"github.com/ethersphere/bee/v2/pkg/bps"
"github.com/ethersphere/bee/v2/pkg/crypto"
"github.com/ethersphere/bee/v2/pkg/feeds"
"github.com/ethersphere/bee/v2/pkg/file/pipeline"
Expand Down Expand Up @@ -95,7 +96,7 @@ type testServerOptions struct {
Resolver resolver.Interface
Pss pss.Interface
Gsoc gsoc.Listener
Bps api.BPSService
Bps bps.Interface
WsPath string
WsPingPeriod time.Duration
Logger log.Logger
Expand Down
Loading
Loading