Skip to content
Open
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ jobs:
working-directory: ${{ github.workspace }}/barge
run: |
bash -x start_ocean.sh --with-typesense 2>&1 > start-node.log &
env:
NODE_VERSION: pr-1207

- name: Install deps & build
run: npm ci && npm run build:metadata
Expand Down
45 changes: 40 additions & 5 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"cross-fetch": "^4.0.0",
"crypto-js": "^4.1.1",
"decimal.js": "^10.4.1",
"eciesjs": "^0.4.5",
"ethers": "^6.15.0",
"form-data": "^2.3.3",
"jsonwebtoken": "^9.0.2"
Expand Down
6 changes: 6 additions & 0 deletions src/@types/Compute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@
}

export enum FileObjectType {
URL = 'url',

Check warning on line 127 in src/@types/Compute.ts

View workflow job for this annotation

GitHub Actions / lint

'URL' is defined but never used
IPFS = 'ipfs',

Check warning on line 128 in src/@types/Compute.ts

View workflow job for this annotation

GitHub Actions / lint

'IPFS' is defined but never used
ARWEAVE = 'arweave'

Check warning on line 129 in src/@types/Compute.ts

View workflow job for this annotation

GitHub Actions / lint

'ARWEAVE' is defined but never used
}

export enum EncryptMethod {
AES = 'AES',

Check warning on line 133 in src/@types/Compute.ts

View workflow job for this annotation

GitHub Actions / lint

'AES' is defined but never used
ECIES = 'ECIES'

Check warning on line 134 in src/@types/Compute.ts

View workflow job for this annotation

GitHub Actions / lint

'ECIES' is defined but never used
}

export interface HeadersObject {
Expand Down Expand Up @@ -199,3 +199,9 @@
isValid: boolean
message: string
}

export interface dockerRegistryAuth {
username?: string
password?: string
auth?: string
}
40 changes: 40 additions & 0 deletions src/@types/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,43 @@ export interface ServiceEndpoint {
export interface UserCustomParameters {
[key: string]: any
}

export const PROTOCOL_COMMANDS = {
DOWNLOAD: 'download',
ENCRYPT: 'encrypt',
ENCRYPT_FILE: 'encryptFile',
DECRYPT_DDO: 'decryptDDO',
GET_DDO: 'getDDO',
QUERY: 'query',
NONCE: 'nonce',
STATUS: 'status',
DETAILED_STATUS: 'detailedStatus',
FIND_DDO: 'findDDO',
GET_FEES: 'getFees',
FILE_INFO: 'fileInfo',
VALIDATE_DDO: 'validateDDO',
COMPUTE_GET_ENVIRONMENTS: 'getComputeEnvironments',
COMPUTE_START: 'startCompute',
FREE_COMPUTE_START: 'freeStartCompute',
COMPUTE_STOP: 'stopCompute',
COMPUTE_GET_STATUS: 'getComputeStatus',
COMPUTE_GET_STREAMABLE_LOGS: 'getComputeStreamableLogs',
COMPUTE_GET_RESULT: 'getComputeResult',
COMPUTE_INITIALIZE: 'initializeCompute',
STOP_NODE: 'stopNode',
REINDEX_TX: 'reindexTx',
REINDEX_CHAIN: 'reindexChain',
HANDLE_INDEXING_THREAD: 'handleIndexingThread',
COLLECT_FEES: 'collectFees',
POLICY_SERVER_PASSTHROUGH: 'PolicyServerPassthrough',
GET_P2P_PEER: 'getP2PPeer',
GET_P2P_PEERS: 'getP2PPeers',
GET_P2P_NETWORK_STATS: 'getP2PNetworkStats',
FIND_PEER: 'findPeer',
CREATE_AUTH_TOKEN: 'createAuthToken',
INVALIDATE_AUTH_TOKEN: 'invalidateAuthToken',
FETCH_CONFIG: 'fetchConfig',
PUSH_CONFIG: 'pushConfig',
GET_LOGS: 'getLogs',
JOBS: 'jobs'
}
24 changes: 15 additions & 9 deletions src/services/Aquarius.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { sleep } from '../utils/General.js'
import { Signer } from 'ethers'
import { signRequest } from '../utils/SignatureUtils.js'
import { Asset, DDO, DDOManager, ValidateMetadata } from '@oceanprotocol/ddo-js'
import { PROTOCOL_COMMANDS } from '../@types/Provider.js'

export interface SearchQuery {
from?: number
Expand All @@ -25,6 +26,12 @@ export class Aquarius {
this.aquariusURL = aquariusURL
}

// temp, untll we merge aquarius & provider
private getAuthorization(signerOrAuthToken: Signer | string): string | undefined {
const isAuthToken = typeof signerOrAuthToken === 'string'
return isAuthToken ? signerOrAuthToken : undefined
}

/** Resolves a DID
* @param {string} did DID of the asset.
* @param {AbortSignal} signal abort signal
Expand Down Expand Up @@ -136,27 +143,26 @@ export class Aquarius {
nonce = '0'
}
const nextNonce = (Number(nonce) + 1).toString() // have to increase the previous
// same signed message as usual (did + nonce)
// the node will only validate (add his signature if there fields are present and are valid)
// let signatureMessage = publisherAddress
const signatureMessage = publisherAddress + nextNonce
const signature = await signRequest(signer, signatureMessage)
const message = String(
String(await signer.getAddress()) +
String(nextNonce) +
String(PROTOCOL_COMMANDS.VALIDATE_DDO)
)
const signature = await signRequest(signer, message)
const data = { ddo, publisherAddress, nonce: nextNonce, signature }
const response = await fetch(ddoValidateRoute, {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/octet-stream',
Authorization: authorization
'Content-Type': 'application/json',
Authorization: this.getAuthorization(signer)
},
signal
})
const jsonResponse = await response.json()
if (response.status !== 200) {
throw new Error('Metadata validation failed')
}
console.log('Ddo successfully validated')

return {
valid: true,
hash: jsonResponse.hash,
Expand Down
Loading
Loading