From 3b7c176a280bb6876135acbf496f56b75d64bd0d Mon Sep 17 00:00:00 2001 From: Janison Sivarajah Date: Fri, 26 Feb 2021 07:00:42 -0500 Subject: [PATCH] Hotfix: convert pub key for members. (#59) * Hotfix: convert pub key for members. * Hotfix/listdir/convert-pub-key: fix test * Another test fix --- integration_tests/sharing_interactions.spec.ts | 3 +++ packages/storage/src/userStorage.spec.ts | 3 ++- packages/storage/src/userStorage.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/integration_tests/sharing_interactions.spec.ts b/integration_tests/sharing_interactions.spec.ts index 7d66b23..01a4598 100644 --- a/integration_tests/sharing_interactions.spec.ts +++ b/integration_tests/sharing_interactions.spec.ts @@ -85,6 +85,9 @@ describe('Users sharing data', () => { }], }); + const ld = await storage1.listDirectory({ bucket: 'personal', path: '' }); + expect(ld.items[0].members[0].publicKey).to.equal(user2Pk); + expect(shareResult.publicKeys).not.to.be.empty; expect(shareResult.publicKeys[0].type).to.equal(ShareKeyType.Existing); expect(shareResult.publicKeys[0].pk).not.to.be.empty; diff --git a/packages/storage/src/userStorage.spec.ts b/packages/storage/src/userStorage.spec.ts index f6bacaa..c45d761 100644 --- a/packages/storage/src/userStorage.spec.ts +++ b/packages/storage/src/userStorage.spec.ts @@ -1,4 +1,5 @@ import { Identity, GetAddressFromPublicKey } from '@spacehq/users'; +import { tryParsePublicKey } from '@spacehq/utils'; import { PrivateKey } from '@textile/crypto'; import { Buckets, PathAccessRole, PathItem, PushPathResult, Root } from '@textile/hub'; import { expect, use } from 'chai'; @@ -222,7 +223,7 @@ describe('UserStorage', () => { expect(result.items[0].isLocallyAvailable).to.equal(false); expect(result.items[0].backupCount).to.equal(1); expect(result.items[0].members).to.deep.equal([{ - publicKey: pubkey, + publicKey: Buffer.from(tryParsePublicKey(pubkey).pubKey).toString('hex'), role: PathAccessRole.PATH_ACCESS_ROLE_WRITER, address: GetAddressFromPublicKey(pubkey), }]); diff --git a/packages/storage/src/userStorage.ts b/packages/storage/src/userStorage.ts index 941201c..31310f1 100644 --- a/packages/storage/src/userStorage.ts +++ b/packages/storage/src/userStorage.ts @@ -270,7 +270,7 @@ export class UserStorage { ms.forEach((v, k) => { members.push({ - publicKey: k, + publicKey: k === '*' ? '*' : Buffer.from(tryParsePublicKey(k).pubKey).toString('hex'), address: k === '*' ? '' : GetAddressFromPublicKey(k), role: v, });