diff --git a/.gitignore b/.gitignore index ed37ca5c4..f3058e9b3 100755 --- a/.gitignore +++ b/.gitignore @@ -15,5 +15,6 @@ __pycache__/ # files .DS_Store + *.pyc /aio diff --git a/lib/errors/access-denied-error.ts b/lib/errors/access-denied-error.ts index 681ca61ab..f067cc9d5 100755 --- a/lib/errors/access-denied-error.ts +++ b/lib/errors/access-denied-error.ts @@ -9,7 +9,7 @@ import { OAuthError } from './oauth-error'; */ export class AccessDeniedError extends OAuthError { - constructor(message?: string | Error, properties?: any) { + constructor(message?: string | Error, properties?: object) { super(message, { code: 400, name: 'access_denied', ...properties }); } } diff --git a/lib/errors/insufficient-scope-error.ts b/lib/errors/insufficient-scope-error.ts index f50b4a9e5..8f7e89f41 100755 --- a/lib/errors/insufficient-scope-error.ts +++ b/lib/errors/insufficient-scope-error.ts @@ -9,7 +9,7 @@ import { OAuthError } from './oauth-error'; */ export class InsufficientScopeError extends OAuthError { - constructor(message?: string | Error, properties?: any) { + constructor(message?: string | Error, properties?: object) { super(message, { code: 403, name: 'insufficient_scope', ...properties }); } } diff --git a/lib/errors/invalid-argument-error.ts b/lib/errors/invalid-argument-error.ts index b4c5adbd2..6370d40e4 100755 --- a/lib/errors/invalid-argument-error.ts +++ b/lib/errors/invalid-argument-error.ts @@ -1,7 +1,7 @@ import { OAuthError } from './oauth-error'; export class InvalidArgumentError extends OAuthError { - constructor(message?: string | Error, properties?: any) { + constructor(message?: string | Error, properties?: object) { super(message, { code: 500, name: 'invalid_argument', ...properties }); } } diff --git a/lib/errors/invalid-client-error.ts b/lib/errors/invalid-client-error.ts index 8c296a2d0..93f621a9c 100755 --- a/lib/errors/invalid-client-error.ts +++ b/lib/errors/invalid-client-error.ts @@ -10,7 +10,7 @@ import { OAuthError } from './oauth-error'; */ export class InvalidClientError extends OAuthError { - constructor(message?: string | Error, properties?: any) { + constructor(message?: string | Error, properties?: object) { super(message, { code: 400, name: 'invalid_client', ...properties }); } } diff --git a/lib/errors/invalid-grant-error.ts b/lib/errors/invalid-grant-error.ts index 8c37a3c9f..71dfdaf9a 100755 --- a/lib/errors/invalid-grant-error.ts +++ b/lib/errors/invalid-grant-error.ts @@ -11,7 +11,7 @@ import { OAuthError } from './oauth-error'; */ export class InvalidGrantError extends OAuthError { - constructor(message?: string | Error, properties?: any) { + constructor(message?: string | Error, properties?: object) { super(message, { code: 400, name: 'invalid_grant', ...properties }); } } diff --git a/lib/errors/invalid-request-error.ts b/lib/errors/invalid-request-error.ts index 6fe0a253b..6afcecaaf 100755 --- a/lib/errors/invalid-request-error.ts +++ b/lib/errors/invalid-request-error.ts @@ -10,7 +10,7 @@ import { OAuthError } from './oauth-error'; */ export class InvalidRequestError extends OAuthError { - constructor(message?: string | Error, properties?: any) { + constructor(message?: string | Error, properties?: object) { super(message, { code: 400, name: 'invalid_request', ...properties }); } } diff --git a/lib/errors/invalid-scope-error.ts b/lib/errors/invalid-scope-error.ts index 6f3977fb5..474914c3e 100755 --- a/lib/errors/invalid-scope-error.ts +++ b/lib/errors/invalid-scope-error.ts @@ -9,7 +9,7 @@ import { OAuthError } from './oauth-error'; */ export class InvalidScopeError extends OAuthError { - constructor(message?: string | Error, properties?: any) { + constructor(message?: string | Error, properties?: object) { super(message, { code: 400, name: 'invalid_scope', ...properties }); } } diff --git a/lib/errors/invalid-token-error.ts b/lib/errors/invalid-token-error.ts index ea22f3012..f4177085b 100755 --- a/lib/errors/invalid-token-error.ts +++ b/lib/errors/invalid-token-error.ts @@ -9,7 +9,7 @@ import { OAuthError } from './oauth-error'; */ export class InvalidTokenError extends OAuthError { - constructor(message?: string | Error, properties?: any) { - super(message, { code: 401, name: 'invalid_token', ...properties }); + constructor(message?: string | Error, properties?: object) { + super(message, { code: 400, name: 'invalid_token', ...properties }); } } diff --git a/lib/errors/oauth-error.ts b/lib/errors/oauth-error.ts index a9ee7c842..80c5054c6 100755 --- a/lib/errors/oauth-error.ts +++ b/lib/errors/oauth-error.ts @@ -1,11 +1,20 @@ import { defaults, isEmpty } from 'lodash'; import * as statuses from 'statuses'; +interface OAuthErrorProperties { + code: number; + name: string; + [propName: string]: any; +} + export class OAuthError extends Error { - code: any; - status: any; - statusCode: any; - constructor(messageOrError: string | Error, properties?: any) { + code: number; + status: number; + statusCode: number; + constructor( + messageOrError: string | Error, + properties?: OAuthErrorProperties, + ) { super(); let message = messageOrError instanceof Error ? messageOrError.message : messageOrError; diff --git a/lib/errors/server-error.ts b/lib/errors/server-error.ts index 68db41ef4..e63453a42 100755 --- a/lib/errors/server-error.ts +++ b/lib/errors/server-error.ts @@ -9,7 +9,7 @@ import { OAuthError } from './oauth-error'; */ export class ServerError extends OAuthError { - constructor(message?: string | Error, properties?: any) { - super(message, { code: 500, name: 'server_error', ...properties }); + constructor(message?: string | Error, properties?: object) { + super(message, { code: 503, name: 'server_error', ...properties }); } } diff --git a/lib/errors/unauthorized-client-error.ts b/lib/errors/unauthorized-client-error.ts index 87d7167b7..7e94c1f7e 100755 --- a/lib/errors/unauthorized-client-error.ts +++ b/lib/errors/unauthorized-client-error.ts @@ -9,10 +9,7 @@ import { OAuthError } from './oauth-error'; */ export class UnauthorizedClientError extends OAuthError { - constructor( - message?: string | Error, - properties?: { code?: number; message?: string }, - ) { + constructor(message?: string | Error, properties?: object) { super(message, { code: 400, name: 'unauthorized_client', ...properties }); } } diff --git a/lib/errors/unauthorized-request-error.ts b/lib/errors/unauthorized-request-error.ts index ba98235da..1458fb39c 100755 --- a/lib/errors/unauthorized-request-error.ts +++ b/lib/errors/unauthorized-request-error.ts @@ -12,7 +12,7 @@ import { OAuthError } from './oauth-error'; */ export class UnauthorizedRequestError extends OAuthError { - constructor(message?: string | Error, properties?: any) { + constructor(message?: string | Error, properties?: object) { super(message, { code: 401, name: 'unauthorized_request', ...properties }); } } diff --git a/lib/errors/unsupported-grant-type-error.ts b/lib/errors/unsupported-grant-type-error.ts index 7a249d343..81de076e0 100755 --- a/lib/errors/unsupported-grant-type-error.ts +++ b/lib/errors/unsupported-grant-type-error.ts @@ -9,7 +9,7 @@ import { OAuthError } from './oauth-error'; */ export class UnsupportedGrantTypeError extends OAuthError { - constructor(message?: string | Error, properties?: any) { + constructor(message?: string | Error, properties?: object) { super(message, { code: 400, name: 'unsupported_grant_type', diff --git a/lib/errors/unsupported-response-type-error.ts b/lib/errors/unsupported-response-type-error.ts index 14c3f9e83..37f6464ad 100755 --- a/lib/errors/unsupported-response-type-error.ts +++ b/lib/errors/unsupported-response-type-error.ts @@ -10,7 +10,7 @@ import { OAuthError } from './oauth-error'; */ export class UnsupportedResponseTypeError extends OAuthError { - constructor(message?: string | Error, properties?: any) { + constructor(message?: string | Error, properties?: object) { super(message, { code: 400, name: 'unsupported_response_type',