From b0046eae42e537385becd11f63e1dd295d11f703 Mon Sep 17 00:00:00 2001 From: alexcos20 Date: Sat, 21 Nov 2026 00:51:10 +0200 Subject: [PATCH 1/5] http root endpoint returns node status --- docs/API.md | 33 ++++++++++++---- docs/Ocean Node.postman_collection.json | 2 +- src/components/httpRoutes/rootEndpoint.ts | 46 +++++++++++++++-------- 3 files changed, 57 insertions(+), 24 deletions(-) diff --git a/docs/API.md b/docs/API.md index 4daca5175..7059fe1fc 100644 --- a/docs/API.md +++ b/docs/API.md @@ -323,8 +323,9 @@ returns decrypted document > decrypterAddress + nonce + "decryptDDO" + issuerPeerId + chainId + transactionId + dataNftAddress > ``` > -> - `issuerPeerId` is the **target (decrypting) node's own peerId** — i.e. the `nodeId` returned -> by that node's root `GET /` endpoint. A signature minted for node A is rejected by node B. +> - `issuerPeerId` is the **target (decrypting) node's own peerId** — i.e. the `id` returned +> by that node's root `GET /` endpoint (the status object). A signature minted for node A is +> rejected by node B. > - `chainId`, `transactionId`, `dataNftAddress` bind the signature to a single decrypt. > - `nonce` is a client-local monotonic value (the Indexer uses `Date.now()`); the node no longer > fetches a nonce from the (untrusted) `decryptorURL`. @@ -985,21 +986,37 @@ byte-identical `address + nonce + "createAuthToken" + issuerPeerId`. ## Status +### `HTTP` GET / + ### `HTTP` POST /directCommand ### `P2P` command: status #### Description -returns status of node +returns status of node. + +The node's root `GET /` endpoint is the HTTP alias of this command: it dispatches the same `status` +command and returns the same object (previously it returned only a small subset — `nodeId`, +`providerAddress`, `nodePublicKey`, `software`, `version` — which has been replaced by the full status +body). It defaults to the **basic** status; pass `?detailed=true` for the extended status +(`c2dClusters` + `supportedSchemas`), mirroring the P2P `status` vs `detailedStatus` split. The +OJ-03 challenge is supported via `?clientChallenge=...`. + +``` +GET / +GET /?detailed=true +GET /?clientChallenge=a-fresh-random-hex-string +``` #### Parameters -| name | type | required | description | -| --------------- | ------ | -------- | --------------------------------------------------------------------------------- | -| command | string | v | command name | -| node | string | | if not present it means current node | -| clientChallenge | string | | OJ-03: when present, the node returns `signedChallenge` proving its peerId (below) | +| name | type | required | description | +| --------------- | ------- | -------- | ---------------------------------------------------------------------------------- | +| command | string | v | command name (POST /directCommand / P2P only) | +| node | string | | if not present it means current node | +| detailed | boolean | | when true, includes `c2dClusters` + `supportedSchemas` (query param on `GET /`) | +| clientChallenge | string | | OJ-03: when present, the node returns `signedChallenge` proving its peerId (below) | #### Request diff --git a/docs/Ocean Node.postman_collection.json b/docs/Ocean Node.postman_collection.json index 91a43ffb5..c86397433 100644 --- a/docs/Ocean Node.postman_collection.json +++ b/docs/Ocean Node.postman_collection.json @@ -100,7 +100,7 @@ "" ] }, - "description": "Returns node identity (nodeId, chainIds, providerAddress, nodePublicKey, software, version)." + "description": "Returns the full node status (the same object as the `status` command: id, publicKey, address, version, provider, indexer, platform, authTokenPolicy, p2pStatus, ...). Add `?detailed=true` for the extended status (c2dClusters + supportedSchemas), or `?clientChallenge=` for the OJ-03 signedChallenge proof." } } ] diff --git a/src/components/httpRoutes/rootEndpoint.ts b/src/components/httpRoutes/rootEndpoint.ts index 16419ab94..07022b26d 100644 --- a/src/components/httpRoutes/rootEndpoint.ts +++ b/src/components/httpRoutes/rootEndpoint.ts @@ -1,19 +1,35 @@ -import express from 'express' -import { HTTP_LOGGER } from '../../utils/logging/common.js' +import express, { Request, Response } from 'express' +import { Readable } from 'stream' +import { StatusHandler } from '../core/handler/statusHandler.js' +import { PROTOCOL_COMMANDS } from '../../utils/constants.js' +import { StatusCommand } from '../../@types/commands.js' + export const rootEndpointRoutes = express.Router() -rootEndpointRoutes.get('/', (req, res) => { - const config = req.oceanNode.getConfig() - if (!config.supportedNetworks) { - HTTP_LOGGER.debug(`Supported networks not defined`) +// The root endpoint is the HTTP mirror of the `status` command (the same object returned over +// P2P / `/directCommand`). It defaults to the BASIC status to keep this frequently-hit path +// cheap for health checks; `?detailed=true` opts into the extended status (c2dClusters + +// supportedSchemas), mirroring the P2P `status` vs `detailedStatus` split. `?clientChallenge=...` +// (OJ-03) is forwarded so a client can prove the node controls the key its peerId commits to. +rootEndpointRoutes.get('/', async (req: Request, res: Response): Promise => { + const detailed = String(req.query.detailed).toLowerCase() === 'true' + const clientChallenge = req.query.clientChallenge + ? String(req.query.clientChallenge) + : undefined + const command: StatusCommand = { + command: PROTOCOL_COMMANDS.STATUS, + node: req.oceanNode.getKeyManager().getPeerId().toString(), + detailed, + clientChallenge, + caller: req.caller + } + const result = await new StatusHandler(req.oceanNode).handle(command) + if (result.stream) { + // The handler already emits a formatted JSON string stream; pipe it straight through + // instead of buffering and re-serializing via res.json(). + res.type('application/json') + ;(result.stream as Readable).pipe(res) + } else { + res.status(result.status.httpStatus).send(result.status.error) } - const keyManager = req.oceanNode.getKeyManager() - res.json({ - nodeId: keyManager.getPeerId().toString(), - chainIds: config.supportedNetworks ? Object.keys(config.supportedNetworks) : [], - providerAddress: keyManager.getEthAddress(), - nodePublicKey: keyManager.getPublicKey(), - software: 'Ocean-Node', - version: '0.0.1' - }) }) From 10b053da109e9d7faf201df5f84524dbcecf7d96 Mon Sep 17 00:00:00 2001 From: Alex Coseru Date: Sat, 21 Nov 2026 00:59:54 +0200 Subject: [PATCH 2/5] Add 'feat/scoped-auth-tokens' based PRs to docker build --- .github/workflows/docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c8d566048..f27acd475 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -10,6 +10,7 @@ on: branches: - 'main' - 'rc_*' + - 'feat/scoped-auth-tokens' env: DOCKERHUB_IMAGE: ${{ 'oceanprotocol/ocean-node' }} From a0dae37d25eea312f7277f22094f1b91314dee02 Mon Sep 17 00:00:00 2001 From: alexcos20 Date: Sat, 21 Nov 2026 07:57:37 +0200 Subject: [PATCH 3/5] resolve comments --- src/components/core/utils/statusHandler.ts | 34 +++++++++++++++------- src/components/httpRoutes/rootEndpoint.ts | 15 +++++++--- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/components/core/utils/statusHandler.ts b/src/components/core/utils/statusHandler.ts index d1a1d6d94..a9e0690fd 100644 --- a/src/components/core/utils/statusHandler.ts +++ b/src/components/core/utils/statusHandler.ts @@ -136,10 +136,13 @@ export async function status( const publicKeyHex = Buffer.from(publicKey).toString('hex') nodeStatus = { - id: - nodeId && nodeId !== undefined - ? nodeId - : oceanNode.getKeyManager().getPeerId().toString(), // get current node ID + // Always identify THIS serving node. `nodeStatus` is a shared module-level cache built + // once, and the caller-supplied `nodeId` (command `node`) would otherwise poison the + // cached `id` for every later request — including the root `GET /` identity endpoint that + // decryptDDO's `issuerPeerId` relies on. The handler still pins `id` to self on the + // challenged response; keeping the cache self-identified makes the unchallenged response + // agree. The `nodeId` param is retained for signature compatibility. + id: oceanNode.getKeyManager().getPeerId().toString(), publicKey: publicKeyHex, friendlyName: humanizeHex(publicKeyHex), address: oceanNode.getKeyManager().getEthAddress(), @@ -211,14 +214,19 @@ export async function status( enabled: oceanNode.isInMaintenance() } - // depends on request + // depends on request. Built into LOCALS (not written to the shared, cached `nodeStatus`) and + // merged into a per-request shallow copy at the return below — same reasoning as the + // maintenance block: a concurrent basic request would otherwise `delete` these keys while a + // detailed request is populating them (and vice versa), racing on the shared object. + let c2dClusters: OceanNodeStatus['c2dClusters'] + let supportedSchemas: OceanNodeStatus['supportedSchemas'] if (detailed) { - nodeStatus.c2dClusters = [] + c2dClusters = [] try { const engines = await oceanNode.getC2DEngines().getAllEngines() for (const engine of engines) { const type = await engine.getC2DType() - nodeStatus.c2dClusters.push({ + c2dClusters.push({ type, hash: await engine.getC2DConfig().hash, environments: await engine.getComputeEnvironments() @@ -232,7 +240,7 @@ export async function status( `Error getting c2d clusters: ${error.message}` ) } - nodeStatus.supportedSchemas = typesenseSchemas.ddoSchemas + supportedSchemas = typesenseSchemas.ddoSchemas // Drain-visibility counts: how much already-committed work is still running, so an admin // can tell when the node is drained and safe to reboot. Wrapped in try/catch + throttled @@ -296,9 +304,6 @@ export async function status( `Error computing maintenance drain counts: ${error.message}` ) } - } else { - delete nodeStatus.c2dClusters - delete nodeStatus.supportedSchemas } // Assign the fully-built maintenance object once, after all awaits above, so a concurrent @@ -312,5 +317,12 @@ export async function status( nodeStatus.persistentStorage.allowBucketSharing = config.persistentStorage.allowBucketSharing === true } + + // Detailed cluster data lives only on the per-request response, never on the shared cache. + // A basic request returns the shared object (which never carries these keys, so + // `c2dClusters` / `supportedSchemas` are absent as before). + if (detailed) { + return { ...nodeStatus, c2dClusters, supportedSchemas } + } return nodeStatus } diff --git a/src/components/httpRoutes/rootEndpoint.ts b/src/components/httpRoutes/rootEndpoint.ts index 07022b26d..491f61cca 100644 --- a/src/components/httpRoutes/rootEndpoint.ts +++ b/src/components/httpRoutes/rootEndpoint.ts @@ -24,12 +24,19 @@ rootEndpointRoutes.get('/', async (req: Request, res: Response): Promise = caller: req.caller } const result = await new StatusHandler(req.oceanNode).handle(command) + // Preserve the handler's HTTP status for BOTH streamed and non-streamed responses: a + // rate-limit / error response (e.g. buildRateLimitReachedResponse) carries a stream AND a + // non-200 httpStatus, so the status must be set before piping, not only on the error branch. + res.status(result.status.httpStatus) if (result.stream) { - // The handler already emits a formatted JSON string stream; pipe it straight through - // instead of buffering and re-serializing via res.json(). - res.type('application/json') + // The success path emits a formatted JSON string stream; pipe it straight through instead + // of buffering and re-serializing via res.json(). Non-200 stream bodies (e.g. the rate-limit + // text) are left as the default content type. + if (result.status.httpStatus === 200) { + res.type('application/json') + } ;(result.stream as Readable).pipe(res) } else { - res.status(result.status.httpStatus).send(result.status.error) + res.send(result.status.error) } }) From 7e691ed7990da78b614a90376427f2bf245ae84c Mon Sep 17 00:00:00 2001 From: alexcos20 Date: Sat, 21 Nov 2026 08:15:43 +0200 Subject: [PATCH 4/5] fix http decryptor --- src/components/Indexer/processors/BaseProcessor.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/Indexer/processors/BaseProcessor.ts b/src/components/Indexer/processors/BaseProcessor.ts index 3a3fba480..e68787deb 100644 --- a/src/components/Indexer/processors/BaseProcessor.ts +++ b/src/components/Indexer/processors/BaseProcessor.ts @@ -292,7 +292,8 @@ export abstract class BaseEventProcessor { * * The signed DECRYPT_DDO message binds the verifier's peerId, so a signature minted for node A * cannot be replayed at node B. Over P2P the destination peerId is already known; over HTTP we - * must learn it from the target node's root endpoint (`GET /` → `nodeId`). If it cannot be + * must learn it from the target node's root endpoint (`GET /` → status `id`, legacy `nodeId`). + * If it cannot be * obtained we return null and the caller MUST NOT send a (now cross-node-replayable) HTTP * decrypt — it fails the HTTP attempt instead. * @@ -381,8 +382,12 @@ export abstract class BaseEventProcessor { const text = await this.readCappedText(res, MAX_NODEID_RESPONSE_BYTES) if (text !== null) { const body = JSON.parse(text) - if (body && typeof body.nodeId === 'string' && body.nodeId.length > 0) { - peerId = body.nodeId + // The root `GET /` endpoint now returns the full node status object, whose peerId + // field is `id`. Fall back to the legacy `nodeId` field so a target node still on the + // pre-unification root endpoint keeps resolving. + const resolvedPeerId = body?.id ?? body?.nodeId + if (typeof resolvedPeerId === 'string' && resolvedPeerId.length > 0) { + peerId = resolvedPeerId } } } From 6c25ecab5bd8aee1acacd47a74ddbe37734f770d Mon Sep 17 00:00:00 2001 From: Alex Coseru Date: Sat, 21 Nov 2026 08:34:05 +0200 Subject: [PATCH 5/5] Update CI workflow to checkout specific branch --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8b510467..dde19c258 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -261,12 +261,14 @@ jobs: persist-credentials: false repository: 'oceanprotocol/ocean-cli' path: 'ocean-cli' + ref: 'feature/unify_status_endpoints' - name: Checkout Ocean-js uses: actions/checkout@v7 with: persist-credentials: false repository: 'oceanprotocol/ocean.js' path: 'ocean.js' + ref: feature/unify_status_endpoints - name: Build ocean-js working-directory: ${{ github.workspace }}/ocean.js run: |