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 .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export LOG_LEVEL=
export HTTP_API_PORT=
export VALIDATE_UNSIGNED_DDO=
export JWT_SECRET=
export NODE_OWNER_INFO=
export UNSAFE_URLS=
export ALLOWED_PRIVATE_URL_RANGES=

Expand Down
5 changes: 5 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,11 @@ returns status of node
"version": "123",
"http": true,
"p2p": true,
"isPSConfigured": false,
"ownerInfo": {
"imprint": { "legalName": "Acme Ltd", "email": "legal@acme.com" },
"termsAndConditions": { "url": "https://acme.com/terms" }
},
"provider": [],
"indexer": [],
"supportedStorage": {
Expand Down
1 change: 1 addition & 0 deletions docs/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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 with the node owner's legal/contact info, returned as `ownerInfo` by the `status` command (HTTP and P2P). Free-form; omitted from status when unset or not a JSON object. Example: `'{"imprint":{"legalName":"Acme Ltd","email":"legal@acme.com","url":"https://acme.com","address":"1 Main St"},"termsAndConditions":{"url":"https://acme.com/terms"},"privacyPolicy":{"url":"https://acme.com/privacy"}}'`
- `PERSISTENT_STORAGE`: Persistent storage config. See [persistent storage](persistentStorage.md).
- `UNSAFE_URLS`: JSON array of regular expressions. A caller-supplied URL (the `url` / `ftp` file objects used by fileInfo, download, encrypt, compute inputs and compute-output upload) matching any of them is rejected. The entries are **added to** the built-in defaults (the cloud metadata endpoints such as `169.254.169.254` and `metadata.google.internal`, and `127.0.0.1`), so setting this variable never drops the defaults. Example: `["^https?://internal\\.example\\.com"]`
- `ALLOWED_PRIVATE_URL_RANGES`: By default the node refuses to contact URLs whose host is, or resolves to, a private, loopback, link-local, CGNAT, multicast or otherwise reserved address, IPv4 or IPv6. This applies to caller-supplied file URLs (`url`, `ftp` and `s3` file objects used by fileInfo / download / compute), on-chain `decryptorURL` fields (the Indexer posts decrypt requests to them), and all outbound requests made during Docker manifest checks for compute images (the initial manifest fetch, the token-endpoint fetch from the `www-authenticate` realm, and the authenticated re-fetch). The check fires at connect time on every connection and every redirect, closing DNS-rebinding and redirect-chain vectors. **Localhost Docker registries** (`localhost:5000/myalgo`, etc.) are also blocked by this default and require listing `127.0.0.1/8` and/or `::1/128` here. This JSON array of CIDRs or single IPs lists exceptions, for example an object store, a private decryptor node, or a localhost registry on the node's LAN. Default is `[]`. Example: `["10.0.5.20/32","192.168.10.0/24","127.0.0.1/8"]`
Expand Down
19 changes: 11 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@libp2p/websockets": "^10.1.21",
"@multiformats/multiaddr": "^13.0.3",
"@oceanprotocol/contracts": "^3.2.0",
"@oceanprotocol/ddo-js": "^1.0.0",
"@oceanprotocol/ddo-js": "^1.1.0",
"@opentelemetry/api": "^1.9.1",
"@opentelemetry/exporter-metrics-otlp-http": "^0.221.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
Expand Down
7 changes: 7 additions & 0 deletions src/@types/OceanNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ export interface OceanNodeConfig {
httpCertPath?: string
httpKeyPath?: string
enableBenchmark?: boolean
// derived, not read from config: whether POLICY_SERVER_URL is set (refreshed by getConfig())
isPSConfigured: boolean
persistentStorage?: PersistentStorageConfig
}

Expand Down Expand Up @@ -291,6 +293,11 @@ export interface OceanNodeStatus {
version: string
http: boolean
p2p: boolean
// whether a Policy Server is configured (POLICY_SERVER_URL); clients use it to decide
// whether to run the credential (SSI) flow before download/compute
isPSConfigured: boolean
// node owner/legal info from NODE_OWNER_INFO (free-form JSON object); absent when unset/invalid
ownerInfo?: Record<string, any>
/** Present only when the P2P interface is enabled and running. */
p2pStatus?: OceanNodeP2PStatus
provider: OceanNodeProvider[]
Expand Down
2 changes: 2 additions & 0 deletions src/OceanNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { createPersistentStorage } from './components/persistentStorage/createPe
import { PersistentStorageFactory } from './components/persistentStorage/PersistentStorageFactory.js'
import { isAddress, FallbackProvider, ethers } from 'ethers'
import { create256Hash } from './utils/crypt.js'
import { isPolicyServerConfigured } from './utils/config.js'
import {
MAINTENANCE_MODE_CONFIG_KEY,
SUPPORTED_PROTOCOL_COMMANDS
Expand Down Expand Up @@ -298,6 +299,7 @@ export class OceanNode {
}

public getConfig(): OceanNodeConfig {
this.config.isPSConfigured = isPolicyServerConfigured()
return this.config
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { EVENTS } from '../../../utils/constants.js'
import { INDEXER_LOGGER } from '../../../utils/logging/common.js'
import {
getDtContract,
getDid,
retrieveDdoByNft,
doesDispenserAlreadyExist,
findServiceIdByDatatoken,
getPricesByDt,
isValidDispenserContract
} from '../utils.js'
Expand Down Expand Up @@ -42,10 +41,9 @@ export class DispenserActivatedEventProcessor extends BaseEventProcessor {
const datatokenContract = getDtContract(signer, datatokenAddress)

const nftAddress = await datatokenContract.getERC721Address()
const did = getDid(nftAddress, chainId)
try {
const { ddo: ddoDatabase } = await this.getDatabase()
const ddo = await ddoDatabase.retrieve(did)
const { did, ddo } = await retrieveDdoByNft(ddoDatabase, nftAddress, chainId)
if (!ddo) {
INDEXER_LOGGER.debug(
`Detected DispenserActivated changed for ${did}, but it does not exists.`
Expand Down Expand Up @@ -86,7 +84,7 @@ export class DispenserActivatedEventProcessor extends BaseEventProcessor {
}
} else {
INDEXER_LOGGER.debug(`[DispenserActivated] - No stats were found on the ddo`)
const serviceIdToFind = findServiceIdByDatatoken(ddoInstance, datatokenAddress)
const serviceIdToFind = ddoInstance.getServiceByDatatoken(datatokenAddress)?.id
if (!serviceIdToFind) {
INDEXER_LOGGER.debug(
`[DispenserActivated] - This datatoken does not contain this service. Invalid service id!`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { EVENTS } from '../../../utils/constants.js'
import { INDEXER_LOGGER } from '../../../utils/logging/common.js'
import {
getDtContract,
getDid,
retrieveDdoByNft,
doesDispenserAlreadyExist,
findServiceIdByDatatoken,
getPricesByDt,
isValidDispenserContract
} from '../utils.js'
Expand Down Expand Up @@ -43,10 +42,9 @@ export class DispenserCreatedEventProcessor extends BaseEventProcessor {
const datatokenContract = getDtContract(signer, datatokenAddress)

const nftAddress = await datatokenContract.getERC721Address()
const did = getDid(nftAddress, chainId)
try {
const { ddo: ddoDatabase } = await this.getDatabase()
const ddo = await ddoDatabase.retrieve(did)
const { did, ddo } = await retrieveDdoByNft(ddoDatabase, nftAddress, chainId)
if (!ddo) {
INDEXER_LOGGER.debug(
`Detected DispenserCreated changed for ${did}, but it does not exists.`
Expand Down Expand Up @@ -88,7 +86,7 @@ export class DispenserCreatedEventProcessor extends BaseEventProcessor {
}
} else {
INDEXER_LOGGER.debug(`[DispenserCreated] - No stats were found on the ddo`)
const serviceIdToFind = findServiceIdByDatatoken(ddoInstance, datatokenAddress)
const serviceIdToFind = ddoInstance.getServiceByDatatoken(datatokenAddress)?.id
if (!serviceIdToFind) {
INDEXER_LOGGER.debug(
`[DispenserCreated] - This datatoken does not contain this service. Invalid service id!`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { EVENTS } from '../../../utils/constants.js'
import { INDEXER_LOGGER } from '../../../utils/logging/common.js'
import {
getDtContract,
getDid,
retrieveDdoByNft,
doesDispenserAlreadyExist,
findServiceIdByDatatoken,
getPricesByDt,
isValidDispenserContract
} from '../utils.js'
Expand Down Expand Up @@ -42,10 +41,9 @@ export class DispenserDeactivatedEventProcessor extends BaseEventProcessor {
const datatokenContract = getDtContract(signer, datatokenAddress)

const nftAddress = await datatokenContract.getERC721Address()
const did = getDid(nftAddress, chainId)
try {
const { ddo: ddoDatabase } = await this.getDatabase()
const ddo = await ddoDatabase.retrieve(did)
const { did, ddo } = await retrieveDdoByNft(ddoDatabase, nftAddress, chainId)
if (!ddo) {
INDEXER_LOGGER.debug(
`Detected DispenserDeactivated changed for ${did}, but it does not exists.`
Expand Down Expand Up @@ -89,7 +87,7 @@ export class DispenserDeactivatedEventProcessor extends BaseEventProcessor {
}
} else {
INDEXER_LOGGER.debug(`[DispenserDeactivated] - No stats were found on the ddo`)
const serviceIdToFind = findServiceIdByDatatoken(ddoInstance, datatokenAddress)
const serviceIdToFind = ddoInstance.getServiceByDatatoken(datatokenAddress)?.id
if (!serviceIdToFind) {
INDEXER_LOGGER.debug(
`[DispenserDeactivated] - This datatoken does not contain this service. Invalid service id!`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { EVENTS } from '../../../utils/constants.js'
import { INDEXER_LOGGER } from '../../../utils/logging/common.js'
import {
getDtContract,
getDid,
retrieveDdoByNft,
doesFreAlreadyExist,
findServiceIdByDatatoken,
getPricesByDt,
isValidFreContract
} from '../utils.js'
Expand Down Expand Up @@ -50,10 +49,9 @@ export class ExchangeActivatedEventProcessor extends BaseEventProcessor {
}
const datatokenContract = getDtContract(signer, datatokenAddress)
const nftAddress = await datatokenContract.getERC721Address()
const did = getDid(nftAddress, chainId)

const { ddo: ddoDatabase } = await this.getDatabase()
const ddo = await ddoDatabase.retrieve(did)
const { did, ddo } = await retrieveDdoByNft(ddoDatabase, nftAddress, chainId)
if (!ddo) {
INDEXER_LOGGER.debug(
`Detected ExchangeActivated changed for ${did}, but it does not exists.`
Expand Down Expand Up @@ -89,7 +87,7 @@ export class ExchangeActivatedEventProcessor extends BaseEventProcessor {
}
} else {
INDEXER_LOGGER.debug(`[ExchangeActivated] - No stats were found on the ddo`)
const serviceIdToFind = findServiceIdByDatatoken(ddoInstance, datatokenAddress)
const serviceIdToFind = ddoInstance.getServiceByDatatoken(datatokenAddress)?.id
if (!serviceIdToFind) {
INDEXER_LOGGER.debug(
`[ExchangeActivated] - This datatoken does not contain this service. Invalid service id!`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { EVENTS } from '../../../utils/constants.js'
import { INDEXER_LOGGER } from '../../../utils/logging/common.js'
import {
getDtContract,
getDid,
retrieveDdoByNft,
doesFreAlreadyExist,
findServiceIdByDatatoken,
getPricesByDt,
isValidFreContract
} from '../utils.js'
Expand Down Expand Up @@ -50,10 +49,9 @@ export class ExchangeCreatedEventProcessor extends BaseEventProcessor {
}
const datatokenContract = getDtContract(signer, datatokenAddress)
const nftAddress = await datatokenContract.getERC721Address()
const did = getDid(nftAddress, chainId)

const { ddo: ddoDatabase } = await this.getDatabase()
const ddo = await ddoDatabase.retrieve(did)
const { did, ddo } = await retrieveDdoByNft(ddoDatabase, nftAddress, chainId)
if (!ddo) {
INDEXER_LOGGER.debug(
`Detected ExchangeCreated changed for ${did}, but it does not exists.`
Expand Down Expand Up @@ -90,7 +88,7 @@ export class ExchangeCreatedEventProcessor extends BaseEventProcessor {
}
} else {
INDEXER_LOGGER.debug(`[ExchangeCreated] - No stats were found on the ddo`)
const serviceIdToFind = findServiceIdByDatatoken(ddoInstance, datatokenAddress)
const serviceIdToFind = ddoInstance.getServiceByDatatoken(datatokenAddress)?.id
if (!serviceIdToFind) {
INDEXER_LOGGER.debug(
`[ExchangeCreated] - This datatoken does not contain this service. Invalid service id!`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { EVENTS } from '../../../utils/constants.js'
import { INDEXER_LOGGER } from '../../../utils/logging/common.js'
import {
getDtContract,
getDid,
retrieveDdoByNft,
doesFreAlreadyExist,
findServiceIdByDatatoken,
getPricesByDt,
isValidFreContract
} from '../utils.js'
Expand Down Expand Up @@ -56,10 +55,9 @@ export class ExchangeDeactivatedEventProcessor extends BaseEventProcessor {
}
const datatokenContract = getDtContract(signer, datatokenAddress)
const nftAddress = await datatokenContract.getERC721Address()
const did = getDid(nftAddress, chainId)
try {
const { ddo: ddoDatabase } = await this.getDatabase()
const ddo = await ddoDatabase.retrieve(did)
const { did, ddo } = await retrieveDdoByNft(ddoDatabase, nftAddress, chainId)
if (!ddo) {
INDEXER_LOGGER.debug(
`Detected ExchangeDeactivated changed for ${did}, but it does not exists.`
Expand Down Expand Up @@ -97,7 +95,7 @@ export class ExchangeDeactivatedEventProcessor extends BaseEventProcessor {
}
} else {
INDEXER_LOGGER.debug(`[ExchangeDeactivated] - No stats were found on the ddo`)
const serviceIdToFind = findServiceIdByDatatoken(ddoInstance, datatokenAddress)
const serviceIdToFind = ddoInstance.getServiceByDatatoken(datatokenAddress)?.id
if (!serviceIdToFind) {
INDEXER_LOGGER.debug(
`[ExchangeDeactivated] - This datatoken does not contain this service. Invalid service id!`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { EVENTS } from '../../../utils/constants.js'
import { INDEXER_LOGGER } from '../../../utils/logging/common.js'
import {
getDtContract,
getDid,
retrieveDdoByNft,
doesFreAlreadyExist,
findServiceIdByDatatoken,
getPricesByDt,
isValidFreContract
} from '../utils.js'
Expand Down Expand Up @@ -51,10 +50,9 @@ export class ExchangeRateChangedEventProcessor extends BaseEventProcessor {
}
const datatokenContract = getDtContract(signer, datatokenAddress)
const nftAddress = await datatokenContract.getERC721Address()
const did = getDid(nftAddress, chainId)

const { ddo: ddoDatabase } = await this.getDatabase()
const ddo = await ddoDatabase.retrieve(did)
const { did, ddo } = await retrieveDdoByNft(ddoDatabase, nftAddress, chainId)
if (!ddo) {
INDEXER_LOGGER.debug(
`Detected ExchangeRateChanged changed for ${did}, but it does not exists.`
Expand Down Expand Up @@ -91,7 +89,7 @@ export class ExchangeRateChangedEventProcessor extends BaseEventProcessor {
}
} else {
INDEXER_LOGGER.debug(`[ExchangeRateChanged] - No stats were found on the ddo`)
const serviceIdToFind = findServiceIdByDatatoken(ddoInstance, datatokenAddress)
const serviceIdToFind = ddoInstance.getServiceByDatatoken(datatokenAddress)?.id
if (!serviceIdToFind) {
INDEXER_LOGGER.debug(
`[ExchangeRateChanged] - This datatoken does not contain this service. Invalid service id!`
Expand Down
Loading
Loading