-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extract keyCache from KeyLoaderFacade and UserFacade and handle user … #6925
Conversation
* @param keyLoader a function to load and decrypt the group key if it is not cached | ||
*/ | ||
getCurrentGroupKey(groupId: Id, keyLoader: () => Promise<VersionedKey>): Promise<VersionedKey> { | ||
return getFromMap(this.currentGroupKeys, groupId, async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if loader rejects you will have a cached rejected promise
const newCurrentGroupKeyCache = new Map<Id, Promise<VersionedKey>>() | ||
for (const membership of user.memberships) { | ||
const cachedGroupKey = this.currentGroupKeys.get(membership.group) | ||
if (cachedGroupKey != null && Number(membership.groupKeyVersion) === (await cachedGroupKey).version) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if any of the cachedGroupKey
reject the whole thing will fail
facade.setAccessToken("hello.") | ||
facade.setUser({} as User) | ||
o(facade.isPartiallyLoggedIn()).equals(true) | ||
o(facade.isFullyLoggedIn()).equals(false) | ||
}) | ||
|
||
o("updateUserGroupKey - successfull", function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you have related tests it might be nice to put them in a spec()
// @ts-ignore | ||
o(cachedUserGroupKey.version).equals(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than completely ts-ignore
ing the line I would suggest to just unwrap it
// @ts-ignore | |
o(cachedUserGroupKey.version).equals(0) | |
o(cachedUserGroupKey!.version).equals(0) |
01ec221
to
1ec4628
Compare
…group key updates using a distribution key. tutadb#1795
…group key updates using a distribution key.
tutadb#1795