Skip to content

Commit 492c95c

Browse files
committed
fix(auth): fix test failure for throwOnError feature
1 parent 2fd8785 commit 492c95c

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

deno.lock

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/auth-js/src/GoTrueClient.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,16 @@ export default class GoTrueClient {
438438
*/
439439
private async _initialize(): Promise<InitializeResult> {
440440
try {
441-
const params = parseParametersFromURL(window.location.href)
441+
let params: { [parameter: string]: string } = {}
442442
let callbackUrlType = 'none'
443-
if (this._isImplicitGrantCallback(params)) {
444-
callbackUrlType = 'implicit'
445-
} else if (await this._isPKCECallback(params)) {
446-
callbackUrlType = 'pkce'
443+
444+
if (isBrowser()) {
445+
params = parseParametersFromURL(window.location.href)
446+
if (this._isImplicitGrantCallback(params)) {
447+
callbackUrlType = 'implicit'
448+
} else if (await this._isPKCECallback(params)) {
449+
callbackUrlType = 'pkce'
450+
}
447451
}
448452

449453
/**

packages/core/auth-js/test/GoTrueClient.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,8 +3240,7 @@ describe('GoTrueClient with throwOnError option', () => {
32403240
await expect(client.signInWithOtp({ email: 'invalid', options: { captchaToken: 'x' } })).rejects.toThrow()
32413241
})
32423242

3243-
test('signInWithSSO() should return error shape; calling code can opt to throw', async () => {
3244-
const res = await client.signInWithSSO({ domain: 'nonexistent.example.com' })
3245-
expect(res.error).not.toBeNull()
3243+
test('signInWithSSO() should throw on error when throwOnError is true', async () => {
3244+
await expect(client.signInWithSSO({ domain: 'nonexistent.example.com' })).rejects.toThrow()
32463245
})
32473246
})

0 commit comments

Comments
 (0)