@@ -3,7 +3,7 @@ const superagent = require('superagent')
33class Auth {
44 constructor ( authUrl , supabaseKey , options = { autoRefreshToken : true } ) {
55 this . authUrl = authUrl
6- this . accessToken = null
6+ this . accessToken = supabaseKey
77 this . refreshToken = null
88 this . supabaseKey = supabaseKey
99 this . currentUser = null
@@ -28,8 +28,8 @@ class Auth {
2828 if ( response . status === 200 ) {
2929 this . accessToken = response . body [ 'access_token' ]
3030 this . refreshToken = response . body [ 'refresh_token' ]
31- if ( this . autoRefreshToken && tokenExirySeconds )
32- setTimeout ( this . refreshToken , tokenExirySeconds - 60 )
31+ if ( this . autoRefreshToken && tokenExpirySeconds )
32+ setTimeout ( this . refreshToken , tokenExpirySeconds - 60 )
3333 }
3434 return response
3535 }
@@ -42,9 +42,9 @@ class Auth {
4242 if ( response . status === 200 ) {
4343 this . accessToken = response . body [ 'access_token' ]
4444 this . refreshToken = response . body [ 'refresh_token' ]
45- let tokenExirySeconds = response . body [ 'expires_in' ]
46- if ( this . autoRefreshToken && tokenExirySeconds )
47- setTimeout ( this . refreshToken , tokenExirySeconds - 60 )
45+ let tokenExpirySeconds = response . body [ 'expires_in' ]
46+ if ( this . autoRefreshToken && tokenExpirySeconds )
47+ setTimeout ( this . refreshToken , tokenExpirySeconds - 60 )
4848 }
4949 return response
5050 }
@@ -59,14 +59,6 @@ class Auth {
5959 this . accessToken = null
6060 }
6161
62- // this.setRefreshTokenExpiry = (refreshTokenExpirySeconds) => {
63- // let bufferSeconds = 60
64- // let t = new Date() // current time
65- // this.refreshTokenExpiry = t.setSeconds(
66- // t.getSeconds() + (refreshTokenExpirySeconds - bufferSeconds)
67- // )
68- // }
69-
7062 this . user = async ( ) => {
7163 if ( this . currentUser ) return this . currentUser
7264
0 commit comments