Skip to content

Commit 88a44df

Browse files
authored
feat: Realtime using accessToken callback for auth (#1320)
1 parent 456f27e commit 88a44df

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@supabase/functions-js": "2.4.3",
4545
"@supabase/node-fetch": "2.6.15",
4646
"@supabase/postgrest-js": "1.16.3",
47-
"@supabase/realtime-js": "2.10.9",
47+
"@supabase/realtime-js": "2.11.2",
4848
"@supabase/storage-js": "2.7.1"
4949
},
5050
"devDependencies": {

src/SupabaseClient.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ export default class SupabaseClient<
118118

119119
this.fetch = fetchWithAuth(supabaseKey, this._getAccessToken.bind(this), settings.global.fetch)
120120

121-
this.realtime = this._initRealtimeClient({ headers: this.headers, ...settings.realtime })
121+
this.realtime = this._initRealtimeClient({
122+
headers: this.headers,
123+
accessToken: this._getAccessToken,
124+
...settings.realtime,
125+
})
122126
this.rest = new PostgrestClient(`${_supabaseUrl}/rest/v1`, {
123127
headers: this.headers,
124128
schema: settings.db.schema,
@@ -330,9 +334,6 @@ export default class SupabaseClient<
330334
(event === 'TOKEN_REFRESHED' || event === 'SIGNED_IN') &&
331335
this.changedAccessToken !== token
332336
) {
333-
// Token has changed
334-
this.realtime.setAuth(token ?? null)
335-
336337
this.changedAccessToken = token
337338
} else if (event === 'SIGNED_OUT') {
338339
// Token is removed

0 commit comments

Comments
 (0)