@@ -245,54 +245,54 @@ declare namespace OAuth2Server {
245
245
* Invoked to generate a new access token.
246
246
*
247
247
*/
248
- generateAccessToken ?( client : Client , user : User , scope : string [ ] ) : Promise < string > ;
248
+ generateAccessToken ?( client : Client , user : User , scope : string [ ] ) : string | Promise < string > ;
249
249
250
250
/**
251
251
* Invoked to retrieve a client using a client id or a client id/client secret combination, depending on the grant type.
252
252
*
253
253
*/
254
- getClient ( clientId : string , clientSecret : string ) : Promise < Client | Falsey > ;
254
+ getClient ( clientId : string , clientSecret : string ) : Client | Falsey | Promise < Client | Falsey > ;
255
255
256
256
/**
257
257
* Invoked to save an access token and optionally a refresh token, depending on the grant type.
258
258
*
259
259
*/
260
- saveToken ( token : Token , client : Client , user : User ) : Promise < Token | Falsey > ;
260
+ saveToken ( token : Token , client : Client , user : User ) : Token | Falsey | Promise < Token | Falsey > ;
261
261
}
262
262
263
263
interface RequestAuthenticationModel {
264
264
/**
265
265
* Invoked to retrieve an existing access token previously saved through Model#saveToken().
266
266
*
267
267
*/
268
- getAccessToken ( accessToken : string ) : Promise < Token | Falsey > ;
268
+ getAccessToken ( accessToken : string ) : Token | Falsey | Promise < Token | Falsey > ;
269
269
270
270
/**
271
271
* Invoked during request authentication to check if the provided access token was authorized the requested scopes.
272
272
* Optional, if a custom authenticateHandler is used or if there is no scope part of the request.
273
273
*
274
274
*/
275
- verifyScope ?( token : Token , scope : string [ ] ) : Promise < boolean > ;
275
+ verifyScope ?( token : Token , scope : string [ ] ) : boolean | Promise < boolean > ;
276
276
}
277
277
278
278
interface AuthorizationCodeModel extends BaseModel , RequestAuthenticationModel {
279
279
/**
280
280
* Invoked to generate a new refresh token.
281
281
*
282
282
*/
283
- generateRefreshToken ?( client : Client , user : User , scope : string [ ] ) : Promise < string > ;
283
+ generateRefreshToken ?( client : Client , user : User , scope : string [ ] ) : string | Promise < string > ;
284
284
285
285
/**
286
286
* Invoked to generate a new authorization code.
287
287
*
288
288
*/
289
- generateAuthorizationCode ?( client : Client , user : User , scope : string [ ] ) : Promise < string > ;
289
+ generateAuthorizationCode ?( client : Client , user : User , scope : string [ ] ) : string | Promise < string > ;
290
290
291
291
/**
292
292
* Invoked to retrieve an existing authorization code previously saved through Model#saveAuthorizationCode().
293
293
*
294
294
*/
295
- getAuthorizationCode ( authorizationCode : string ) : Promise < AuthorizationCode | Falsey > ;
295
+ getAuthorizationCode ( authorizationCode : string ) : AuthorizationCode | Falsey | Promise < AuthorizationCode | Falsey > ;
296
296
297
297
/**
298
298
* Invoked to save an authorization code.
@@ -302,79 +302,79 @@ declare namespace OAuth2Server {
302
302
code : Pick < AuthorizationCode , 'authorizationCode' | 'expiresAt' | 'redirectUri' | 'scope' | 'codeChallenge' | 'codeChallengeMethod' > ,
303
303
client : Client ,
304
304
user : User
305
- ) : Promise < AuthorizationCode | Falsey > ;
305
+ ) : AuthorizationCode | Falsey | Promise < AuthorizationCode | Falsey > ;
306
306
307
307
/**
308
308
* Invoked to revoke an authorization code.
309
309
*
310
310
*/
311
- revokeAuthorizationCode ( code : AuthorizationCode ) : Promise < boolean > ;
311
+ revokeAuthorizationCode ( code : AuthorizationCode ) : boolean | Promise < boolean > ;
312
312
313
313
/**
314
314
* Invoked to check if the requested scope is valid for a particular client/user combination.
315
315
*
316
316
*/
317
- validateScope ?( user : User , client : Client , scope ?: string [ ] ) : Promise < string [ ] | Falsey > ;
317
+ validateScope ?( user : User , client : Client , scope ?: string [ ] ) : string [ ] | Falsey | Promise < string [ ] | Falsey > ;
318
318
319
319
/**
320
320
* Invoked to check if the provided `redirectUri` is valid for a particular `client`.
321
321
*
322
322
*/
323
- validateRedirectUri ?( redirect_uri : string , client : Client ) : Promise < boolean > ;
323
+ validateRedirectUri ?( redirect_uri : string , client : Client ) : boolean | Promise < boolean > ;
324
324
}
325
325
326
326
interface PasswordModel extends BaseModel , RequestAuthenticationModel {
327
327
/**
328
328
* Invoked to generate a new refresh token.
329
329
*
330
330
*/
331
- generateRefreshToken ?( client : Client , user : User , scope : string [ ] ) : Promise < string > ;
331
+ generateRefreshToken ?( client : Client , user : User , scope : string [ ] ) : string | Promise < string > ;
332
332
333
333
/**
334
334
* Invoked to retrieve a user using a username/password combination.
335
335
*
336
336
*/
337
- getUser ( username : string , password : string , client : Client ) : Promise < User | Falsey > ;
337
+ getUser ( username : string , password : string , client : Client ) : User | Falsey | Promise < User | Falsey > ;
338
338
339
339
/**
340
340
* Invoked to check if the requested scope is valid for a particular client/user combination.
341
341
*
342
342
*/
343
- validateScope ?( user : User , client : Client , scope ?: string [ ] ) : Promise < string [ ] | Falsey > ;
343
+ validateScope ?( user : User , client : Client , scope ?: string [ ] ) : string [ ] | Falsey | Promise < string [ ] | Falsey > ;
344
344
}
345
345
346
346
interface RefreshTokenModel extends BaseModel , RequestAuthenticationModel {
347
347
/**
348
348
* Invoked to generate a new refresh token.
349
349
*
350
350
*/
351
- generateRefreshToken ?( client : Client , user : User , scope : string [ ] ) : Promise < string > ;
351
+ generateRefreshToken ?( client : Client , user : User , scope : string [ ] ) : string | Promise < string > ;
352
352
353
353
/**
354
354
* Invoked to retrieve an existing refresh token previously saved through Model#saveToken().
355
355
*
356
356
*/
357
- getRefreshToken ( refreshToken : string ) : Promise < RefreshToken | Falsey > ;
357
+ getRefreshToken ( refreshToken : string ) : RefreshToken | Falsey | Promise < RefreshToken | Falsey > ;
358
358
359
359
/**
360
360
* Invoked to revoke a refresh token.
361
361
*
362
362
*/
363
- revokeToken ( token : RefreshToken ) : Promise < boolean > ;
363
+ revokeToken ( token : RefreshToken ) : boolean | Promise < boolean > ;
364
364
}
365
365
366
366
interface ClientCredentialsModel extends BaseModel , RequestAuthenticationModel {
367
367
/**
368
368
* Invoked to retrieve the user associated with the specified client.
369
369
*
370
370
*/
371
- getUserFromClient ( client : Client ) : Promise < User | Falsey > ;
371
+ getUserFromClient ( client : Client ) : User | Falsey | Promise < User | Falsey > ;
372
372
373
373
/**
374
374
* Invoked to check if the requested scope is valid for a particular client/user combination.
375
375
*
376
376
*/
377
- validateScope ?( user : User , client : Client , scope ?: string [ ] ) : Promise < string [ ] | Falsey > ;
377
+ validateScope ?( user : User , client : Client , scope ?: string [ ] ) : string [ ] | Falsey | Promise < string [ ] | Falsey > ;
378
378
}
379
379
380
380
interface ExtensionModel extends BaseModel , RequestAuthenticationModel { }
0 commit comments