Skip to content

Conversation

@ioannischtz
Copy link
Collaborator

  • Introduce a time-based lru cache for the decryptChannelDEK method, in order to significantly reduce redundant rpc requests.
  • Fix some issues in the integration tests, regarding the pagination of getChannelMemberships
  • Fix an issue with the AAD used when decrypting attachments

this.#sessionKey = config.sessionKey;
this.#sessionKeyConfig = config.sessionKeyConfig;
this.#encryptionPrimitives = config.encryptionPrimitives ?? WebCryptoPrimitives.getInstance();
this.#dekCache = new TimeBasedLruCache({ ttlMs: 5 * 60 * 1000, maxEntries: 100 }); // 5 minutes TTL, 100 max entries
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be configurable. let's open a ticket for that.

];

// Use cache with loader function
return await this.#dekCache.read(cacheKey, async (): Promise<SymmetricKey> => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that, await is not needed here

import { EncryptedObject, SessionKey } from '@mysten/seal';
import { fromHex, isValidSuiObjectId, toHex } from '@mysten/sui/utils';

import { TimeBasedLruCache } from '../cache.js';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the suffix?

}

export class TimeBasedLruCache {
#cache: Map<string, { value: unknown; timestampMs: number }>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 -> readonly

}
this.#set(cacheKey, result);

return result as T;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as T is not needed I believe

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you gonna use these consts?

@ioannischtz ioannischtz changed the base branch from ic/ts-sdk/2300/npm-build to main September 23, 2025 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants