Page MenuHomePhabricator

[keyserver] call identity service during account creation and deletion
ClosedPublic

Authored by varun on Jun 22 2023, 11:46 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jan 2, 6:48 AM
Unknown Object (File)
Sun, Dec 29, 5:59 AM
Unknown Object (File)
Sun, Dec 29, 5:59 AM
Unknown Object (File)
Sun, Dec 29, 5:59 AM
Unknown Object (File)
Sun, Dec 29, 5:59 AM
Unknown Object (File)
Sun, Dec 29, 5:59 AM
Unknown Object (File)
Sun, Dec 29, 5:59 AM
Unknown Object (File)
Sun, Dec 29, 5:59 AM
Subscribers

Details

Summary

when we create a new account with a username, we should add it to the reserved usernames list
being maintained by the identity service.

when we delete an existing account with a username, we should remove it from the reserved usernames list being maintained by the identity service.

Depends on D8299

Test Plan

tested this by creating and deleting a new user locally. saw that the username was added to and then removed from my ddb table in localstack.

also tried removing a reserved username that didn't exist in ddb and got back an error as expected.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Jun 23 2023, 12:12 AM
Harbormaster failed remote builds in B20447: Diff 28029!
varun requested review of this revision.Jun 23 2023, 1:40 PM
atul added a reviewer: ashoat.

Seems right at a high level, adding @ashoat as blocking to take a look at babel-plugin-transform-import-meta dependency and related changes.

keyserver/src/creators/account-creator.js
220 ↗(On Diff #28070)

Should this "magic string" be defined somewhere that's shared?

keyserver/src/creators/account-creator.js
220 ↗(On Diff #28070)

that's a fair point

ashoat requested changes to this revision.Jun 28 2023, 5:26 PM

This diff should be split, and more work should be done to explain the changes and why they're necessary

keyserver/addons/rust-node-addon/index.js
16–19 ↗(On Diff #28166)

No idea what this is about or why it's being introduced! This needs to be explained in the diff description...

keyserver/babel.config.cjs
11 ↗(On Diff #28166)

No idea why this is necessary

keyserver/package.json
34 ↗(On Diff #28166)

It really would've made it easier to review if you had split this part out into its own diff

keyserver/src/shared/message-statements.js
3–7 ↗(On Diff #28166)
  1. Why do these need to be human-readable?
  2. Does this need to be synced with some equivalent strings on the Rust side? If so, it would be better to avoid the copy-paste, but if it's necessary then you need to do some extra work to make sure the reader is aware of this strong requirement. Otherwise it's really easy for the expectation to be broken, as you've done nothing to make the requirement discoverable
lib/types/crypto-types.js
43 ↗(On Diff #28166)
  1. Why don't we always take a $ReadOnlyArray<string>?
  2. If there's some strong reason we need to take `string | $ReadOnlyArray<string>, then I think we should type it that way, and avoid generics. I suspect that the payload needs to be a specific format for the Rust call, so we should enforce that on the JS side
This revision now requires changes to proceed.Jun 28 2023, 5:26 PM
lib/types/crypto-types.js
41–45 ↗(On Diff #28166)

I think this would be a better type:

export type ReservedUsernameMessage = {
  +mutationType: 'add' | 'remove',
  +userIDs: $ReadOnlyArray<string>,
  +issuedAt: string,
};

If you absolutely need to make the payload only take a single string for deletes, you could do this:

export type ReservedUsernameMessage =
  | {
      +mutationType: 'add',
      +userIDs: $ReadOnlyArray<string>,
      +issuedAt: string,
    }
  | {
      +mutationType: 'remove',
      +userID: string,
      +issuedAt: string,
    };
varun marked 3 inline comments as done.

address feedback

keyserver/addons/rust-node-addon/index.js
16–19 ↗(On Diff #28166)

split this out into a separate diff

keyserver/babel.config.cjs
11 ↗(On Diff #28166)

this is in a separate diff now

keyserver/src/shared/message-statements.js
3–7 ↗(On Diff #28166)

it doesn't need to be human-readable, actually. we can simplify this. follow up task: https://linear.app/comm/issue/ENG-4296/reduce-message-statement-to-just-a-verb

lib/types/crypto-types.js
41–45 ↗(On Diff #28166)

to avoid making changes on the identity service, i'm doing the following for now:

export type ReservedUsernameMessage =
  | {
      +statement: 'Add the following usernames to reserved list',
      +payload: $ReadOnlyArray<string>,
      +issuedAt: string,
    }
  | {
      +statement: 'Remove the following username from reserved list',
      +payload: string,
      +issuedAt: string,
    };

will address further type improvements in this follow-up task: https://linear.app/comm/issue/ENG-4295/simplify-reservedusernamemessage-type-on-keyserver

43 ↗(On Diff #28166)

Why don't we always take a $ReadOnlyArray<string>?

we don't have a use case for a batch delete, but this would simplify things a bit on the keyserver side. created a follow-up task: https://linear.app/comm/issue/ENG-4294/update-removereservedusername-rpc-to-take-a-list-of-usernames

ashoat added inline comments.
lib/types/crypto-types.js
42 ↗(On Diff #28323)

Can you make sure we add the equivalent text on the Rust side?

This revision is now accepted and ready to land.Jul 2 2023, 11:36 AM