diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8b510467..cb68e16a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -267,6 +267,7 @@ jobs: persist-credentials: false repository: 'oceanprotocol/ocean.js' path: 'ocean.js' + ref: 'feature/peerId_in_all_signatures' - name: Build ocean-js working-directory: ${{ github.workspace }}/ocean.js run: | diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a9f9c3b0a..c8d566048 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -9,10 +9,7 @@ on: pull_request: branches: - 'main' - - 'next-4' - - 'deps/node_v24' - - 'feature/user_input_subsidy' - - 'feature/subsidy_provider' + - 'rc_*' env: DOCKERHUB_IMAGE: ${{ 'oceanprotocol/ocean-node' }} diff --git a/docs/API.md b/docs/API.md index 6a0a487c9..40424529d 100644 --- a/docs/API.md +++ b/docs/API.md @@ -19,6 +19,45 @@ change closes. Client libraries that construct the `decryptDDO` message themselv --- +## Release note — universal peerId-bound signing (BREAKING, since Ocean Node v5.1.0) + +Previously only `decryptDDO` (ON-02, above) bound its signature to the destination node's peerId. +As of **v5.1.0** **every** signature-authenticated command — ordinary (user) commands **and** admin +commands — binds the signed message to the **destination (verifier) node's own peerId**. This closes +signature replay across nodes for all commands: a signature minted for node A is rejected by node B. + +For every signed command **except `decryptDDO`** (which additionally binds its resource fields — see +the `POST /api/services/decrypt` and P2P `decryptDDO` sections), the signed message is the +concatenation: + +``` +consumerAddress + nonce + command + issuerPeerId +``` + +- `consumerAddress` — the caller's EVM address (the same value sent as `consumerAddress` / `address`), + in the casing you actually signed (see **Address casing**). +- `nonce` — the per-caller monotonic nonce, as a string. +- `command` — the **exact** command string the request carries, same casing as sent (e.g. `encrypt`, + `download`, `startCompute`, `persistentStorageCreateBucket`, `serviceStart`, `serviceExtend`, + `setMaintenance`). +- `issuerPeerId` — the **target node's own peerId**. Discover it once per node from the `id` field of + that node's `status` response (`POST /directCommand` with `{"command":"status"}`) or the `nodeId` + returned by its root `GET /`, then bind the same value into every signed request to that node. + +This applies to all signature-authenticated families, including **persistent storage** +(`persistentStorageCreateBucket`, `persistentStorageUploadFile`, `persistentStorageDeleteFile`, …), +**services** (`serviceStart`, `serviceExtend`, `serviceStop`, …), compute (`startCompute` / +`freeStartCompute`), `encrypt` / `encryptFile`, `download`, `validateDDO`, and the admin commands. + +**Breaking change.** This is a coordinated signer/verifier change with **no empty-peerId fallback**: a +request whose signed message omits `issuerPeerId` (the pre-v5.1.0 `consumerAddress + nonce + command` +format) is rejected with a `consumer address and nonce signature mismatch` error. Client libraries +that build the signed message themselves must adopt the new format and upgrade in lockstep with the +node. `ocean.js` resolves the peerId automatically (from the node `status`) before signing, so callers +using it need no change. + +--- + ## Address casing Every EVM address you send (`consumerAddress`, `owner`, `address`, `decrypterAddress`, @@ -1416,10 +1455,13 @@ asset/service and consumer. This endpoint requires an `Authorization` header or `nonce` + `signature` pair. This is a distinct command from `PolicyServerPassthrough`, so the signed message uses its -own command string: `consumerAddress + nonce + "PolicyServerInitialize"`. +own command string and is bound to the node's peerId (see the universal signing release note +above): `consumerAddress + nonce + "PolicyServerInitialize" + issuerPeerId`. The verified `consumerAddress` is the one forwarded to the PolicyServer; the caller's -`authorization`, `nonce` and `signature` are added to the `policyServer` object. +`authorization`, `nonce` and `signature` are added to the `policyServer` object, together with +this node's `issuerPeerId`, so a PolicyServer that re-verifies the forwarded signature can rebuild +the peer-bound message. (ocean-node has already verified the signature locally.) #### Parameters @@ -2389,7 +2431,7 @@ List buckets for a given `owner`. Results are filtered by bucket access lists fo | name | type | required | description | | --------------- | ------ | -------- | -------------------------------------------------- | | consumerAddress | string | v | consumer address | -| signature | string | v | signed message (consumerAddress + nonce + command) | +| signature | string | v | signed message (consumerAddress + nonce + command + issuerPeerId) | | nonce | string | v | request nonce | | chainId | number | v | chain id (used by auth/signature checks) | | owner | string | v | bucket owner to filter by | @@ -2420,7 +2462,7 @@ List files in a bucket. | name | type | required | description | | --------------- | ------ | -------- | -------------------------------------------------- | | consumerAddress | string | v | consumer address | -| signature | string | v | signed message (consumerAddress + nonce + command) | +| signature | string | v | signed message (consumerAddress + nonce + command + issuerPeerId) | | nonce | string | v | request nonce | #### Response (200) @@ -2449,7 +2491,7 @@ Return the `fileObject` for a specific file in a bucket (useful for passing refe | name | type | required | description | | --------------- | ------ | -------- | -------------------------------------------------- | | consumerAddress | string | v | consumer address | -| signature | string | v | signed message (consumerAddress + nonce + command) | +| signature | string | v | signed message (consumerAddress + nonce + command + issuerPeerId) | | nonce | string | v | request nonce | #### Response (200) @@ -2478,7 +2520,7 @@ identically. | name | type | required | description | | --------------- | ------ | -------- | -------------------------------------------------- | | consumerAddress | string | v | consumer address | -| signature | string | v | signed message (consumerAddress + nonce + command) | +| signature | string | v | signed message (consumerAddress + nonce + command + issuerPeerId) | | nonce | string | v | request nonce | #### Response (200) @@ -2509,7 +2551,7 @@ Upload a file to a bucket. The request body is treated as raw bytes. | name | type | required | description | | --------------- | ------ | -------- | -------------------------------------------------- | | consumerAddress | string | v | consumer address | -| signature | string | v | signed message (consumerAddress + nonce + command) | +| signature | string | v | signed message (consumerAddress + nonce + command + issuerPeerId) | | nonce | string | v | request nonce | #### Request Body @@ -2540,7 +2582,7 @@ Delete a file from a bucket. | name | type | required | description | | --------------- | ------ | -------- | -------------------------------------------------- | | consumerAddress | string | v | consumer address | -| signature | string | v | signed message (consumerAddress + nonce + command) | +| signature | string | v | signed message (consumerAddress + nonce + command + issuerPeerId) | | nonce | string | v | request nonce | | chainId | number | v | chain id (used by auth/signature checks) | @@ -2562,8 +2604,9 @@ it expires, is stopped, or is extended. See [`services.md`](./services.md) for t and security model. All routes live under `/api/services`. Every command except `serviceTemplates` is -authenticated by a signature over `consumerAddress` + `nonce` + `command` (or an auth-token -`Authorization` header). Cost is computed only from the environment's server-side pricing and +authenticated by a signature over `consumerAddress` + `nonce` + `command` + `issuerPeerId` (the +target node's peerId — see the universal signing release note above) or an auth-token +`Authorization` header. Cost is computed only from the environment's server-side pricing and charged to the authenticated `consumerAddress`. > **Note:** service containers run hardened (`no-new-privileges`, `CapDrop: ['ALL']`), so a diff --git a/src/components/core/handler/policyServer.ts b/src/components/core/handler/policyServer.ts index 270b86fb8..60b012770 100644 --- a/src/components/core/handler/policyServer.ts +++ b/src/components/core/handler/policyServer.ts @@ -134,7 +134,11 @@ export class PolicyServerInitializeHandler extends CommandHandler { ...task.policyServer, authorization: task.authorization, nonce: task.nonce, - signature: task.signature + signature: task.signature, + // The request signature is bound to this node's peerId (anti-replay), so a policy + // server that re-verifies the forwarded signature needs the same peerId to rebuild + // the signed message. ocean-node has already verified it locally regardless. + issuerPeerId: this.getOceanNode().getKeyManager().getPeerIdString() } ) if (!policyStatus.success) { diff --git a/src/components/core/utils/nonceHandler.ts b/src/components/core/utils/nonceHandler.ts index 81d4a6e96..b0d5d546d 100644 --- a/src/components/core/utils/nonceHandler.ts +++ b/src/components/core/utils/nonceHandler.ts @@ -182,13 +182,10 @@ async function validateNonceAndSignature( error: 'nonce: ' + nonce + ' is not a valid nonce' } } - // ON-02: DECRYPT_DDO binds the signed message to THIS (verifier) node's peerId, exactly as - // CREATE_AUTH_TOKEN does, so a signature harvested from one node cannot be replayed at another. - const issuerPeerId = - command === PROTOCOL_COMMANDS.CREATE_AUTH_TOKEN || - command === PROTOCOL_COMMANDS.DECRYPT_DDO - ? OceanNode.getInstance().getKeyManager().getPeerIdString() - : '' + // Every signed command binds the signed message to THIS (verifier) node's peerId, so a + // signature harvested from (or sent to) one node cannot be replayed against another node. + // (DECRYPT_DDO additionally binds resource fields via its dedicated builder, below.) + const issuerPeerId = OceanNode.getInstance().getKeyManager().getPeerIdString() if ( await verifyConsumerSignature( consumer, diff --git a/src/test/integration/algorithmsAccess.test.ts b/src/test/integration/algorithmsAccess.test.ts index 3ac936eda..c9eb8c6b1 100644 --- a/src/test/integration/algorithmsAccess.test.ts +++ b/src/test/integration/algorithmsAccess.test.ts @@ -448,7 +448,8 @@ describe('********** Trusted algorithms Flow', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.COMPUTE_START + PROTOCOL_COMMANDS.COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const startComputeTask: PaidComputeStartCommand = { diff --git a/src/test/integration/auth.test.ts b/src/test/integration/auth.test.ts index 905bbfe75..6323aaa86 100644 --- a/src/test/integration/auth.test.ts +++ b/src/test/integration/auth.test.ts @@ -198,7 +198,9 @@ describe('********** Auth Token Integration Tests', () => { const invalidateHash = createHashForSignature( consumerAddress, newNonce, - PROTOCOL_COMMANDS.INVALIDATE_AUTH_TOKEN + PROTOCOL_COMMANDS.INVALIDATE_AUTH_TOKEN, + // every signed command binds the verifier node's peerId (anti-replay) + oceanNode.getKeyManager().getPeerIdString() ) const invalidateSignature = await safeSign(consumerAccount, invalidateHash) diff --git a/src/test/integration/compute.test.ts b/src/test/integration/compute.test.ts index 67ea01733..ffdbdf4ac 100644 --- a/src/test/integration/compute.test.ts +++ b/src/test/integration/compute.test.ts @@ -670,7 +670,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.COMPUTE_START + PROTOCOL_COMMANDS.COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) // since ganache does not supports personal_sign, we use wallet account const signature = await safeSign(consumerAccount, messageHashBytes) @@ -764,7 +765,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.COMPUTE_START + PROTOCOL_COMMANDS.COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const re = [] @@ -864,7 +866,8 @@ describe('********** Compute', () => { createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.COMPUTE_START + PROTOCOL_COMMANDS.COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) ) const re = firstEnv.resources.map((res) => ({ id: res.id, amount: res.min })) @@ -1040,7 +1043,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.COMPUTE_START + PROTOCOL_COMMANDS.COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const re = [] @@ -1149,7 +1153,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.COMPUTE_START + PROTOCOL_COMMANDS.COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const re = [] @@ -1244,7 +1249,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.COMPUTE_START + PROTOCOL_COMMANDS.COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const re = [] @@ -1292,7 +1298,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.FREE_COMPUTE_START + PROTOCOL_COMMANDS.FREE_COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const startComputeTask: FreeComputeStartCommand = { @@ -1346,7 +1353,8 @@ describe('********** Compute', () => { createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.FREE_COMPUTE_START + PROTOCOL_COMMANDS.FREE_COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) ) const startComputeTask: FreeComputeStartCommand = { @@ -1425,7 +1433,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.COMPUTE_GET_RESULT + PROTOCOL_COMMANDS.COMPUTE_GET_RESULT, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const resultComputeTask: ComputeGetResultCommand = { @@ -1447,7 +1456,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await additionalViewerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.COMPUTE_GET_RESULT + PROTOCOL_COMMANDS.COMPUTE_GET_RESULT, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(additionalViewerAccount, messageHashBytes) const resultComputeTask: ComputeGetResultCommand = { @@ -1469,7 +1479,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await nonAllowedAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.COMPUTE_GET_RESULT + PROTOCOL_COMMANDS.COMPUTE_GET_RESULT, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(nonAllowedAccount, messageHashBytes) const resultComputeTask: ComputeGetResultCommand = { @@ -1494,7 +1505,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.COMPUTE_STOP + PROTOCOL_COMMANDS.COMPUTE_STOP, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const stopComputeTask: ComputeStopCommand = { @@ -1546,7 +1558,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await consumerAccount.address, nonce, - PROTOCOL_COMMANDS.FREE_COMPUTE_START + PROTOCOL_COMMANDS.FREE_COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) freeComputeStartPayload.command = PROTOCOL_COMMANDS.FREE_COMPUTE_START @@ -1610,7 +1623,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( lowercasedOwner, nonce, - PROTOCOL_COMMANDS.COMPUTE_GET_STATUS + PROTOCOL_COMMANDS.COMPUTE_GET_STATUS, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const response = await new ComputeGetStatusHandler(oceanNode).handle({ @@ -2084,7 +2098,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.COMPUTE_START + PROTOCOL_COMMANDS.COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const startComputeTask: PaidComputeStartCommand = { @@ -2142,7 +2157,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.COMPUTE_START + PROTOCOL_COMMANDS.COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) @@ -2195,7 +2211,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await consumerAccount.address, nonce, - PROTOCOL_COMMANDS.FREE_COMPUTE_START + PROTOCOL_COMMANDS.FREE_COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) @@ -2252,7 +2269,8 @@ describe('********** Compute', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.FREE_COMPUTE_START + PROTOCOL_COMMANDS.FREE_COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) @@ -2596,7 +2614,8 @@ describe('********** Compute', () => { createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) ) const createRes = await new PersistentStorageCreateBucketHandler(oceanNode).handle({ @@ -2617,7 +2636,8 @@ describe('********** Compute', () => { createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) ) const uploadRes = await new PersistentStorageUploadFileHandler(oceanNode).handle({ @@ -2662,7 +2682,8 @@ describe('********** Compute', () => { createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.FREE_COMPUTE_START + PROTOCOL_COMMANDS.FREE_COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) ) return { @@ -2779,7 +2800,8 @@ describe('********** Compute', () => { let messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumerAccount, messageHashBytes) const createRes = await new PersistentStorageCreateBucketHandler(oceanNode).handle({ @@ -2800,7 +2822,8 @@ describe('********** Compute', () => { messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumerAccount, messageHashBytes) const uploadRes = await new PersistentStorageUploadFileHandler(oceanNode).handle({ @@ -2856,7 +2879,8 @@ describe('********** Compute', () => { messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.FREE_COMPUTE_START + PROTOCOL_COMMANDS.FREE_COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumerAccount, messageHashBytes) @@ -2908,7 +2932,8 @@ describe('********** Compute', () => { let messageHashBytes = createHashForSignature( ownerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumerAccount, messageHashBytes) const createRes = await new PersistentStorageCreateBucketHandler(oceanNode).handle({ @@ -2928,7 +2953,8 @@ describe('********** Compute', () => { messageHashBytes = createHashForSignature( ownerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumerAccount, messageHashBytes) const uploadRes = await new PersistentStorageUploadFileHandler(oceanNode).handle({ @@ -2947,7 +2973,8 @@ describe('********** Compute', () => { messageHashBytes = createHashForSignature( intruderAddress, nonce, - PROTOCOL_COMMANDS.FREE_COMPUTE_START + PROTOCOL_COMMANDS.FREE_COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(nonAllowedAccount, messageHashBytes) @@ -3059,7 +3086,8 @@ describe('********** Compute', () => { createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) ) const uploadRes = await new PersistentStorageUploadFileHandler(oceanNode).handle({ @@ -3337,7 +3365,8 @@ describe('********** Compute', () => { createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.FREE_COMPUTE_START + PROTOCOL_COMMANDS.FREE_COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) ) const startTask: FreeComputeStartCommand = { @@ -3382,7 +3411,8 @@ describe('********** Compute', () => { createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) ) const createRes = await new PersistentStorageCreateBucketHandler( @@ -3404,7 +3434,8 @@ describe('********** Compute', () => { createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) ) const uploadRes = await new PersistentStorageUploadFileHandler(oceanNode).handle({ @@ -3509,7 +3540,8 @@ describe('********** Compute Access Restrictions', () => { const messageHashBytes = createHashForSignature( consumerAddr, nonce, - PROTOCOL_COMMANDS.COMPUTE_START + PROTOCOL_COMMANDS.COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(signerWallet, messageHashBytes) @@ -3546,7 +3578,8 @@ describe('********** Compute Access Restrictions', () => { const messageHashBytes = createHashForSignature( consumerAddr, nonce, - PROTOCOL_COMMANDS.FREE_COMPUTE_START + PROTOCOL_COMMANDS.FREE_COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(signerWallet, messageHashBytes) diff --git a/src/test/integration/configAdmin.test.ts b/src/test/integration/configAdmin.test.ts index 1012aa91a..21cc94fc6 100644 --- a/src/test/integration/configAdmin.test.ts +++ b/src/test/integration/configAdmin.test.ts @@ -100,7 +100,8 @@ describe('********** Config Admin Endpoints Integration Tests', () => { const messageHashBytes = createHashForSignature( await adminAccount.getAddress(), nonce, - command + command, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(adminAccount, messageHashBytes) return signature @@ -156,7 +157,8 @@ describe('********** Config Admin Endpoints Integration Tests', () => { const messageHashBytes = createHashForSignature( await nonAdminAccount.getAddress(), expiryTimestamp.toString(), - PROTOCOL_COMMANDS.FETCH_CONFIG + PROTOCOL_COMMANDS.FETCH_CONFIG, + oceanNode.getKeyManager().getPeerIdString() ) const invalidSignature = await safeSign(nonAdminAccount, messageHashBytes) @@ -316,7 +318,8 @@ describe('********** Config Admin Endpoints Integration Tests', () => { const messageHashBytes = createHashForSignature( await nonAdminAccount.getAddress(), expiryTimestamp.toString(), - PROTOCOL_COMMANDS.FETCH_CONFIG + PROTOCOL_COMMANDS.FETCH_CONFIG, + oceanNode.getKeyManager().getPeerIdString() ) const invalidSignature = await safeSign(nonAdminAccount, messageHashBytes) diff --git a/src/test/integration/credentials.test.ts b/src/test/integration/credentials.test.ts index 73fd0cf63..3c5446798 100644 --- a/src/test/integration/credentials.test.ts +++ b/src/test/integration/credentials.test.ts @@ -361,7 +361,8 @@ describe('********** [Credentials Flow] - Should run a complete node flo const messageHashBytes = createHashForSignature( await consumerAccounts[0].getAddress(), nonce, - PROTOCOL_COMMANDS.DOWNLOAD + PROTOCOL_COMMANDS.DOWNLOAD, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccounts[0], messageHashBytes) @@ -395,7 +396,8 @@ describe('********** [Credentials Flow] - Should run a complete node flo const messageHashBytes = createHashForSignature( await consumerAccounts[0].getAddress(), nonce, - PROTOCOL_COMMANDS.DOWNLOAD + PROTOCOL_COMMANDS.DOWNLOAD, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccounts[0], messageHashBytes) @@ -542,7 +544,8 @@ describe('********** [Credentials Flow] - Should run a complete node flo const messageHashBytes = createHashForSignature( await consumerAccounts[1].getAddress(), nonce, - PROTOCOL_COMMANDS.DOWNLOAD + PROTOCOL_COMMANDS.DOWNLOAD, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccounts[1], messageHashBytes) @@ -579,7 +582,8 @@ describe('********** [Credentials Flow] - Should run a complete node flo const messageHashBytes = createHashForSignature( await consumerAccounts[2].getAddress(), nonce, - PROTOCOL_COMMANDS.DOWNLOAD + PROTOCOL_COMMANDS.DOWNLOAD, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccounts[2], messageHashBytes) diff --git a/src/test/integration/download.test.ts b/src/test/integration/download.test.ts index 2308efbab..dc487f19e 100644 --- a/src/test/integration/download.test.ts +++ b/src/test/integration/download.test.ts @@ -279,7 +279,8 @@ describe('********** [Download Flow] - Should run a complete node flow.' const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.DOWNLOAD + PROTOCOL_COMMANDS.DOWNLOAD, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const downloadTask = { @@ -312,7 +313,8 @@ describe('********** [Download Flow] - Should run a complete node flow.' const messageHashBytes = createHashForSignature( await anotherConsumer.getAddress(), nonce, - PROTOCOL_COMMANDS.DOWNLOAD + PROTOCOL_COMMANDS.DOWNLOAD, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(anotherConsumer, messageHashBytes) diff --git a/src/test/integration/encryptFile.test.ts b/src/test/integration/encryptFile.test.ts index f26038652..b498b140f 100644 --- a/src/test/integration/encryptFile.test.ts +++ b/src/test/integration/encryptFile.test.ts @@ -57,7 +57,8 @@ describe('********** Encrypt File', () => { const messageHashBytes = createHashForSignature( await anotherConsumerWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.ENCRYPT_FILE + PROTOCOL_COMMANDS.ENCRYPT_FILE, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(anotherConsumerWallet, messageHashBytes) const encryptFileTask: EncryptFileCommand = { @@ -94,7 +95,8 @@ describe('********** Encrypt File', () => { const messageHashBytes = createHashForSignature( await anotherConsumerWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.ENCRYPT_FILE + PROTOCOL_COMMANDS.ENCRYPT_FILE, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(anotherConsumerWallet, messageHashBytes) const encryptFileTask: EncryptFileCommand = { @@ -126,7 +128,8 @@ describe('********** Encrypt File', () => { const messageHashBytes = createHashForSignature( await anotherConsumerWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.ENCRYPT_FILE + PROTOCOL_COMMANDS.ENCRYPT_FILE, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(anotherConsumerWallet, messageHashBytes) const encryptFileTask: EncryptFileCommand = { @@ -156,7 +159,8 @@ describe('********** Encrypt File', () => { const messageHashBytes = createHashForSignature( await anotherConsumerWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.ENCRYPT_FILE + PROTOCOL_COMMANDS.ENCRYPT_FILE, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(anotherConsumerWallet, messageHashBytes) const encryptFileTask: EncryptFileCommand = { diff --git a/src/test/integration/maintenanceDrain.test.ts b/src/test/integration/maintenanceDrain.test.ts index bd6dea3e8..1e2a971b2 100644 --- a/src/test/integration/maintenanceDrain.test.ts +++ b/src/test/integration/maintenanceDrain.test.ts @@ -78,7 +78,12 @@ describe('Maintenance mode — running job survives drain while new jobs are rej const nonce = Date.now().toString() const signature = await safeSign( consumerAccount, - createHashForSignature(consumerAddress, nonce, PROTOCOL_COMMANDS.FREE_COMPUTE_START) + createHashForSignature( + consumerAddress, + nonce, + PROTOCOL_COMMANDS.FREE_COMPUTE_START, + oceanNode.getKeyManager().getPeerIdString() + ) ) return { command: PROTOCOL_COMMANDS.FREE_COMPUTE_START, @@ -102,7 +107,12 @@ describe('Maintenance mode — running job survives drain while new jobs are rej const nonce = Date.now().toString() const signature = await safeSign( consumerAccount, - createHashForSignature(consumerAddress, nonce, PROTOCOL_COMMANDS.COMPUTE_STOP) + createHashForSignature( + consumerAddress, + nonce, + PROTOCOL_COMMANDS.COMPUTE_STOP, + oceanNode.getKeyManager().getPeerIdString() + ) ) const task: ComputeStopCommand = { command: PROTOCOL_COMMANDS.COMPUTE_STOP, @@ -318,7 +328,8 @@ describe('Maintenance mode — running job survives drain while new jobs are rej createHashForSignature( consumerAddress, logsNonce, - PROTOCOL_COMMANDS.COMPUTE_GET_STREAMABLE_LOGS + PROTOCOL_COMMANDS.COMPUTE_GET_STREAMABLE_LOGS, + oceanNode.getKeyManager().getPeerIdString() ) ) const logs = await new ComputeGetStreamableLogsHandler(oceanNode).handle({ @@ -336,7 +347,8 @@ describe('Maintenance mode — running job survives drain while new jobs are rej createHashForSignature( consumerAddress, resNonce, - PROTOCOL_COMMANDS.COMPUTE_GET_RESULT + PROTOCOL_COMMANDS.COMPUTE_GET_RESULT, + oceanNode.getKeyManager().getPeerIdString() ) ) const result = await new ComputeGetResultHandler(oceanNode).handle({ diff --git a/src/test/integration/operationsDashboard.test.ts b/src/test/integration/operationsDashboard.test.ts index 3da4047dc..2348f01ae 100644 --- a/src/test/integration/operationsDashboard.test.ts +++ b/src/test/integration/operationsDashboard.test.ts @@ -123,7 +123,8 @@ describe('********** OperationsDashboard tests', () => { const messageHashBytes = createHashForSignature( await adminWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.STOP_NODE + PROTOCOL_COMMANDS.STOP_NODE, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(adminWallet, messageHashBytes) const stopNodeCommand: AdminStopNodeCommand = { @@ -152,7 +153,8 @@ describe('********** OperationsDashboard tests', () => { let messageHashBytes = createHashForSignature( await adminWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.COLLECT_FEES + PROTOCOL_COMMANDS.COLLECT_FEES, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(adminWallet, messageHashBytes) const fees = new ProviderFees(oceanNode) @@ -189,7 +191,8 @@ describe('********** OperationsDashboard tests', () => { messageHashBytes = createHashForSignature( await adminWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.COLLECT_FEES + PROTOCOL_COMMANDS.COLLECT_FEES, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(adminWallet, messageHashBytes) const collectFeesCommandWrongNode: AdminCollectFeesCommand = { @@ -211,7 +214,8 @@ describe('********** OperationsDashboard tests', () => { messageHashBytes = createHashForSignature( await adminWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.COLLECT_FEES + PROTOCOL_COMMANDS.COLLECT_FEES, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(adminWallet, messageHashBytes) const collectFeesCommandWrongAmount: AdminCollectFeesCommand = { @@ -250,7 +254,8 @@ describe('********** OperationsDashboard tests', () => { const messageHashBytes = createHashForSignature( await adminWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.REINDEX_TX + PROTOCOL_COMMANDS.REINDEX_TX, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(adminWallet, messageHashBytes) @@ -330,7 +335,8 @@ describe('********** OperationsDashboard tests', () => { const messageHashBytes = createHashForSignature( await adminWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.REINDEX_CHAIN + PROTOCOL_COMMANDS.REINDEX_CHAIN, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(adminWallet, messageHashBytes) const reindexChainCommand: AdminReindexChainCommand = { @@ -401,7 +407,8 @@ describe('********** OperationsDashboard tests', () => { let messageHashBytes = createHashForSignature( await adminWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.HANDLE_INDEXING_THREAD + PROTOCOL_COMMANDS.HANDLE_INDEXING_THREAD, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(adminWallet, messageHashBytes) @@ -418,7 +425,8 @@ describe('********** OperationsDashboard tests', () => { messageHashBytes = createHashForSignature( await adminWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.HANDLE_INDEXING_THREAD + PROTOCOL_COMMANDS.HANDLE_INDEXING_THREAD, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(adminWallet, messageHashBytes) const indexingStopCommand: StartStopIndexingCommand = { @@ -434,7 +442,8 @@ describe('********** OperationsDashboard tests', () => { messageHashBytes = createHashForSignature( await adminWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.HANDLE_INDEXING_THREAD + PROTOCOL_COMMANDS.HANDLE_INDEXING_THREAD, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(adminWallet, messageHashBytes) indexingStopCommand.signature = signature @@ -453,7 +462,8 @@ describe('********** OperationsDashboard tests', () => { messageHashBytes = createHashForSignature( await adminWallet.getAddress(), nonce, - PROTOCOL_COMMANDS.HANDLE_INDEXING_THREAD + PROTOCOL_COMMANDS.HANDLE_INDEXING_THREAD, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(adminWallet, messageHashBytes) indexingStartCommand.signature = signature diff --git a/src/test/integration/persistentStorage.test.ts b/src/test/integration/persistentStorage.test.ts index 36738365b..21e5f8421 100644 --- a/src/test/integration/persistentStorage.test.ts +++ b/src/test/integration/persistentStorage.test.ts @@ -182,7 +182,8 @@ describe('********** Persistent storage handlers (integration)', functio let messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumer, messageHashBytes) @@ -209,7 +210,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const uploadRes = await new PersistentStorageUploadFileHandler(oceanNode).handle({ @@ -230,7 +232,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_LIST_FILES + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_LIST_FILES, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const listRes = await new PersistentStorageListFilesHandler(oceanNode).handle({ @@ -251,7 +254,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_DELETE_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_DELETE_FILE, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const delRes = await new PersistentStorageDeleteFileHandler(oceanNode).handle({ @@ -271,7 +275,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_LIST_FILES + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_LIST_FILES, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const listAfterDel = await new PersistentStorageListFilesHandler(oceanNode).handle({ @@ -294,7 +299,8 @@ describe('********** Persistent storage handlers (integration)', functio let messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumer, messageHashBytes) @@ -316,7 +322,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const uploadRes = await new PersistentStorageUploadFileHandler(oceanNode).handle({ @@ -334,7 +341,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_FILE_OBJECT + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_FILE_OBJECT, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const objRes = await new PersistentStorageGetFileObjectHandler(oceanNode).handle({ @@ -360,7 +368,8 @@ describe('********** Persistent storage handlers (integration)', functio let messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumer, messageHashBytes) @@ -383,7 +392,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const uploadRes = await new PersistentStorageUploadFileHandler(oceanNode).handle({ @@ -402,7 +412,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_DOWNLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_DOWNLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const downloadRes = await new PersistentStorageDownloadFileHandler(oceanNode).handle({ @@ -428,7 +439,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( strangerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_DOWNLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_DOWNLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(forbiddenConsumer, messageHashBytes) const deniedRes = await new PersistentStorageDownloadFileHandler(oceanNode).handle({ @@ -453,7 +465,8 @@ describe('********** Persistent storage handlers (integration)', functio createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) ) const createRes = await new PersistentStorageCreateBucketHandler(oceanNode).handle({ @@ -478,7 +491,8 @@ describe('********** Persistent storage handlers (integration)', functio createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) ) const uploadRes = await new PersistentStorageUploadFileHandler(oceanNode).handle({ @@ -518,7 +532,8 @@ describe('********** Persistent storage handlers (integration)', functio createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) ) const createRes = await new PersistentStorageCreateBucketHandler(oceanNode).handle({ @@ -543,7 +558,8 @@ describe('********** Persistent storage handlers (integration)', functio createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) ) const uploadRes = await new PersistentStorageUploadFileHandler(oceanNode).handle({ @@ -613,7 +629,8 @@ describe('********** Persistent storage handlers (integration)', functio createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) ) const createRes = await new PersistentStorageCreateBucketHandler(oceanNode).handle({ @@ -637,7 +654,8 @@ describe('********** Persistent storage handlers (integration)', functio createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) ) const uploadRes = await new PersistentStorageUploadFileHandler(oceanNode).handle({ @@ -694,7 +712,8 @@ describe('********** Persistent storage handlers (integration)', functio const messageHashBytes = createHashForSignature( forbiddenConsumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(forbiddenConsumer, messageHashBytes) @@ -718,7 +737,8 @@ describe('********** Persistent storage handlers (integration)', functio let messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumer, messageHashBytes) @@ -741,7 +761,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( forbiddenConsumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_LIST_FILES + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_LIST_FILES, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(forbiddenConsumer, messageHashBytes) const listRes = await new PersistentStorageListFilesHandler(oceanNode).handle({ @@ -760,7 +781,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( forbiddenConsumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(forbiddenConsumer, messageHashBytes) const uploadRes = await new PersistentStorageUploadFileHandler(oceanNode).handle({ @@ -784,7 +806,8 @@ describe('********** Persistent storage handlers (integration)', functio let messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumer, messageHashBytes) @@ -805,7 +828,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPLOAD_FILE, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const uploadRes = await new PersistentStorageUploadFileHandler(oceanNode).handle({ @@ -824,7 +848,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( forbiddenConsumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_FILE_OBJECT + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_FILE_OBJECT, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(forbiddenConsumer, messageHashBytes) @@ -849,7 +874,8 @@ describe('********** Persistent storage handlers (integration)', functio let messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumer, messageHashBytes) @@ -870,7 +896,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_FILE_OBJECT + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_FILE_OBJECT, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) @@ -894,7 +921,8 @@ describe('********** Persistent storage handlers (integration)', functio let messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumer, messageHashBytes) @@ -915,7 +943,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_DELETE_FILE + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_DELETE_FILE, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) @@ -940,7 +969,8 @@ describe('********** Persistent storage handlers (integration)', functio let messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_BUCKETS + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_BUCKETS, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumer, messageHashBytes) const beforeCreate = await new PersistentStorageGetBucketsHandler(oceanNode).handle({ @@ -960,7 +990,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const createRes = await new PersistentStorageCreateBucketHandler(oceanNode).handle({ @@ -979,7 +1010,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_BUCKETS + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_BUCKETS, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const afterCreate = await new PersistentStorageGetBucketsHandler(oceanNode).handle({ @@ -1013,7 +1045,12 @@ describe('********** Persistent storage handlers (integration)', functio const address = await signer.getAddress() const signature = await safeSign( signer, - createHashForSignature(address, nonce, command) + createHashForSignature( + address, + nonce, + command, + oceanNode.getKeyManager().getPeerIdString() + ) ) return { command, @@ -1117,7 +1154,8 @@ describe('********** Persistent storage handlers (integration)', functio const messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumer, messageHashBytes) const validation = await new PersistentStorageCreateBucketHandler(oceanNode).validate( @@ -1140,7 +1178,8 @@ describe('********** Persistent storage handlers (integration)', functio let messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumer, messageHashBytes) const label = 'my-dataset-bucket' @@ -1163,7 +1202,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_BUCKETS + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_BUCKETS, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const listRes = await new PersistentStorageGetBucketsHandler(oceanNode).handle({ @@ -1188,7 +1228,8 @@ describe('********** Persistent storage handlers (integration)', functio const messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumer, messageHashBytes) const createRes = await new PersistentStorageCreateBucketHandler(oceanNode).handle({ @@ -1212,7 +1253,8 @@ describe('********** Persistent storage handlers (integration)', functio let messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumer, messageHashBytes) const createRes = await new PersistentStorageCreateBucketHandler(oceanNode).handle({ @@ -1233,7 +1275,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPDATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPDATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const updateRes = await new PersistentStorageUpdateBucketHandler(oceanNode).handle({ @@ -1254,7 +1297,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_BUCKETS + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_GET_BUCKETS, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const listRes = await new PersistentStorageGetBucketsHandler(oceanNode).handle({ @@ -1277,7 +1321,8 @@ describe('********** Persistent storage handlers (integration)', functio let messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumer, messageHashBytes) const createRes = await new PersistentStorageCreateBucketHandler(oceanNode).handle({ @@ -1297,7 +1342,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPDATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPDATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(consumer, messageHashBytes) const updateRes = await new PersistentStorageUpdateBucketHandler(oceanNode).handle({ @@ -1323,7 +1369,8 @@ describe('********** Persistent storage handlers (integration)', functio let messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) let signature = await safeSign(consumer, messageHashBytes) const createRes = await new PersistentStorageCreateBucketHandler(oceanNode).handle({ @@ -1342,7 +1389,8 @@ describe('********** Persistent storage handlers (integration)', functio messageHashBytes = createHashForSignature( forbiddenConsumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPDATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPDATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) signature = await safeSign(forbiddenConsumer, messageHashBytes) const updateRes = await new PersistentStorageUpdateBucketHandler(oceanNode).handle({ @@ -1365,7 +1413,8 @@ describe('********** Persistent storage handlers (integration)', functio const messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPDATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_UPDATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumer, messageHashBytes) const updateRes = await new PersistentStorageUpdateBucketHandler(oceanNode).handle({ @@ -1422,7 +1471,8 @@ describe('********** Persistent storage handlers (integration)', functio const messageHashBytes = createHashForSignature( consumerAddress, nonce, - PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET + PROTOCOL_COMMANDS.PERSISTENT_STORAGE_CREATE_BUCKET, + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumer, messageHashBytes) diff --git a/src/test/integration/services.test.ts b/src/test/integration/services.test.ts index 7806788f7..e6e5b754b 100644 --- a/src/test/integration/services.test.ts +++ b/src/test/integration/services.test.ts @@ -122,7 +122,12 @@ describe('********** Service on Demand', () => { async function signFor(signer: Signer, command: string) { const addr = await signer.getAddress() const nonce = Date.now().toString() - const hash = createHashForSignature(addr, nonce, command) + const hash = createHashForSignature( + addr, + nonce, + command, + oceanNode.getKeyManager().getPeerIdString() + ) const signature = await safeSign(signer, hash) return { consumerAddress: addr, nonce, signature } } diff --git a/src/test/integration/stopJob.test.ts b/src/test/integration/stopJob.test.ts index fe8dc7fec..1a0cc83d8 100644 --- a/src/test/integration/stopJob.test.ts +++ b/src/test/integration/stopJob.test.ts @@ -73,7 +73,8 @@ describe('********** Admin StopJob Handler Integration Tests', () => { const messageHashBytes = createHashForSignature( await adminAccount.getAddress(), nonce, - command + command, + oceanNode.getKeyManager().getPeerIdString() ) return safeSign(adminAccount, messageHashBytes) } @@ -85,7 +86,8 @@ describe('********** Admin StopJob Handler Integration Tests', () => { const messageHashBytes = createHashForSignature( await nonAdminAccount.getAddress(), nonce, - command + command, + oceanNode.getKeyManager().getPeerIdString() ) return safeSign(nonAdminAccount, messageHashBytes) } diff --git a/src/test/unit/download.test.ts b/src/test/unit/download.test.ts index 425c7af65..3f1728e2c 100644 --- a/src/test/unit/download.test.ts +++ b/src/test/unit/download.test.ts @@ -104,7 +104,9 @@ describe('Should validate files structure for download', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.ENCRYPT + PROTOCOL_COMMANDS.ENCRYPT, + // every signed command binds the verifier node's peerId (anti-replay) + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const result = await new EncryptHandler(oceanNode).handle({ @@ -175,7 +177,9 @@ describe('Should validate files structure for download', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.ENCRYPT + PROTOCOL_COMMANDS.ENCRYPT, + // every signed command binds the verifier node's peerId (anti-replay) + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const result = await new EncryptHandler(oceanNode).handle({ diff --git a/src/test/unit/indexer/validation.test.ts b/src/test/unit/indexer/validation.test.ts index 1e1fd9d5d..94f21272e 100644 --- a/src/test/unit/indexer/validation.test.ts +++ b/src/test/unit/indexer/validation.test.ts @@ -184,7 +184,9 @@ describe('Schema validation tests', () => { const messageHashBytes = createHashForSignature( await consumerAccount.getAddress(), nonce, - PROTOCOL_COMMANDS.VALIDATE_DDO + PROTOCOL_COMMANDS.VALIDATE_DDO, + // every signed command binds the verifier node's peerId (anti-replay) + oceanNode.getKeyManager().getPeerIdString() ) const signature = await safeSign(consumerAccount, messageHashBytes) const task = { diff --git a/src/test/unit/policyServer.test.ts b/src/test/unit/policyServer.test.ts index 857cce0b4..c066e37a7 100644 --- a/src/test/unit/policyServer.test.ts +++ b/src/test/unit/policyServer.test.ts @@ -11,6 +11,7 @@ const CONSUMER = '0x0000000000000000000000000000000000000abc' const VICTIM = '0x0000000000000000000000000000000000000def' const TOKEN = 'eyJhbGciOiJIUzI1NiJ9.fake.token' const DDO = { id: 'did:op:1234', nftAddress: '0xnft' } +const NODE_PEER_ID = '16Uiu2HAmNodePeerIdForPolicyServerTest' interface FakeOpts { // what Auth.validateAuthenticationOrToken resolves to @@ -32,7 +33,8 @@ function buildFakes(opts: FakeOpts = {}) { getConfig: (): any => ({ rateLimit: undefined as number | undefined }), getDatabase: () => Promise.resolve({ ddo: { retrieve } }), getAuth: () => - opts.authConfigured === false ? undefined : { validateAuthenticationOrToken } + opts.authConfigured === false ? undefined : { validateAuthenticationOrToken }, + getKeyManager: () => ({ getPeerIdString: () => NODE_PEER_ID }) } return { node, validateAuthenticationOrToken, retrieve } @@ -260,6 +262,8 @@ describe('PolicyServerInitializeHandler', () => { expect(policyServer.authorization).to.equal(TOKEN) expect(policyServer.nonce).to.equal('1') expect(policyServer.signature).to.equal('0xsignature') + // the node's own peerId is forwarded so a PolicyServer can re-verify the peer-bound signature + expect(policyServer.issuerPeerId).to.equal(NODE_PEER_ID) }) it('returns 404 when the DDO does not exist', async () => {