diff --git a/types/oauth2-server/index.d.ts b/types/oauth2-server/index.d.ts index 6729a05e7e..6c20aab221 100644 --- a/types/oauth2-server/index.d.ts +++ b/types/oauth2-server/index.d.ts @@ -1,7 +1,8 @@ // Type definitions for Node OAuth2 Server 3.0 // Project: https://github.com/oauthjs/node-oauth2-server // Definitions by: Robbie Van Gorkom , -// Charles Irick +// Charles Irick , +// Daniel Fischer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -263,7 +264,7 @@ declare namespace OAuth2Server { * Invoked to check if the requested scope is valid for a particular client/user combination. * */ - validateScope?(user: User, client: Client, scope: string, callback?: Callback): Promise; + validateScope?(user: User, client: Client, scope: string, callback?: Callback): Promise; } interface PasswordModel extends BaseModel, RequestAuthenticationModel { @@ -283,7 +284,7 @@ declare namespace OAuth2Server { * Invoked to check if the requested scope is valid for a particular client/user combination. * */ - validateScope?(user: User, client: Client, scope: string, callback?: Callback): Promise; + validateScope?(user: User, client: Client, scope: string, callback?: Callback): Promise; } interface RefreshTokenModel extends BaseModel, RequestAuthenticationModel { @@ -317,7 +318,7 @@ declare namespace OAuth2Server { * Invoked to check if the requested scope is valid for a particular client/user combination. * */ - validateScope?(user: User, client: Client, scope: string, callback?: Callback): Promise; + validateScope?(user: User, client: Client, scope: string, callback?: Callback): Promise; } interface ExtensionModel extends BaseModel, RequestAuthenticationModel {} @@ -380,6 +381,39 @@ declare namespace OAuth2Server { user: User; [key: string]: any; } + + class OAuthError extends Error { + constructor(messageOrError: string | Error, properties?: object); + + /** + * The HTTP error code. + */ + code: number; + + /** + * The OAuth error code. + */ + name: string; + + /** + * A human-readable error message. + */ + message: string; + } + + class AccessDeniedError extends OAuthError {} + class InsufficientScopeError extends OAuthError {} + class InvalidArgumentError extends OAuthError {} + class InvalidClientError extends OAuthError {} + class InvalidGrantError extends OAuthError {} + class InvalidRequestError extends OAuthError {} + class InvalidScopeError extends OAuthError {} + class InvalidTokenError extends OAuthError {} + class ServerError extends OAuthError {} + class UnauthorizedClientError extends OAuthError {} + class UnauthorizedRequestError extends OAuthError {} + class UnsupportedGrantTypeError extends OAuthError {} + class UnsupportedResponseTypeError extends OAuthError {} } export = OAuth2Server;