Skip to content

Commit 4544b33

Browse files
Update publisherTrustedAlgorithmPublishers and publisherTrustedAlgorithms (#950)
* Update publisherTrustedAlgorithmPublishers and publisherTrustedAlgorithm logic for allowing all datasets DIDs or algorithm DIDs. * tweak. * Refactor logic. * Added tests for new trusted algorithm flow. * Fix lint. * tweaks. * Fix. * Updated test. * Fix lint. * Fix key. * Fix init response. * Fix await * Fix variable of results. * Updated test. * Added tests back. * Print start compute resp. * revert prints. * Fix previous config and stop indexer threads. * Fix lint. * print compute resp. * Cancel expired locks * Bring back tests. * tweak. * Update branch name for cli tests. * Added docker envs for system tests job. * remove address file. * update cli branch. * Update ddo.js version. * Fix credential type according to latest ddo.js update. * fix lint. --------- Co-authored-by: giurgiur99 <giurgiur99@gmail.com>
1 parent 2c66a2c commit 4544b33

9 files changed

Lines changed: 559 additions & 94 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ jobs:
282282
with:
283283
repository: 'oceanprotocol/ocean-cli'
284284
path: 'ocean-cli'
285-
ref: 'main'
285+
ref: 'fix-tests-for-node'
286286
- name: Setup Ocean CLI
287287
working-directory: ${{ github.workspace }}/ocean-cli
288288
run: |

package-lock.json

Lines changed: 38 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"@libp2p/websockets": "^8.1.1",
7474
"@multiformats/multiaddr": "^10.2.0",
7575
"@oceanprotocol/contracts": "^2.3.0",
76-
"@oceanprotocol/ddo-js": "^0.0.6",
76+
"@oceanprotocol/ddo-js": "^0.1.0",
7777
"@types/lodash.clonedeep": "^4.5.7",
7878
"axios": "^1.8.4",
7979
"base58-js": "^2.0.0",

src/components/core/compute/utils.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,27 @@ export async function validateAlgoForDataset(
8686

8787
if (algoDID) {
8888
if (
89-
// if not set allow them all
89+
// if not set deny them all
9090
(!Array.isArray(compute.publisherTrustedAlgorithms) ||
9191
compute.publisherTrustedAlgorithms.length === 0) &&
9292
(!Array.isArray(compute.publisherTrustedAlgorithmPublishers) ||
9393
compute.publisherTrustedAlgorithmPublishers.length === 0)
94+
) {
95+
return false
96+
}
97+
98+
if (
99+
compute.publisherTrustedAlgorithms.includes('*') &&
100+
compute.publisherTrustedAlgorithmPublishers.includes('*')
94101
) {
95102
return true
96103
}
97-
// if is set only allow if match
98-
if (compute.publisherTrustedAlgorithms) {
104+
105+
if (
106+
Array.isArray(compute.publisherTrustedAlgorithms) &&
107+
compute.publisherTrustedAlgorithms.length > 0 &&
108+
!compute.publisherTrustedAlgorithms.includes('*')
109+
) {
99110
const trustedAlgo = compute.publisherTrustedAlgorithms.find(
100111
(algo: any) => algo.did === algoDID
101112
)
@@ -107,7 +118,11 @@ export async function validateAlgoForDataset(
107118
}
108119
return false
109120
}
110-
if (compute.publisherTrustedAlgorithmPublishers) {
121+
if (
122+
Array.isArray(compute.publisherTrustedAlgorithmPublishers) &&
123+
compute.publisherTrustedAlgorithmPublishers.length > 0 &&
124+
!compute.publisherTrustedAlgorithmPublishers.includes('*')
125+
) {
111126
const algoDDO = await new FindDdoHandler(oceanNode).findAndFormatDdo(algoDID)
112127
const algoInstance = DDOManager.getDDOClass(algoDDO)
113128
const { nftAddress } = algoInstance.getDDOFields()

src/test/data/assets.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Credentials } from '@oceanprotocol/ddo-js'
1+
import { Credentials, CREDENTIALS_TYPES } from '@oceanprotocol/ddo-js'
22

33
export const downloadAsset = {
44
'@context': ['https://w3id.org/did/v1'],
@@ -62,17 +62,17 @@ export const downloadAsset = {
6262
const nftLevelCredentials: Credentials = {
6363
allow: [
6464
{
65-
type: 'address',
65+
type: CREDENTIALS_TYPES.ADDRESS,
6666
values: ['0xBE5449a6A97aD46c8558A3356267Ee5D2731ab5e']
6767
},
6868
{
69-
type: 'address',
69+
type: CREDENTIALS_TYPES.ADDRESS,
7070
values: ['0xA78deb2Fa79463945C247991075E2a0e98Ba7A09']
7171
}
7272
],
7373
deny: [
7474
{
75-
type: 'address',
75+
type: CREDENTIALS_TYPES.ADDRESS,
7676
values: ['0x02354A1F160A3fd7ac8b02ee91F04104440B28E7']
7777
}
7878
]
@@ -82,7 +82,7 @@ const serviceLevelCredentials: Credentials = {
8282
allow: [],
8383
deny: [
8484
{
85-
type: 'address',
85+
type: CREDENTIALS_TYPES.ADDRESS,
8686
values: ['0xA78deb2Fa79463945C247991075E2a0e98Ba7A09']
8787
}
8888
]

0 commit comments

Comments
 (0)