feat: Automatic token provisioning on deploy#178
Conversation
| function base64url(binary: Uint8Array): string { | ||
| const binaryString = Array.from(binary).map((b) => String.fromCharCode(b)) | ||
| .join(""); | ||
| const output = btoa(binaryString); | ||
| const urlSafeOutput = output | ||
| .replaceAll("=", "") | ||
| .replaceAll("+", "-") | ||
| .replaceAll("/", "_"); | ||
| return urlSafeOutput; | ||
| } |
There was a problem hiding this comment.
Would be good to have a unit test for this
There was a problem hiding this comment.
Any suggestion on test cases I should implement?
There was a problem hiding this comment.
Also, is there a way to test it while keeping the function private to the module?
There was a problem hiding this comment.
No, I don't think so. The test should be in a *_test.ts file
There was a problem hiding this comment.
This PR adds auto-provisioning to deploy subcommand only, but we'll extend it to other subcommands, right?
There was a problem hiding this comment.
Yes. I can add it in this PR as well
|
|
||
| async function provision(): Promise<string> { | ||
| const spinnerInterrupted = interruptSpinner(); | ||
| wait("").start().info("Provisioning a new access token..."); |
There was a problem hiding this comment.
Not really sure how spinner exactly works, but what wait("").start().info("some message") does is basically:
- starting the spinner with no message along the spinner
- then stopping (and clearing) the spinner with an info message printed
Is this correct? If correct, then starting the spinner will have essentially no effect because it's immediately stopped and cleared - I wonder if we could just use console.info
There was a problem hiding this comment.
The beauty of it is that the output is consistent with the rest of spinner result messages (the info/warn icon, the identation, etc).
There was a problem hiding this comment.
(this pattern is used everywhere in deployctl)
There was a problem hiding this comment.
I think this file should be moved to token_storage/mod.ts
satyarohith
left a comment
There was a problem hiding this comment.
I tested the changes on mac and It's an amazing experience when the access token is provisioned automatically. Nice work!
LGTM apart from the nits
Notes on the current implementation