diff --git a/src/Client.ts b/src/Client.ts index cd336cbe8..24115efb9 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -197,10 +197,6 @@ export type PreEventCallbackOptions = { preEnableIdentityCallback?: PreEventCallback } -export type ConsentListOptions = { - enableConsentList: boolean -} - /** * Aggregate type for client options. Optional properties are used when the default value is calculated on invocation, and are computed * as needed by each function. All other defaults are specified in defaultOptions. @@ -210,8 +206,7 @@ export type ClientOptions = Flatten< KeyStoreOptions & ContentOptions & LegacyOptions & - PreEventCallbackOptions & - ConsentListOptions + PreEventCallbackOptions > /** @@ -234,7 +229,6 @@ export function defaultOptions(opts?: Partial): ClientOptions { disablePersistenceEncryption: false, keystoreProviders: defaultKeystoreProviders(), apiClientFactory: createHttpApiClientFromOptions, - enableConsentList: false, } if (opts?.codecs) { @@ -272,14 +266,12 @@ export default class Client { // eslint-disable-next-line @typescript-eslint/no-explicit-any private _codecs: Map> private _maxContentSize: number - readonly _enableConsentList: boolean constructor( publicKeyBundle: PublicKeyBundle, apiClient: ApiClient, backupClient: BackupClient, - keystore: Keystore, - enableConsentList: boolean = false + keystore: Keystore ) { this.contacts = new Contacts(this) this.knownPublicKeyBundles = new Map< @@ -295,7 +287,6 @@ export default class Client { this._maxContentSize = MaxContentSize this.apiClient = apiClient this._backupClient = backupClient - this._enableConsentList = enableConsentList } /** @@ -340,13 +331,7 @@ export default class Client { const backupClient = await Client.setupBackupClient(address, options.env) const client = new Client< ExtractDecodedType<[...ContentCodecs, TextCodec][number]> | undefined - >( - publicKeyBundle, - apiClient, - backupClient, - keystore, - opts?.enableConsentList - ) + >(publicKeyBundle, apiClient, backupClient, keystore) await client.init(options) return client } diff --git a/src/Contacts.ts b/src/Contacts.ts index 74bfa6d7f..fa368afbf 100644 --- a/src/Contacts.ts +++ b/src/Contacts.ts @@ -67,14 +67,17 @@ export class ConsentList { return this._identifier } - static async load(client: Client): Promise { + static async load(client: Client, startTime?: Date): Promise { const consentList = new ConsentList() const identifier = await this.getIdentifier(client) const contentTopic = buildUserPrivatePreferencesTopic(identifier) const messages = await client.listEnvelopes( contentTopic, - async ({ message }: EnvelopeWithMessage) => message + async ({ message }: EnvelopeWithMessage) => message, + { + startTime, + } ) // decrypt messages @@ -171,10 +174,8 @@ export class Contacts { this.client = client } - async refreshConsentList() { - if (this.client._enableConsentList) { - this.consentList = await ConsentList.load(this.client) - } + async refreshConsentList(startTime?: Date) { + this.consentList = await ConsentList.load(this.client, startTime) } isAllowed(address: string) { @@ -190,20 +191,16 @@ export class Contacts { } async allow(addresses: string[]) { - if (this.client._enableConsentList) { - await ConsentList.publish( - addresses.map((address) => this.consentList.allow(address)), - this.client - ) - } + await ConsentList.publish( + addresses.map((address) => this.consentList.allow(address)), + this.client + ) } async block(addresses: string[]) { - if (this.client._enableConsentList) { - await ConsentList.publish( - addresses.map((address) => this.consentList.block(address)), - this.client - ) - } + await ConsentList.publish( + addresses.map((address) => this.consentList.block(address)), + this.client + ) } } diff --git a/src/conversations/Conversations.ts b/src/conversations/Conversations.ts index 74433ed02..f0320dd13 100644 --- a/src/conversations/Conversations.ts +++ b/src/conversations/Conversations.ts @@ -49,9 +49,6 @@ export default class Conversations { this.listV2Conversations(), ]) - // fetch allow list if enabled - this.client.contacts.refreshConsentList() - const conversations = v1Convos.concat(v2Convos) conversations.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime()) @@ -571,9 +568,7 @@ export default class Conversations { ]) // add peer address to allow list - if (this.client._enableConsentList) { - this.client.contacts.allow([peerAddress]) - } + this.client.contacts.allow([peerAddress]) return this.conversationReferenceToV2(conversation) } diff --git a/src/crypto/ecies.ts b/src/crypto/ecies.ts index 056d325a9..57d448f06 100644 --- a/src/crypto/ecies.ts +++ b/src/crypto/ecies.ts @@ -110,7 +110,6 @@ async function hmacSha256Verify(key: Buffer, msg: Buffer, sig: Buffer) { /** * Generate a new valid private key. Will use the window.crypto or window.msCrypto as source * depending on your browser. - * * @returns {Buffer} A 32-byte private key. * @function */ diff --git a/src/message-backup/BackupClientFactory.ts b/src/message-backup/BackupClientFactory.ts index 1aa0d6ee3..5784cc000 100644 --- a/src/message-backup/BackupClientFactory.ts +++ b/src/message-backup/BackupClientFactory.ts @@ -10,12 +10,11 @@ import TopicStoreBackupClient from './TopicStoreBackupClient' * Creates a backup client of the correct provider type (e.g. xmtp backup, no backup, etc). * Uses an existing user preference from the backend if it exists, else prompts for a new * one using the `providerSelector` - * * @param walletAddress The public address of the user's wallet * @param selectBackupProvider A callback for determining the provider to use, in the event there is no * existing user preference. The app can define the policy to use here (e.g. prompt the user, * or default to a certain provider type). - * @returns A backup client of the correct type + * @returns {Promise} A backup client of the correct type */ export async function createBackupClient( walletAddress: string, diff --git a/test/Contacts.test.ts b/test/Contacts.test.ts index c19839d0b..45e5186ea 100644 --- a/test/Contacts.test.ts +++ b/test/Contacts.test.ts @@ -14,15 +14,12 @@ describe('Contacts', () => { beforeEach(async () => { aliceClient = await Client.create(alice, { env: 'local', - enableConsentList: true, }) bobClient = await Client.create(bob, { env: 'local', - enableConsentList: true, }) carolClient = await Client.create(carol, { env: 'local', - enableConsentList: true, }) }) @@ -102,7 +99,6 @@ describe('Contacts', () => { aliceClient = await Client.create(alice, { env: 'local', - enableConsentList: true, }) expect(aliceClient.contacts.consentState(bob.address)).toBe('unknown')