chore: investigate login error [INS-3851]#7438
Merged
filfreire merged 3 commits intoKong:developfrom May 28, 2024
Merged
Conversation
4f6cb82 to
de26010
Compare
jackkav
reviewed
May 22, 2024
jackkav
reviewed
May 22, 2024
Comment on lines
+31
to
+66
|
|
||
| export async function decodeBase64(base64: string): Promise<Uint8Array> { | ||
| try { | ||
| let uri = 'data:application/octet-binary;base64,'; | ||
| uri += base64; | ||
| const res = await fetch(uri); | ||
| const buffer = await res.arrayBuffer(); | ||
| return new Uint8Array(buffer); | ||
|
|
||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error('Failed to decode base64'); | ||
| } | ||
| } | ||
|
|
||
| export async function encodeBase64(data: Uint8Array): Promise<string> { | ||
| const dataUri = await new Promise<string>((resolve, reject) => { | ||
| const reader = new FileReader(); | ||
| reader.onload = () => { | ||
| if (typeof reader.result === 'string') { | ||
| resolve(reader.result); | ||
| } else { | ||
| reject(); | ||
| } | ||
| }; | ||
| reader.onerror = reject; | ||
| reader.readAsDataURL(new Blob([data])); | ||
| }); | ||
|
|
||
| const dataAt = dataUri.indexOf(','); | ||
| if (dataAt === -1) { | ||
| throw new Error(`unexpected data uri output: ${dataUri}`); | ||
| } | ||
|
|
||
| return dataUri.slice(dataAt + 1); | ||
| } |
Contributor
There was a problem hiding this comment.
this was pulled out of api-cilent code to make it clearer it was going to use insomniaFetch, no sure if this is desirable @gatzjames to decide.
Contributor
There was a problem hiding this comment.
Yes lets deprecate the api-client
filfreire
commented
May 22, 2024
Comment on lines
+80
to
+81
| console.error(error); | ||
| return error.toString(); |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| console.error(error); | |
| return error.toString(); | |
| console.error(error); | |
| return error; |
Contributor
There was a problem hiding this comment.
This is a bit of a smell and likely to cause a bug now or in a future change, might help to consider a few angles here
ac349d8 to
32c13e7
Compare
gatzjames
approved these changes
May 23, 2024
Comment on lines
+31
to
+66
|
|
||
| export async function decodeBase64(base64: string): Promise<Uint8Array> { | ||
| try { | ||
| let uri = 'data:application/octet-binary;base64,'; | ||
| uri += base64; | ||
| const res = await fetch(uri); | ||
| const buffer = await res.arrayBuffer(); | ||
| return new Uint8Array(buffer); | ||
|
|
||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error('Failed to decode base64'); | ||
| } | ||
| } | ||
|
|
||
| export async function encodeBase64(data: Uint8Array): Promise<string> { | ||
| const dataUri = await new Promise<string>((resolve, reject) => { | ||
| const reader = new FileReader(); | ||
| reader.onload = () => { | ||
| if (typeof reader.result === 'string') { | ||
| resolve(reader.result); | ||
| } else { | ||
| reject(); | ||
| } | ||
| }; | ||
| reader.onerror = reject; | ||
| reader.readAsDataURL(new Blob([data])); | ||
| }); | ||
|
|
||
| const dataAt = dataUri.indexOf(','); | ||
| if (dataAt === -1) { | ||
| throw new Error(`unexpected data uri output: ${dataUri}`); | ||
| } | ||
|
|
||
| return dataUri.slice(dataAt + 1); | ||
| } |
Contributor
There was a problem hiding this comment.
Yes lets deprecate the api-client
32c13e7 to
c08038a
Compare
stefancruz
pushed a commit
to stefancruz/insomnia
that referenced
this pull request
Jun 30, 2024
* chore: investigate login error [INS-3851] * another pass at error we show * Update packages/insomnia/src/ui/auth-session-provider.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes INS-3851
Taking a pass at #7358 (comment)
Trying to surfaces cases where whoami fails