From 072773b01d67746f7a7b2b252a68ec5dce251a0a Mon Sep 17 00:00:00 2001 From: Francisco Micaelli Date: Wed, 6 Jul 2022 14:49:27 +0200 Subject: [PATCH] feat: remove getDeviceList --- packages/core/src/LocalUser/Manager.ts | 7 --- packages/core/src/Session/Session.ts | 1 - packages/core/src/Tanker.ts | 12 ----- packages/core/src/index.ts | 2 +- .../functional-tests/src/getDeviceList.ts | 51 ------------------- packages/functional-tests/src/index.ts | 2 - packages/functional-tests/src/session.ts | 10 ---- 7 files changed, 1 insertion(+), 84 deletions(-) delete mode 100644 packages/functional-tests/src/getDeviceList.ts diff --git a/packages/core/src/LocalUser/Manager.ts b/packages/core/src/LocalUser/Manager.ts index e746fc66..14f5de50 100644 --- a/packages/core/src/LocalUser/Manager.ts +++ b/packages/core/src/LocalUser/Manager.ts @@ -37,7 +37,6 @@ import type { UserData, DelegationToken } from './UserData'; import type { Client, PullOptions } from '../Network/Client'; import { OidcNonceManager } from '../OidcNonce/Manager'; import { Status } from '../Session/status'; -import type { Device } from '../Users/types'; import { makeSessionCertificate } from './SessionCertificate'; export type PrivateProvisionalKeys = { @@ -279,12 +278,6 @@ export class LocalUserManager extends EventEmitter { } }; - listDevices = async (): Promise> => { - await this.updateLocalUser({ isLight: false }); - const devices = this._localUser.devices; - return devices.filter(d => !d.isGhostDevice); - }; - getSessionToken = async (verification: VerificationWithToken): Promise => { await this.updateLocalUser({ isLight: true }); diff --git a/packages/core/src/Session/Session.ts b/packages/core/src/Session/Session.ts index 73438e31..98993c98 100644 --- a/packages/core/src/Session/Session.ts +++ b/packages/core/src/Session/Session.ts @@ -159,7 +159,6 @@ export class Session extends EventEmitter { createNewDevice = this._promiseChain(this._forward(this._getLocalUserManager, 'createNewDevice'), this._setReady, this._stopIfNotRetryable); getVerificationKey = this._forward(this._getLocalUserManager, 'getVerificationKey'); - listDevices = this._forward(this._getLocalUserManager, 'listDevices'); deviceId = () => this._localUserManager.localUser.deviceId; setVerificationMethod = this._forward(this._getLocalUserManager, 'setVerificationMethod'); diff --git a/packages/core/src/Tanker.ts b/packages/core/src/Tanker.ts index 3d35f3b0..7f8a306d 100644 --- a/packages/core/src/Tanker.ts +++ b/packages/core/src/Tanker.ts @@ -62,7 +62,6 @@ export type TankerCoreOptions = { export type TankerOptions = Partial & { dataStore: Partial; }>; -export type Device = { id: string; }; export type ProvisionalVerification = EmailVerification | PhoneNumberVerification; export function optionsWithDefaults(options: TankerOptions, defaults: TankerCoreOptions): TankerCoreOptions { @@ -439,17 +438,6 @@ export class Tanker extends EventEmitter { } } - async getDeviceList(): Promise> { - console.warn('The "getDeviceList" method is deprecated, it will be removed in the future'); - - assertStatus(this.status, statuses.READY, 'get the device list'); - - const devices = await this.session.listDevices(); - return devices.map(d => ({ - id: utils.toBase64(d.deviceId), - })); - } - async share(resourceIds: Array, options: SharingOptions): Promise { assertStatus(this.status, statuses.READY, 'share'); diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 4e636cf4..37bd5daf 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -52,7 +52,7 @@ export type { LegacyEmailVerificationMethod, } from './LocalUser/types'; export type { AttachResult } from './ProvisionalIdentity/types'; -export type { TankerOptions, Device, ProvisionalVerification } from './Tanker'; +export type { TankerOptions, ProvisionalVerification } from './Tanker'; export type { EncryptionSession } from './DataProtection/EncryptionSession'; export type { UploadStream } from './CloudStorage/UploadStream'; export type { DownloadStream } from './CloudStorage/DownloadStream'; diff --git a/packages/functional-tests/src/getDeviceList.ts b/packages/functional-tests/src/getDeviceList.ts deleted file mode 100644 index 9afa3b13..00000000 --- a/packages/functional-tests/src/getDeviceList.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { errors } from '@tanker/core'; -import type { Tanker, b64string } from '@tanker/core'; -import { expect, uuid } from '@tanker/test-utils'; - -import type { TestArgs } from './helpers'; - -export const generateGetDeviceListTests = (args: TestArgs) => { - describe('getDeviceList', () => { - let bobId: b64string; - let bobIdentity: b64string; - let bobLaptop: Tanker; - let bobPhone: Tanker; - - beforeEach(async () => { - bobId = uuid.v4(); - bobIdentity = await args.appHelper.generateIdentity(bobId); - bobLaptop = args.makeTanker(); - bobPhone = args.makeTanker(); - await bobLaptop.start(bobIdentity); - await bobLaptop.registerIdentity({ passphrase: 'passphrase' }); - }); - - afterEach(async () => { - await Promise.all([ - bobLaptop.stop(), - bobPhone.stop(), - ]); - }); - - it('should throw when using a session in an invalid state', async () => { - await bobLaptop.stop(); - await expect(bobLaptop.getDeviceList()).to.be.rejectedWith(errors.PreconditionFailed); - }); - - it('can list the devices of a user', async () => { - await bobPhone.start(bobIdentity); - await bobPhone.verifyIdentity({ passphrase: 'passphrase' }); - - const list1 = await bobLaptop.getDeviceList(); - const list2 = await bobPhone.getDeviceList(); - - expect(list1).to.deep.equal(list2); - expect(list1.filter(({ id }) => id === bobLaptop.deviceId)).to.have.lengthOf(1); - expect(list1.filter(({ id }) => id === bobPhone.deviceId)).to.have.lengthOf(1); - }); - - it('does not expose ghostDevices in device list', async () => { - expect(await bobLaptop.getDeviceList()).to.have.lengthOf(1); - }); - }); -}; diff --git a/packages/functional-tests/src/index.ts b/packages/functional-tests/src/index.ts index 788a9877..6f1b570a 100644 --- a/packages/functional-tests/src/index.ts +++ b/packages/functional-tests/src/index.ts @@ -11,7 +11,6 @@ import { generateEncryptionTests } from './encryption'; import { generateEnrollTests } from './enroll'; import { generateFakeAuthenticationTests } from './fake-authentication'; import { generateNetworkTests } from './network'; -import { generateGetDeviceListTests } from './getDeviceList'; import { generateGroupsTests } from './groups'; import { generateSessionTests } from './session'; import { generateUploadTests } from './upload'; @@ -64,7 +63,6 @@ export function generateFunctionalTests( }); generateSessionTests(args); - generateGetDeviceListTests(args); generateVerificationTests(args); generateEncryptionTests(args); generateEncryptionSessionTests(args); diff --git a/packages/functional-tests/src/session.ts b/packages/functional-tests/src/session.ts index 05ecda65..dc94ff2f 100644 --- a/packages/functional-tests/src/session.ts +++ b/packages/functional-tests/src/session.ts @@ -179,11 +179,6 @@ export const generateSessionTests = (args: TestArgs) => { await expect(bobLaptop.status).to.equal(IDENTITY_VERIFICATION_NEEDED); await bobLaptop.verifyIdentity({ passphrase: 'passphrase' }); - - // Check two devices have been created - const devices = await bobLaptop.getDeviceList(); - expect(devices).to.have.lengthOf(2); - expect(devices).to.deep.include.members([{ id: bobLaptop.deviceId }]); }); }); @@ -215,11 +210,6 @@ export const generateSessionTests = (args: TestArgs) => { await expect(bobLaptop.status).to.equal(IDENTITY_VERIFICATION_NEEDED); await bobLaptop.verifyIdentity({ passphrase: 'passphrase' }); - - // Check two devices have been created - const devices = await bobLaptop.getDeviceList(); - expect(devices).to.have.lengthOf(3); - expect(devices).to.deep.include.members([{ id: bobLaptop.deviceId }]); }); }); });