From 9ffa1b29c37b91635ef83ee0632dff1a568531fe Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Fri, 13 Dec 2019 17:41:33 +0100 Subject: [PATCH 1/2] Fix wrong type for comment key --- packages/mobile/src/identity/commentKey.ts | 4 ++-- packages/mobile/src/identity/verification.ts | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/mobile/src/identity/commentKey.ts b/packages/mobile/src/identity/commentKey.ts index cf990ae1b62..90a76340082 100644 --- a/packages/mobile/src/identity/commentKey.ts +++ b/packages/mobile/src/identity/commentKey.ts @@ -5,8 +5,8 @@ import { contractKit } from 'src/web3/contracts' export async function getCommentKey(address: string): Promise { const accountsWrapper: AccountsWrapper = await contractKit.contracts.getAccounts() - - const hexString = (await accountsWrapper.getDataEncryptionKey(address)).join() + // getDataEncryptionKey actually returns a string instead of an array + const hexString = [await accountsWrapper.getDataEncryptionKey(address)].join() // No comment key -> empty string returned from getDEK. This is expected for old addresses created before comment encryption change if (!hexString) { return null diff --git a/packages/mobile/src/identity/verification.ts b/packages/mobile/src/identity/verification.ts index 2a8687ad090..55ffbd8ebfa 100644 --- a/packages/mobile/src/identity/verification.ts +++ b/packages/mobile/src/identity/verification.ts @@ -522,7 +522,10 @@ async function isAccountUpToDate( accountsWrapper.getDataEncryptionKey(address), ]) return ( - eqAddress(currentWalletAddress, address) && currentDEK && eqAddress(currentDEK.join(), dataKey) + // currentDEK is actually a string instead of an array + eqAddress(currentWalletAddress, address) && + currentDEK && + eqAddress([currentDEK].join(), dataKey) ) } From f215e558c44f611486b21c2c6f10db85bd399860 Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Mon, 16 Dec 2019 15:17:17 +0100 Subject: [PATCH 2/2] Address comments --- packages/mobile/src/identity/verification.test.ts | 4 ++-- packages/mobile/src/identity/verification.ts | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/mobile/src/identity/verification.test.ts b/packages/mobile/src/identity/verification.test.ts index d5a4ccd6fdd..fccfa0a0335 100644 --- a/packages/mobile/src/identity/verification.test.ts +++ b/packages/mobile/src/identity/verification.test.ts @@ -135,8 +135,8 @@ const mockAttestationsWrapperPartlyVerified = { } const mockAccountsWrapper = { - getWalletAddress: jest.fn(() => mockAccount), - getDataEncryptionKey: jest.fn(() => [mockPublicDEK]), + getWalletAddress: jest.fn(() => Promise.resolve(mockAccount)), + getDataEncryptionKey: jest.fn(() => Promise.resolve(mockPublicDEK)), } describe('Start Verification Saga', () => { diff --git a/packages/mobile/src/identity/verification.ts b/packages/mobile/src/identity/verification.ts index 55ffbd8ebfa..d552fc98d12 100644 --- a/packages/mobile/src/identity/verification.ts +++ b/packages/mobile/src/identity/verification.ts @@ -519,13 +519,11 @@ async function isAccountUpToDate( ) { const [currentWalletAddress, currentDEK] = await Promise.all([ accountsWrapper.getWalletAddress(address), - accountsWrapper.getDataEncryptionKey(address), + // getDataEncryptionKey actually returns a string instead of an array + accountsWrapper.getDataEncryptionKey(address).then((key) => [key]), ]) return ( - // currentDEK is actually a string instead of an array - eqAddress(currentWalletAddress, address) && - currentDEK && - eqAddress([currentDEK].join(), dataKey) + eqAddress(currentWalletAddress, address) && currentDEK && eqAddress(currentDEK.join(), dataKey) ) }