Skip to content

Commit 928818b

Browse files
committed
fix: added backwards compatibility with older KPS instances and fixed auth tests
1 parent cfcea33 commit 928818b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import Realtime from './Realtime'
33
import { Auth } from './Auth'
44
import { PostgrestClient } from '@supabase/postgrest-js'
55

6+
const DEPRICATED_KEY_LENGTH = 45
7+
68
class SupabaseClient {
79
constructor(supabaseUrl, supabaseKey, options = { autoRefreshToken: true }) {
810
this.supabaseUrl = null
@@ -91,7 +93,8 @@ class SupabaseClient {
9193
initClient() {
9294
let headers = { apikey: this.supabaseKey }
9395

94-
if (this.auth.authHeader()) headers['Authorization'] = this.auth.authHeader()
96+
if (this.supabaseKey.length > DEPRICATED_KEY_LENGTH && this.auth.authHeader())
97+
headers['Authorization'] = this.auth.authHeader()
9598

9699
let rest = new PostgrestClient(this.restUrl, {
97100
headers,

test/integration/testAuth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('test signing up and logging in as a new user', () => {
1515
it('should register a new user', async () => {
1616
try {
1717
const response = await supabase.auth.signup(randomEmail, '11password')
18-
assert(response.body.email === randomEmail, 'user could not sign up')
18+
assert(response.body.user.email === randomEmail, 'user could not sign up')
1919
} catch (error) {
2020
assert(!error, 'sign up returns an error')
2121
}

0 commit comments

Comments
 (0)