@@ -245,54 +245,54 @@ declare namespace OAuth2Server {
245245 * Invoked to generate a new access token.
246246 *
247247 */
248- generateAccessToken ?( client : Client , user : User , scope : string [ ] ) : Promise < string > ;
248+ generateAccessToken ?( client : Client , user : User , scope : string [ ] ) : string | Promise < string > ;
249249
250250 /**
251251 * Invoked to retrieve a client using a client id or a client id/client secret combination, depending on the grant type.
252252 *
253253 */
254- getClient ( clientId : string , clientSecret : string ) : Promise < Client | Falsey > ;
254+ getClient ( clientId : string , clientSecret : string ) : Client | Falsey | Promise < Client | Falsey > ;
255255
256256 /**
257257 * Invoked to save an access token and optionally a refresh token, depending on the grant type.
258258 *
259259 */
260- saveToken ( token : Token , client : Client , user : User ) : Promise < Token | Falsey > ;
260+ saveToken ( token : Token , client : Client , user : User ) : Token | Falsey | Promise < Token | Falsey > ;
261261 }
262262
263263 interface RequestAuthenticationModel {
264264 /**
265265 * Invoked to retrieve an existing access token previously saved through Model#saveToken().
266266 *
267267 */
268- getAccessToken ( accessToken : string ) : Promise < Token | Falsey > ;
268+ getAccessToken ( accessToken : string ) : Token | Falsey | Promise < Token | Falsey > ;
269269
270270 /**
271271 * Invoked during request authentication to check if the provided access token was authorized the requested scopes.
272272 * Optional, if a custom authenticateHandler is used or if there is no scope part of the request.
273273 *
274274 */
275- verifyScope ?( token : Token , scope : string [ ] ) : Promise < boolean > ;
275+ verifyScope ?( token : Token , scope : string [ ] ) : boolean | Promise < boolean > ;
276276 }
277277
278278 interface AuthorizationCodeModel extends BaseModel , RequestAuthenticationModel {
279279 /**
280280 * Invoked to generate a new refresh token.
281281 *
282282 */
283- generateRefreshToken ?( client : Client , user : User , scope : string [ ] ) : Promise < string > ;
283+ generateRefreshToken ?( client : Client , user : User , scope : string [ ] ) : string | Promise < string > ;
284284
285285 /**
286286 * Invoked to generate a new authorization code.
287287 *
288288 */
289- generateAuthorizationCode ?( client : Client , user : User , scope : string [ ] ) : Promise < string > ;
289+ generateAuthorizationCode ?( client : Client , user : User , scope : string [ ] ) : string | Promise < string > ;
290290
291291 /**
292292 * Invoked to retrieve an existing authorization code previously saved through Model#saveAuthorizationCode().
293293 *
294294 */
295- getAuthorizationCode ( authorizationCode : string ) : Promise < AuthorizationCode | Falsey > ;
295+ getAuthorizationCode ( authorizationCode : string ) : AuthorizationCode | Falsey | Promise < AuthorizationCode | Falsey > ;
296296
297297 /**
298298 * Invoked to save an authorization code.
@@ -302,79 +302,79 @@ declare namespace OAuth2Server {
302302 code : Pick < AuthorizationCode , 'authorizationCode' | 'expiresAt' | 'redirectUri' | 'scope' | 'codeChallenge' | 'codeChallengeMethod' > ,
303303 client : Client ,
304304 user : User
305- ) : Promise < AuthorizationCode | Falsey > ;
305+ ) : AuthorizationCode | Falsey | Promise < AuthorizationCode | Falsey > ;
306306
307307 /**
308308 * Invoked to revoke an authorization code.
309309 *
310310 */
311- revokeAuthorizationCode ( code : AuthorizationCode ) : Promise < boolean > ;
311+ revokeAuthorizationCode ( code : AuthorizationCode ) : boolean | Promise < boolean > ;
312312
313313 /**
314314 * Invoked to check if the requested scope is valid for a particular client/user combination.
315315 *
316316 */
317- validateScope ?( user : User , client : Client , scope ?: string [ ] ) : Promise < string [ ] | Falsey > ;
317+ validateScope ?( user : User , client : Client , scope ?: string [ ] ) : string [ ] | Falsey | Promise < string [ ] | Falsey > ;
318318
319319 /**
320320 * Invoked to check if the provided `redirectUri` is valid for a particular `client`.
321321 *
322322 */
323- validateRedirectUri ?( redirect_uri : string , client : Client ) : Promise < boolean > ;
323+ validateRedirectUri ?( redirect_uri : string , client : Client ) : boolean | Promise < boolean > ;
324324 }
325325
326326 interface PasswordModel extends BaseModel , RequestAuthenticationModel {
327327 /**
328328 * Invoked to generate a new refresh token.
329329 *
330330 */
331- generateRefreshToken ?( client : Client , user : User , scope : string [ ] ) : Promise < string > ;
331+ generateRefreshToken ?( client : Client , user : User , scope : string [ ] ) : string | Promise < string > ;
332332
333333 /**
334334 * Invoked to retrieve a user using a username/password combination.
335335 *
336336 */
337- getUser ( username : string , password : string , client : Client ) : Promise < User | Falsey > ;
337+ getUser ( username : string , password : string , client : Client ) : User | Falsey | Promise < User | Falsey > ;
338338
339339 /**
340340 * Invoked to check if the requested scope is valid for a particular client/user combination.
341341 *
342342 */
343- validateScope ?( user : User , client : Client , scope ?: string [ ] ) : Promise < string [ ] | Falsey > ;
343+ validateScope ?( user : User , client : Client , scope ?: string [ ] ) : string [ ] | Falsey | Promise < string [ ] | Falsey > ;
344344 }
345345
346346 interface RefreshTokenModel extends BaseModel , RequestAuthenticationModel {
347347 /**
348348 * Invoked to generate a new refresh token.
349349 *
350350 */
351- generateRefreshToken ?( client : Client , user : User , scope : string [ ] ) : Promise < string > ;
351+ generateRefreshToken ?( client : Client , user : User , scope : string [ ] ) : string | Promise < string > ;
352352
353353 /**
354354 * Invoked to retrieve an existing refresh token previously saved through Model#saveToken().
355355 *
356356 */
357- getRefreshToken ( refreshToken : string ) : Promise < RefreshToken | Falsey > ;
357+ getRefreshToken ( refreshToken : string ) : RefreshToken | Falsey | Promise < RefreshToken | Falsey > ;
358358
359359 /**
360360 * Invoked to revoke a refresh token.
361361 *
362362 */
363- revokeToken ( token : RefreshToken ) : Promise < boolean > ;
363+ revokeToken ( token : RefreshToken ) : boolean | Promise < boolean > ;
364364 }
365365
366366 interface ClientCredentialsModel extends BaseModel , RequestAuthenticationModel {
367367 /**
368368 * Invoked to retrieve the user associated with the specified client.
369369 *
370370 */
371- getUserFromClient ( client : Client ) : Promise < User | Falsey > ;
371+ getUserFromClient ( client : Client ) : User | Falsey | Promise < User | Falsey > ;
372372
373373 /**
374374 * Invoked to check if the requested scope is valid for a particular client/user combination.
375375 *
376376 */
377- validateScope ?( user : User , client : Client , scope ?: string [ ] ) : Promise < string [ ] | Falsey > ;
377+ validateScope ?( user : User , client : Client , scope ?: string [ ] ) : string [ ] | Falsey | Promise < string [ ] | Falsey > ;
378378 }
379379
380380 interface ExtensionModel extends BaseModel , RequestAuthenticationModel { }
0 commit comments