diff --git a/index.d.ts b/index.d.ts index bb1396c..6b4bcf9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -245,19 +245,19 @@ declare namespace OAuth2Server { * Invoked to generate a new access token. * */ - generateAccessToken?(client: Client, user: User, scope: string[]): Promise; + generateAccessToken?(client: Client, user: User, scope: string[]): string | Promise; /** * Invoked to retrieve a client using a client id or a client id/client secret combination, depending on the grant type. * */ - getClient(clientId: string, clientSecret: string): Promise; + getClient(clientId: string, clientSecret: string): Client | Falsey | Promise; /** * Invoked to save an access token and optionally a refresh token, depending on the grant type. * */ - saveToken(token: Token, client: Client, user: User): Promise; + saveToken(token: Token, client: Client, user: User): Token | Falsey | Promise; } interface RequestAuthenticationModel { @@ -265,14 +265,14 @@ declare namespace OAuth2Server { * Invoked to retrieve an existing access token previously saved through Model#saveToken(). * */ - getAccessToken(accessToken: string): Promise; + getAccessToken(accessToken: string): Token | Falsey | Promise; /** * Invoked during request authentication to check if the provided access token was authorized the requested scopes. * Optional, if a custom authenticateHandler is used or if there is no scope part of the request. * */ - verifyScope?(token: Token, scope: string[]): Promise; + verifyScope?(token: Token, scope: string[]): boolean | Promise; } interface AuthorizationCodeModel extends BaseModel, RequestAuthenticationModel { @@ -280,19 +280,19 @@ declare namespace OAuth2Server { * Invoked to generate a new refresh token. * */ - generateRefreshToken?(client: Client, user: User, scope: string[]): Promise; + generateRefreshToken?(client: Client, user: User, scope: string[]): string | Promise; /** * Invoked to generate a new authorization code. * */ - generateAuthorizationCode?(client: Client, user: User, scope: string[]): Promise; + generateAuthorizationCode?(client: Client, user: User, scope: string[]): string | Promise; /** * Invoked to retrieve an existing authorization code previously saved through Model#saveAuthorizationCode(). * */ - getAuthorizationCode(authorizationCode: string): Promise; + getAuthorizationCode(authorizationCode: string): AuthorizationCode | Falsey | Promise; /** * Invoked to save an authorization code. @@ -302,25 +302,25 @@ declare namespace OAuth2Server { code: Pick, client: Client, user: User - ): Promise; + ): AuthorizationCode | Falsey | Promise; /** * Invoked to revoke an authorization code. * */ - revokeAuthorizationCode(code: AuthorizationCode): Promise; + revokeAuthorizationCode(code: AuthorizationCode): boolean | Promise; /** * Invoked to check if the requested scope is valid for a particular client/user combination. * */ - validateScope?(user: User, client: Client, scope?: string[]): Promise; + validateScope?(user: User, client: Client, scope?: string[]): string[] | Falsey | Promise; /** * Invoked to check if the provided `redirectUri` is valid for a particular `client`. * */ - validateRedirectUri?(redirect_uri: string, client: Client): Promise; + validateRedirectUri?(redirect_uri: string, client: Client): boolean | Promise; } interface PasswordModel extends BaseModel, RequestAuthenticationModel { @@ -328,19 +328,19 @@ declare namespace OAuth2Server { * Invoked to generate a new refresh token. * */ - generateRefreshToken?(client: Client, user: User, scope: string[]): Promise; + generateRefreshToken?(client: Client, user: User, scope: string[]): string | Promise; /** * Invoked to retrieve a user using a username/password combination. * */ - getUser(username: string, password: string, client: Client): Promise; + getUser(username: string, password: string, client: Client): User | Falsey | Promise; /** * Invoked to check if the requested scope is valid for a particular client/user combination. * */ - validateScope?(user: User, client: Client, scope?: string[]): Promise; + validateScope?(user: User, client: Client, scope?: string[]): string[] | Falsey | Promise; } interface RefreshTokenModel extends BaseModel, RequestAuthenticationModel { @@ -348,19 +348,19 @@ declare namespace OAuth2Server { * Invoked to generate a new refresh token. * */ - generateRefreshToken?(client: Client, user: User, scope: string[]): Promise; + generateRefreshToken?(client: Client, user: User, scope: string[]): string | Promise; /** * Invoked to retrieve an existing refresh token previously saved through Model#saveToken(). * */ - getRefreshToken(refreshToken: string): Promise; + getRefreshToken(refreshToken: string): RefreshToken | Falsey | Promise; /** * Invoked to revoke a refresh token. * */ - revokeToken(token: RefreshToken): Promise; + revokeToken(token: RefreshToken): boolean | Promise; } interface ClientCredentialsModel extends BaseModel, RequestAuthenticationModel { @@ -368,13 +368,13 @@ declare namespace OAuth2Server { * Invoked to retrieve the user associated with the specified client. * */ - getUserFromClient(client: Client): Promise; + getUserFromClient(client: Client): User | Falsey | Promise; /** * Invoked to check if the requested scope is valid for a particular client/user combination. * */ - validateScope?(user: User, client: Client, scope?: string[]): Promise; + validateScope?(user: User, client: Client, scope?: string[]): string[] | Falsey | Promise; } interface ExtensionModel extends BaseModel, RequestAuthenticationModel {}