@@ -78,7 +78,7 @@ export class ConvexClient {
78
78
| ReturnType < typeof setTimeout >
79
79
| undefined ;
80
80
private _closed : boolean ;
81
- disabled : boolean ;
81
+ private _disabled : boolean ;
82
82
/**
83
83
* Once closed no registered callbacks will fire again.
84
84
*/
@@ -89,6 +89,9 @@ export class ConvexClient {
89
89
if ( this . _client ) return this . _client ;
90
90
throw new Error ( "ConvexClient is disabled" ) ;
91
91
}
92
+ get disabled ( ) : boolean {
93
+ return this . _disabled ;
94
+ }
92
95
93
96
/**
94
97
* Construct a client and immediately initiate a WebSocket connection to the passed address.
@@ -101,7 +104,7 @@ export class ConvexClient {
101
104
}
102
105
const { disabled, ...baseOptions } = options ;
103
106
this . _closed = false ;
104
- this . disabled = ! ! disabled ;
107
+ this . _disabled = ! ! disabled ;
105
108
if (
106
109
defaultWebSocketConstructor &&
107
110
! ( "webSocketConstructor" in baseOptions ) &&
@@ -254,13 +257,14 @@ export class ConvexClient {
254
257
* `fetchToken` will be called automatically again if a token expires.
255
258
* `fetchToken` should return `null` if the token cannot be retrieved, for example
256
259
* when the user's rights were permanently revoked.
257
- * @param fetchToken - an async function returning the JWT-encoded OpenID Connect Identity Token
260
+ * @param fetchToken - an async function returning the JWT (typically an OpenID Connect Identity Token)
258
261
* @param onChange - a callback that will be called when the authentication status changes
259
262
*/
260
263
setAuth (
261
264
fetchToken : AuthTokenFetcher ,
262
265
onChange ?: ( isAuthenticated : boolean ) => void ,
263
266
) {
267
+ if ( this . disabled ) return ;
264
268
this . client . setAuth (
265
269
fetchToken ,
266
270
onChange ??
0 commit comments