Skip to content

Commit

Permalink
refactor: throw errors instead of strings (#645)
Browse files Browse the repository at this point in the history
see title
  • Loading branch information
J0 committed Apr 5, 2023
1 parent 85ac7d8 commit 325d748
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ export default class GoTrueClient {
}

if (!data) {
throw 'An error occurred on token verification.'
throw new Error('An error occurred on token verification.')
}

const session: Session | null = data.session
Expand Down
4 changes: 2 additions & 2 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export function generatePKCEVerifier() {
const verifierLength = 56
const array = new Uint32Array(verifierLength)
if (typeof window.crypto === 'undefined') {
throw 'PKCE is not supported on devices without WebCrypto API support or equivalent polyfills'
throw new Error('PKCE is not supported on devices without WebCrypto API support or equivalent polyfills')
}
window.crypto.getRandomValues(array)
return Array.from(array, dec2hex).join('')
Expand All @@ -255,7 +255,7 @@ async function sha256(randomString: string) {
const encoder = new TextEncoder()
const encodedData = encoder.encode(randomString)
if (typeof window.crypto === 'undefined') {
throw 'PKCE is not supported on devices without WebCrypto API support or equivalent polyfills'
throw new Error('PKCE is not supported on devices without WebCrypto API support or equivalent polyfills')
}
const hash = await window.crypto.subtle.digest('SHA-256', encodedData)
const bytes = new Uint8Array(hash)
Expand Down

0 comments on commit 325d748

Please sign in to comment.