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
1 change: 1 addition & 0 deletions docs/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Environmental variables are also tracked in `ENVIRONMENT_VARIABLES` within `src/
- `AUTHORIZED_PUBLISHERS_LIST`: AccessList contract addresses (per chain). If present, Node will only index assets published by the accounts present on the given access lists. Example: `"{ \"8996\": [\"0x967da4048cD07aB37855c090aAF366e4ce1b9F48\",\"0x388C818CA8B9251b393131C08a736A67ccB19297\"] }"`
- `VALIDATE_UNSIGNED_DDO`: If set to `false`, the node will not validate unsigned DDOs and will request a signed message with the publisher address, nonce and signature. Default is `true`. Example: `false`
- `JWT_SECRET`: Secret used to sign JWT tokens. Default is `ocean-node-secret`. Example: `"my-secret-jwt-token"`
- `NODE_OWNER_INFO`: Optional JSON object returned by the root endpoint as `ownerInfo`. Example: `"{\"imprint\":{\"legalName\":\"Example Ocean Services GmbH\"},\"termsAndConditions\":{\"url\":\"https://example.com/terms\"},\"anyCustomSection\":{\"foo\":\"bar\"}}"`

## Database

Expand Down
14 changes: 12 additions & 2 deletions src/components/httpRoutes/rootEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import express from 'express'
import { HTTP_LOGGER } from '../../utils/logging/common.js'
import { getConfiguration } from '../../utils/index.js'
import { getAllServiceEndpoints } from './index.js'
import { getNodeOwnerInfo } from './utils.js'
export const rootEndpointRoutes = express.Router()

rootEndpointRoutes.get('/', async (req, res) => {
Expand All @@ -10,12 +11,21 @@ rootEndpointRoutes.get('/', async (req, res) => {
HTTP_LOGGER.warn(`Supported networks not defined`)
}
const keyManager = req.oceanNode.getKeyManager()
res.json({
const rootResponse: Record<string, unknown> = {
nodeId: keyManager.getPeerId().toString(),
chainIds: config.supportedNetworks ? Object.keys(config.supportedNetworks) : [],
providerAddress: keyManager.getEthAddress(),
serviceEndpoints: getAllServiceEndpoints(),
software: 'Ocean-Node',
version: '0.0.1'
})
}

const ownerInfo = getNodeOwnerInfo()
if (ownerInfo) {
rootResponse.ownerInfo = ownerInfo
} else {
HTTP_LOGGER.warn('NODE_OWNER_INFO not present or invalid')
}

res.json(rootResponse)
})
26 changes: 26 additions & 0 deletions src/components/httpRoutes/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const OWNER_INFO_ENV_KEY = 'NODE_OWNER_INFO'

function parseObj(envValue: string): Record<string, any> | null {
if (!envValue) {
return null
}

try {
const parsedValue = JSON.parse(envValue)
if (
typeof parsedValue === 'object' &&
parsedValue !== null &&
!Array.isArray(parsedValue)
) {
return parsedValue as Record<string, any>
}
} catch {
return null
}

return null
}

export function getNodeOwnerInfo(): Record<string, any> | null {
return parseObj(process.env[OWNER_INFO_ENV_KEY])
}
Loading