From 787bad07ecd0b94a3f48b5ddc04a1b9564c7f474 Mon Sep 17 00:00:00 2001 From: enrique Date: Fri, 1 Mar 2024 12:24:55 +0100 Subject: [PATCH 1/7] feat: prepare methods to new profile restrictions --- integration/nevermined/Permissions.test.ts | 7 ++++++- integration/nevermined/Profiles.test.ts | 4 +--- package.json | 2 +- src/services/metadata/Profiles.ts | 10 ++++++---- src/services/metadata/types.ts | 5 +++++ test/profiles/Profiles.test.ts | 2 +- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/integration/nevermined/Permissions.test.ts b/integration/nevermined/Permissions.test.ts index 9b8ff04d9..72d62cd13 100644 --- a/integration/nevermined/Permissions.test.ts +++ b/integration/nevermined/Permissions.test.ts @@ -17,7 +17,12 @@ describe('Permissions', () => { config.marketplaceAuthToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIweGUyREQwOWQ3MTlEYTg5ZTVhM0QwRjI1NDljN0UyNDU2NmU5NDcyNjAiLCJzdWIiOiJ1LWU2YzI2NDhjLTIwZjktNDJlMC1iMWZlLWZjZWEwNzA4ODY3NyIsInJvbGVzIjpbImFkbWluIl0sImlhdCI6MTY1MTI0ODM1NCwiZXhwIjoxNzUxMjUxOTU0fQ.p9fr_c_HVlJzY1cJSGDod1zMdhRCRWdExOB_UxMDrKg' - const userProfile = await nevermined.services.profiles.findOneByAddress(account1.getId()) + const userProfileRestricted = await nevermined.services.profiles.findOneByAddress( + account1.getId(), + ) + const userProfile = await nevermined.services.profiles.findOneByUserId( + userProfileRestricted.userId, + ) newPermission = { userId: userProfile.userId, diff --git a/integration/nevermined/Profiles.test.ts b/integration/nevermined/Profiles.test.ts index a57f34410..5ba993588 100644 --- a/integration/nevermined/Profiles.test.ts +++ b/integration/nevermined/Profiles.test.ts @@ -68,10 +68,8 @@ describe('User Profiles', () => { const response = await nevermined.services.profiles.findOneByAddress(account3.getId()) assert.deepEqual(response, { - ...newProfile, userId: response.userId, - creationDate: response.creationDate, - updateDate: response.updateDate, + name: response.name, }) }) diff --git a/package.json b/package.json index 0780507a4..45fd4bee0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/sdk", - "version": "2.2.3", + "version": "2.2.4", "description": "Javascript SDK for connecting with Nevermined Data Platform ", "main": "./dist/node/sdk.js", "typings": "./dist/node/sdk.d.ts", diff --git a/src/services/metadata/Profiles.ts b/src/services/metadata/Profiles.ts index 31f0d4ccd..7e2be9e00 100644 --- a/src/services/metadata/Profiles.ts +++ b/src/services/metadata/Profiles.ts @@ -1,5 +1,5 @@ import { MarketplaceApi } from './MarketplaceAPI' -import { NewProfile, Profile } from './types' +import { NewProfile, Profile, ProfileRestricted } from './types' import { HttpError, ApiError } from '../../errors' const profilePath = '/api/v1/metadata/profiles' @@ -56,7 +56,9 @@ export class Profiles extends MarketplaceApi { const fullUrl = `${this.url}${profilePath}/${userId}` try { - const response = await this.nevermined.utils.fetch.get(fullUrl) + const response = await this.nevermined.utils.fetch.get(fullUrl, { + Authorization: `Bearer ${this.config.marketplaceAuthToken}`, + }) if (response.ok) { return response.json() as Promise @@ -71,14 +73,14 @@ export class Profiles extends MarketplaceApi { } } - public async findOneByAddress(address: string): Promise { + public async findOneByAddress(address: string): Promise { const fullUrl = `${this.url}${profilePath}/address/${address}` try { const response = await this.nevermined.utils.fetch.get(fullUrl) if (response.ok) { - return response.json() as Promise + return response.json() as Promise } throw new HttpError( diff --git a/src/services/metadata/types.ts b/src/services/metadata/types.ts index f73f29f01..d21ea1ce2 100644 --- a/src/services/metadata/types.ts +++ b/src/services/metadata/types.ts @@ -49,3 +49,8 @@ export interface Profile extends NewProfile { creationDate: Date updateDate: Date } + +export interface ProfileRestricted { + userId: string + name?: string +} diff --git a/test/profiles/Profiles.test.ts b/test/profiles/Profiles.test.ts index 71e69a405..0a52267a1 100644 --- a/test/profiles/Profiles.test.ts +++ b/test/profiles/Profiles.test.ts @@ -75,7 +75,7 @@ describe('Profiles', () => { const result = await profiles.findOneByAddress(profile.addresses[0]) - assert.equal(result, profile) + assert.equal(result, { userId: profile.userId, name: profile.name }) }) it('should update a profile by userId', async () => { From 5e99ce7263e5c1de0553d6279e76223198fdb780 Mon Sep 17 00:00:00 2001 From: enrique Date: Fri, 1 Mar 2024 12:52:29 +0100 Subject: [PATCH 2/7] fix: unit test --- test/profiles/Profiles.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/profiles/Profiles.test.ts b/test/profiles/Profiles.test.ts index 0a52267a1..78331c67c 100644 --- a/test/profiles/Profiles.test.ts +++ b/test/profiles/Profiles.test.ts @@ -70,7 +70,7 @@ describe('Profiles', () => { it('should get a profile by address', async () => { spy.on(nevermined.utils.fetch, 'get', () => { - return reponsify(profile) + return reponsify({ userId: profile.userId, name: profile.name }) }) const result = await profiles.findOneByAddress(profile.addresses[0]) From 38014e6e8aa417417d83db0703def838c89f3ac7 Mon Sep 17 00:00:00 2001 From: enrique Date: Fri, 1 Mar 2024 12:59:10 +0100 Subject: [PATCH 3/7] feat: update name --- integration/nevermined/Permissions.test.ts | 6 ++---- src/services/metadata/Profiles.ts | 6 +++--- src/services/metadata/types.ts | 2 +- test/profiles/Profiles.test.ts | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/integration/nevermined/Permissions.test.ts b/integration/nevermined/Permissions.test.ts index 72d62cd13..98d6e8ad6 100644 --- a/integration/nevermined/Permissions.test.ts +++ b/integration/nevermined/Permissions.test.ts @@ -17,11 +17,9 @@ describe('Permissions', () => { config.marketplaceAuthToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIweGUyREQwOWQ3MTlEYTg5ZTVhM0QwRjI1NDljN0UyNDU2NmU5NDcyNjAiLCJzdWIiOiJ1LWU2YzI2NDhjLTIwZjktNDJlMC1iMWZlLWZjZWEwNzA4ODY3NyIsInJvbGVzIjpbImFkbWluIl0sImlhdCI6MTY1MTI0ODM1NCwiZXhwIjoxNzUxMjUxOTU0fQ.p9fr_c_HVlJzY1cJSGDod1zMdhRCRWdExOB_UxMDrKg' - const userProfileRestricted = await nevermined.services.profiles.findOneByAddress( - account1.getId(), - ) + const userProfileReduced = await nevermined.services.profiles.findOneByAddress(account1.getId()) const userProfile = await nevermined.services.profiles.findOneByUserId( - userProfileRestricted.userId, + userProfileReduced.userId, ) newPermission = { diff --git a/src/services/metadata/Profiles.ts b/src/services/metadata/Profiles.ts index 7e2be9e00..48031aa66 100644 --- a/src/services/metadata/Profiles.ts +++ b/src/services/metadata/Profiles.ts @@ -1,5 +1,5 @@ import { MarketplaceApi } from './MarketplaceAPI' -import { NewProfile, Profile, ProfileRestricted } from './types' +import { NewProfile, Profile, ReducedProfile } from './types' import { HttpError, ApiError } from '../../errors' const profilePath = '/api/v1/metadata/profiles' @@ -73,14 +73,14 @@ export class Profiles extends MarketplaceApi { } } - public async findOneByAddress(address: string): Promise { + public async findOneByAddress(address: string): Promise { const fullUrl = `${this.url}${profilePath}/address/${address}` try { const response = await this.nevermined.utils.fetch.get(fullUrl) if (response.ok) { - return response.json() as Promise + return response.json() as Promise } throw new HttpError( diff --git a/src/services/metadata/types.ts b/src/services/metadata/types.ts index d21ea1ce2..b01b100b1 100644 --- a/src/services/metadata/types.ts +++ b/src/services/metadata/types.ts @@ -50,7 +50,7 @@ export interface Profile extends NewProfile { updateDate: Date } -export interface ProfileRestricted { +export interface ReducedProfile { userId: string name?: string } diff --git a/test/profiles/Profiles.test.ts b/test/profiles/Profiles.test.ts index 78331c67c..2aa5b8c9b 100644 --- a/test/profiles/Profiles.test.ts +++ b/test/profiles/Profiles.test.ts @@ -75,7 +75,7 @@ describe('Profiles', () => { const result = await profiles.findOneByAddress(profile.addresses[0]) - assert.equal(result, { userId: profile.userId, name: profile.name }) + assert.deepEqual(result, { userId: profile.userId, name: profile.name }) }) it('should update a profile by userId', async () => { From 8f7a2c64189d0d8503c6d0b6b9d35c658a4e5757 Mon Sep 17 00:00:00 2001 From: enrique Date: Fri, 1 Mar 2024 13:04:19 +0100 Subject: [PATCH 4/7] feat: add marketplace version in actions --- .github/workflows/testing-nightly.yml | 1 + .github/workflows/testing-node.yml | 1 + .github/workflows/testing.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/testing-nightly.yml b/.github/workflows/testing-nightly.yml index 00d78913a..dd52d9fdc 100644 --- a/.github/workflows/testing-nightly.yml +++ b/.github/workflows/testing-nightly.yml @@ -67,6 +67,7 @@ jobs: estuary: 'true' compute: 'true' contracts-version: 'latest' + marketplace-version: 'latest' node-version: 'develop' - name: Install dependencies diff --git a/.github/workflows/testing-node.yml b/.github/workflows/testing-node.yml index 6af7c5751..5f54fcf79 100644 --- a/.github/workflows/testing-node.yml +++ b/.github/workflows/testing-node.yml @@ -26,6 +26,7 @@ jobs: opengsn: 'true' estuary: 'true' contracts-version: 'latest' + marketplace-version: 'latest' node: 'false' - name: Install dependencies diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index f23d80781..6a6cd23fb 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -19,6 +19,7 @@ jobs: opengsn: 'true' estuary: 'true' node-version: 'latest' + marketplace-version: 'latest' contracts-version: 'latest' - name: Install dependencies From f77f398c28ed2abfd5073da55a48d61937fb0e4c Mon Sep 17 00:00:00 2001 From: enrique Date: Fri, 1 Mar 2024 13:19:21 +0100 Subject: [PATCH 5/7] fix: permission test --- integration/nevermined/Permissions.test.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/integration/nevermined/Permissions.test.ts b/integration/nevermined/Permissions.test.ts index 98d6e8ad6..340c0e22b 100644 --- a/integration/nevermined/Permissions.test.ts +++ b/integration/nevermined/Permissions.test.ts @@ -17,16 +17,13 @@ describe('Permissions', () => { config.marketplaceAuthToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIweGUyREQwOWQ3MTlEYTg5ZTVhM0QwRjI1NDljN0UyNDU2NmU5NDcyNjAiLCJzdWIiOiJ1LWU2YzI2NDhjLTIwZjktNDJlMC1iMWZlLWZjZWEwNzA4ODY3NyIsInJvbGVzIjpbImFkbWluIl0sImlhdCI6MTY1MTI0ODM1NCwiZXhwIjoxNzUxMjUxOTU0fQ.p9fr_c_HVlJzY1cJSGDod1zMdhRCRWdExOB_UxMDrKg' - const userProfileReduced = await nevermined.services.profiles.findOneByAddress(account1.getId()) - const userProfile = await nevermined.services.profiles.findOneByUserId( - userProfileReduced.userId, - ) + const userProfile = await nevermined.services.profiles.findOneByAddress(account1.getId()) newPermission = { userId: userProfile.userId, type: [PermissionType.Read, PermissionType.Update, PermissionType.Delete], issuer: account2.getId(), - holder: userProfile.addresses[0], + holder: account1.getId(), } }) From 70567d8454b25f1e87a021e57a384e0139309c6a Mon Sep 17 00:00:00 2001 From: enrique Date: Fri, 1 Mar 2024 13:50:34 +0100 Subject: [PATCH 6/7] feat: try with other version --- .github/workflows/testing-nightly.yml | 2 +- .github/workflows/testing-node.yml | 2 +- .github/workflows/testing.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/testing-nightly.yml b/.github/workflows/testing-nightly.yml index dd52d9fdc..84a9fad30 100644 --- a/.github/workflows/testing-nightly.yml +++ b/.github/workflows/testing-nightly.yml @@ -67,7 +67,7 @@ jobs: estuary: 'true' compute: 'true' contracts-version: 'latest' - marketplace-version: 'latest' + marketplace-version: 'v0.8.0' node-version: 'develop' - name: Install dependencies diff --git a/.github/workflows/testing-node.yml b/.github/workflows/testing-node.yml index 5f54fcf79..261fb79f9 100644 --- a/.github/workflows/testing-node.yml +++ b/.github/workflows/testing-node.yml @@ -26,7 +26,7 @@ jobs: opengsn: 'true' estuary: 'true' contracts-version: 'latest' - marketplace-version: 'latest' + marketplace-version: 'v0.8.0' node: 'false' - name: Install dependencies diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 6a6cd23fb..ef81373e1 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -19,7 +19,7 @@ jobs: opengsn: 'true' estuary: 'true' node-version: 'latest' - marketplace-version: 'latest' + marketplace-version: 'v0.8.0' contracts-version: 'latest' - name: Install dependencies From 125fa093aa106b5737916b65dde72a9ab17e355e Mon Sep 17 00:00:00 2001 From: enrique Date: Fri, 1 Mar 2024 14:42:41 +0100 Subject: [PATCH 7/7] feat: revert force version --- .github/workflows/testing-nightly.yml | 1 - .github/workflows/testing-node.yml | 1 - .github/workflows/testing.yml | 1 - 3 files changed, 3 deletions(-) diff --git a/.github/workflows/testing-nightly.yml b/.github/workflows/testing-nightly.yml index 84a9fad30..00d78913a 100644 --- a/.github/workflows/testing-nightly.yml +++ b/.github/workflows/testing-nightly.yml @@ -67,7 +67,6 @@ jobs: estuary: 'true' compute: 'true' contracts-version: 'latest' - marketplace-version: 'v0.8.0' node-version: 'develop' - name: Install dependencies diff --git a/.github/workflows/testing-node.yml b/.github/workflows/testing-node.yml index 261fb79f9..6af7c5751 100644 --- a/.github/workflows/testing-node.yml +++ b/.github/workflows/testing-node.yml @@ -26,7 +26,6 @@ jobs: opengsn: 'true' estuary: 'true' contracts-version: 'latest' - marketplace-version: 'v0.8.0' node: 'false' - name: Install dependencies diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index ef81373e1..f23d80781 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -19,7 +19,6 @@ jobs: opengsn: 'true' estuary: 'true' node-version: 'latest' - marketplace-version: 'v0.8.0' contracts-version: 'latest' - name: Install dependencies