Skip to content
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

Persist Account keys on login #375

Merged
merged 11 commits into from
Oct 8, 2024
Merged

Persist Account keys on login #375

merged 11 commits into from
Oct 8, 2024

Conversation

mwilde345
Copy link
Member

@mwilde345 mwilde345 commented Oct 4, 2024

Ticket(s): FE-5875

Problem

We aren't persisting account keys

Solution

Build basic handler to manage creds files

  • Credentials class has methods to get, put, and delete entries in the access_keys or secret_keys file.
  • profile flag can be used to index the stored account keys. default is otherwise used.
  • added some jsdocs

Result

Basic persistence of creds

Made a simple list databases handler fauna db list that uses the stored account key. Will build that command and tests out later.

Testing

  • Login successfully writes and overwrites account key creds

@mwilde345 mwilde345 changed the title creds file Persist Account keys on login Oct 8, 2024
@mwilde345 mwilde345 marked this pull request as ready for review October 8, 2024 13:55
@@ -12,18 +12,6 @@ const clientSecret =
const REDIRECT_URI = `http://127.0.0.1`;

class OAuthClient {
Copy link
Member Author

Choose a reason for hiding this comment

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

will jsdoc this in another pr, this one is getting big

Copy link
Contributor

Choose a reason for hiding this comment

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

in the JSDoc PR can you add the annotation //@ts-check to the top of the file? it'll turn on in-IDE static analysis and should help you generate good types.

@@ -12,18 +12,6 @@ const clientSecret =
const REDIRECT_URI = `http://127.0.0.1`;

class OAuthClient {
Copy link
Contributor

Choose a reason for hiding this comment

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

in the JSDoc PR can you add the annotation //@ts-check to the top of the file? it'll turn on in-IDE static analysis and should help you generate good types.

Comment on lines +119 to 123
this.server.on("listening", () => {
this.port = this.server.address().port;
this.server.emit("ready");
});
this.server.listen(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this.server.listening set when you emit ready?

Copy link
Member Author

Choose a reason for hiding this comment

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

this check was a workaround for that builtYargs.argv weirdness, so not strictly necessary but yes by the time i send "ready" it's already true

src/lib/fauna-account-client.mjs Show resolved Hide resolved
Comment on lines +127 to +128
headers.append("Authorization", `Bearer ${accountKey}`);

Copy link
Contributor

Choose a reason for hiding this comment

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

thoughts on abstracting out something with an API like makeFaunaRequest on the next draft of this PR? that'll let you centralize error handling and make these methods really short & similar.

src/lib/file-util.mjs Outdated Show resolved Hide resolved
src/lib/file-util.mjs Outdated Show resolved Hide resolved
src/lib/file-util.mjs Outdated Show resolved Hide resolved
src/lib/file-util.mjs Outdated Show resolved Hide resolved
@mwilde345 mwilde345 merged commit 70088ed into v3 Oct 8, 2024
1 check passed
@mwilde345 mwilde345 deleted the creds-file branch October 8, 2024 20:36
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.

2 participants