@@ -3,7 +3,7 @@ const superagent = require('superagent')
3
3
class Auth {
4
4
constructor ( authUrl , supabaseKey , options = { autoRefreshToken : true } ) {
5
5
this . authUrl = authUrl
6
- this . accessToken = null
6
+ this . accessToken = supabaseKey
7
7
this . refreshToken = null
8
8
this . supabaseKey = supabaseKey
9
9
this . currentUser = null
@@ -28,8 +28,8 @@ class Auth {
28
28
if ( response . status === 200 ) {
29
29
this . accessToken = response . body [ 'access_token' ]
30
30
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 )
33
33
}
34
34
return response
35
35
}
@@ -42,9 +42,9 @@ class Auth {
42
42
if ( response . status === 200 ) {
43
43
this . accessToken = response . body [ 'access_token' ]
44
44
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 )
48
48
}
49
49
return response
50
50
}
@@ -59,14 +59,6 @@ class Auth {
59
59
this . accessToken = null
60
60
}
61
61
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
-
70
62
this . user = async ( ) => {
71
63
if ( this . currentUser ) return this . currentUser
72
64
0 commit comments