Skip to content

Commit 3bffe8b

Browse files
Removed callback support in typings.
1 parent 471af88 commit 3bffe8b

File tree

1 file changed

+23
-31
lines changed

1 file changed

+23
-31
lines changed

index.d.ts

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ declare class OAuth2Server {
2323
authenticate(
2424
request: OAuth2Server.Request,
2525
response: OAuth2Server.Response,
26-
options?: OAuth2Server.AuthenticateOptions,
27-
callback?: OAuth2Server.Callback<OAuth2Server.Token>
26+
options?: OAuth2Server.AuthenticateOptions
2827
): Promise<OAuth2Server.Token>;
2928

3029
/**
@@ -33,8 +32,7 @@ declare class OAuth2Server {
3332
authorize(
3433
request: OAuth2Server.Request,
3534
response: OAuth2Server.Response,
36-
options?: OAuth2Server.AuthorizeOptions,
37-
callback?: OAuth2Server.Callback<OAuth2Server.AuthorizationCode>
35+
options?: OAuth2Server.AuthorizeOptions
3836
): Promise<OAuth2Server.AuthorizationCode>;
3937

4038
/**
@@ -43,8 +41,7 @@ declare class OAuth2Server {
4341
token(
4442
request: OAuth2Server.Request,
4543
response: OAuth2Server.Response,
46-
options?: OAuth2Server.TokenOptions,
47-
callback?: OAuth2Server.Callback<OAuth2Server.Token>
44+
options?: OAuth2Server.TokenOptions
4845
): Promise<OAuth2Server.Token>;
4946
}
5047

@@ -238,11 +235,6 @@ declare namespace OAuth2Server {
238235
extendedGrantTypes?: { [key: string]: typeof AbstractGrantType } | undefined;
239236
}
240237

241-
/**
242-
* Represents a generic callback structure for model callbacks
243-
*/
244-
type Callback<T> = (err?: any, result?: T) => void;
245-
246238
/**
247239
* For returning falsey parameters in cases of failure
248240
*/
@@ -253,53 +245,53 @@ declare namespace OAuth2Server {
253245
* Invoked to generate a new access token.
254246
*
255247
*/
256-
generateAccessToken?(client: Client, user: User, scope: string | string[], callback?: Callback<string>): Promise<string>;
248+
generateAccessToken?(client: Client, user: User, scope: string | string[]): Promise<string>;
257249

258250
/**
259251
* Invoked to retrieve a client using a client id or a client id/client secret combination, depending on the grant type.
260252
*
261253
*/
262-
getClient(clientId: string, clientSecret: string, callback?: Callback<Client | Falsey>): Promise<Client | Falsey>;
254+
getClient(clientId: string, clientSecret: string): Promise<Client | Falsey>;
263255

264256
/**
265257
* Invoked to save an access token and optionally a refresh token, depending on the grant type.
266258
*
267259
*/
268-
saveToken(token: Token, client: Client, user: User, callback?: Callback<Token>): Promise<Token | Falsey>;
260+
saveToken(token: Token, client: Client, user: User): Promise<Token | Falsey>;
269261
}
270262

271263
interface RequestAuthenticationModel {
272264
/**
273265
* Invoked to retrieve an existing access token previously saved through Model#saveToken().
274266
*
275267
*/
276-
getAccessToken(accessToken: string, callback?: Callback<Token>): Promise<Token | Falsey>;
268+
getAccessToken(accessToken: string): Promise<Token | Falsey>;
277269

278270
/**
279271
* Invoked during request authentication to check if the provided access token was authorized the requested scopes.
280272
*
281273
*/
282-
verifyScope(token: Token, scope: string | string[], callback?: Callback<boolean>): Promise<boolean>;
274+
verifyScope(token: Token, scope: string | string[]): Promise<boolean>;
283275
}
284276

285277
interface AuthorizationCodeModel extends BaseModel, RequestAuthenticationModel {
286278
/**
287279
* Invoked to generate a new refresh token.
288280
*
289281
*/
290-
generateRefreshToken?(client: Client, user: User, scope: string | string[], callback?: Callback<string>): Promise<string>;
282+
generateRefreshToken?(client: Client, user: User, scope: string | string[]): Promise<string>;
291283

292284
/**
293285
* Invoked to generate a new authorization code.
294286
*
295287
*/
296-
generateAuthorizationCode?(client: Client, user: User, scope: string | string[], callback?: Callback<string>): Promise<string>;
288+
generateAuthorizationCode?(client: Client, user: User, scope: string | string[]): Promise<string>;
297289

298290
/**
299291
* Invoked to retrieve an existing authorization code previously saved through Model#saveAuthorizationCode().
300292
*
301293
*/
302-
getAuthorizationCode(authorizationCode: string, callback?: Callback<AuthorizationCode>): Promise<AuthorizationCode | Falsey>;
294+
getAuthorizationCode(authorizationCode: string): Promise<AuthorizationCode | Falsey>;
303295

304296
/**
305297
* Invoked to save an authorization code.
@@ -308,20 +300,20 @@ declare namespace OAuth2Server {
308300
saveAuthorizationCode(
309301
code: Pick<AuthorizationCode, 'authorizationCode' | 'expiresAt' | 'redirectUri' | 'scope' | 'codeChallenge' | 'codeChallengeMethod'>,
310302
client: Client,
311-
user: User,
312-
callback?: Callback<AuthorizationCode>): Promise<AuthorizationCode | Falsey>;
303+
user: User
304+
): Promise<AuthorizationCode | Falsey>;
313305

314306
/**
315307
* Invoked to revoke an authorization code.
316308
*
317309
*/
318-
revokeAuthorizationCode(code: AuthorizationCode, callback?: Callback<boolean>): Promise<boolean>;
310+
revokeAuthorizationCode(code: AuthorizationCode): Promise<boolean>;
319311

320312
/**
321313
* Invoked to check if the requested scope is valid for a particular client/user combination.
322314
*
323315
*/
324-
validateScope?(user: User, client: Client, scope: string | string[], callback?: Callback<string | Falsey>): Promise<string | string[] | Falsey>;
316+
validateScope?(user: User, client: Client, scope: string | string[]): Promise<string | string[] | Falsey>;
325317

326318
/**
327319
* Invoked to check if the provided `redirectUri` is valid for a particular `client`.
@@ -335,53 +327,53 @@ declare namespace OAuth2Server {
335327
* Invoked to generate a new refresh token.
336328
*
337329
*/
338-
generateRefreshToken?(client: Client, user: User, scope: string | string[], callback?: Callback<string>): Promise<string>;
330+
generateRefreshToken?(client: Client, user: User, scope: string | string[]): Promise<string>;
339331

340332
/**
341333
* Invoked to retrieve a user using a username/password combination.
342334
*
343335
*/
344-
getUser(username: string, password: string, callback?: Callback<User | Falsey>): Promise<User | Falsey>;
336+
getUser(username: string, password: string): Promise<User | Falsey>;
345337

346338
/**
347339
* Invoked to check if the requested scope is valid for a particular client/user combination.
348340
*
349341
*/
350-
validateScope?(user: User, client: Client, scope: string | string[], callback?: Callback<string | Falsey>): Promise<string | string[] | Falsey>;
342+
validateScope?(user: User, client: Client, scope: string | string[]): Promise<string | string[] | Falsey>;
351343
}
352344

353345
interface RefreshTokenModel extends BaseModel, RequestAuthenticationModel {
354346
/**
355347
* Invoked to generate a new refresh token.
356348
*
357349
*/
358-
generateRefreshToken?(client: Client, user: User, scope: string | string[], callback?: Callback<string>): Promise<string>;
350+
generateRefreshToken?(client: Client, user: User, scope: string | string[]): Promise<string>;
359351

360352
/**
361353
* Invoked to retrieve an existing refresh token previously saved through Model#saveToken().
362354
*
363355
*/
364-
getRefreshToken(refreshToken: string, callback?: Callback<RefreshToken>): Promise<RefreshToken | Falsey>;
356+
getRefreshToken(refreshToken: string): Promise<RefreshToken | Falsey>;
365357

366358
/**
367359
* Invoked to revoke a refresh token.
368360
*
369361
*/
370-
revokeToken(token: RefreshToken | Token, callback?: Callback<boolean>): Promise<boolean>;
362+
revokeToken(token: RefreshToken | Token): Promise<boolean>;
371363
}
372364

373365
interface ClientCredentialsModel extends BaseModel, RequestAuthenticationModel {
374366
/**
375367
* Invoked to retrieve the user associated with the specified client.
376368
*
377369
*/
378-
getUserFromClient(client: Client, callback?: Callback<User | Falsey>): Promise<User | Falsey>;
370+
getUserFromClient(client: Client): Promise<User | Falsey>;
379371

380372
/**
381373
* Invoked to check if the requested scope is valid for a particular client/user combination.
382374
*
383375
*/
384-
validateScope?(user: User, client: Client, scope: string | string[], callback?: Callback<string | Falsey>): Promise<string | string[] | Falsey>;
376+
validateScope?(user: User, client: Client, scope: string | string[]): Promise<string | string[] | Falsey>;
385377
}
386378

387379
interface ExtensionModel extends BaseModel, RequestAuthenticationModel {}

0 commit comments

Comments
 (0)