| "use strict";
|
| Object.defineProperty(exports, "__esModule", { value: true });
|
| exports.OAUTH_ERRORS = exports.CustomOAuthError = exports.InvalidTargetError = exports.InsufficientScopeError = exports.InvalidClientMetadataError = exports.TooManyRequestsError = exports.MethodNotAllowedError = exports.InvalidTokenError = exports.UnsupportedTokenTypeError = exports.UnsupportedResponseTypeError = exports.TemporarilyUnavailableError = exports.ServerError = exports.AccessDeniedError = exports.InvalidScopeError = exports.UnsupportedGrantTypeError = exports.UnauthorizedClientError = exports.InvalidGrantError = exports.InvalidClientError = exports.InvalidRequestError = exports.OAuthError = void 0;
|
| |
| |
|
|
| class OAuthError extends Error {
|
| constructor(message, errorUri) {
|
| super(message);
|
| this.errorUri = errorUri;
|
| this.name = this.constructor.name;
|
| }
|
| |
| |
|
|
| toResponseObject() {
|
| const response = {
|
| error: this.errorCode,
|
| error_description: this.message
|
| };
|
| if (this.errorUri) {
|
| response.error_uri = this.errorUri;
|
| }
|
| return response;
|
| }
|
| get errorCode() {
|
| return this.constructor.errorCode;
|
| }
|
| }
|
| exports.OAuthError = OAuthError;
|
| |
| |
| |
| |
|
|
| class InvalidRequestError extends OAuthError {
|
| }
|
| exports.InvalidRequestError = InvalidRequestError;
|
| InvalidRequestError.errorCode = 'invalid_request';
|
| |
| |
| |
|
|
| class InvalidClientError extends OAuthError {
|
| }
|
| exports.InvalidClientError = InvalidClientError;
|
| InvalidClientError.errorCode = 'invalid_client';
|
| |
| |
| |
| |
|
|
| class InvalidGrantError extends OAuthError {
|
| }
|
| exports.InvalidGrantError = InvalidGrantError;
|
| InvalidGrantError.errorCode = 'invalid_grant';
|
| |
| |
| |
|
|
| class UnauthorizedClientError extends OAuthError {
|
| }
|
| exports.UnauthorizedClientError = UnauthorizedClientError;
|
| UnauthorizedClientError.errorCode = 'unauthorized_client';
|
| |
| |
| |
|
|
| class UnsupportedGrantTypeError extends OAuthError {
|
| }
|
| exports.UnsupportedGrantTypeError = UnsupportedGrantTypeError;
|
| UnsupportedGrantTypeError.errorCode = 'unsupported_grant_type';
|
| |
| |
| |
|
|
| class InvalidScopeError extends OAuthError {
|
| }
|
| exports.InvalidScopeError = InvalidScopeError;
|
| InvalidScopeError.errorCode = 'invalid_scope';
|
| |
| |
|
|
| class AccessDeniedError extends OAuthError {
|
| }
|
| exports.AccessDeniedError = AccessDeniedError;
|
| AccessDeniedError.errorCode = 'access_denied';
|
| |
| |
| |
|
|
| class ServerError extends OAuthError {
|
| }
|
| exports.ServerError = ServerError;
|
| ServerError.errorCode = 'server_error';
|
| |
| |
| |
|
|
| class TemporarilyUnavailableError extends OAuthError {
|
| }
|
| exports.TemporarilyUnavailableError = TemporarilyUnavailableError;
|
| TemporarilyUnavailableError.errorCode = 'temporarily_unavailable';
|
| |
| |
| |
|
|
| class UnsupportedResponseTypeError extends OAuthError {
|
| }
|
| exports.UnsupportedResponseTypeError = UnsupportedResponseTypeError;
|
| UnsupportedResponseTypeError.errorCode = 'unsupported_response_type';
|
| |
| |
| |
|
|
| class UnsupportedTokenTypeError extends OAuthError {
|
| }
|
| exports.UnsupportedTokenTypeError = UnsupportedTokenTypeError;
|
| UnsupportedTokenTypeError.errorCode = 'unsupported_token_type';
|
| |
| |
| |
|
|
| class InvalidTokenError extends OAuthError {
|
| }
|
| exports.InvalidTokenError = InvalidTokenError;
|
| InvalidTokenError.errorCode = 'invalid_token';
|
| |
| |
| |
|
|
| class MethodNotAllowedError extends OAuthError {
|
| }
|
| exports.MethodNotAllowedError = MethodNotAllowedError;
|
| MethodNotAllowedError.errorCode = 'method_not_allowed';
|
| |
| |
| |
|
|
| class TooManyRequestsError extends OAuthError {
|
| }
|
| exports.TooManyRequestsError = TooManyRequestsError;
|
| TooManyRequestsError.errorCode = 'too_many_requests';
|
| |
| |
| |
|
|
| class InvalidClientMetadataError extends OAuthError {
|
| }
|
| exports.InvalidClientMetadataError = InvalidClientMetadataError;
|
| InvalidClientMetadataError.errorCode = 'invalid_client_metadata';
|
| |
| |
|
|
| class InsufficientScopeError extends OAuthError {
|
| }
|
| exports.InsufficientScopeError = InsufficientScopeError;
|
| InsufficientScopeError.errorCode = 'insufficient_scope';
|
| |
| |
| |
|
|
| class InvalidTargetError extends OAuthError {
|
| }
|
| exports.InvalidTargetError = InvalidTargetError;
|
| InvalidTargetError.errorCode = 'invalid_target';
|
| |
| |
|
|
| class CustomOAuthError extends OAuthError {
|
| constructor(customErrorCode, message, errorUri) {
|
| super(message, errorUri);
|
| this.customErrorCode = customErrorCode;
|
| }
|
| get errorCode() {
|
| return this.customErrorCode;
|
| }
|
| }
|
| exports.CustomOAuthError = CustomOAuthError;
|
| |
| |
|
|
| exports.OAUTH_ERRORS = {
|
| [InvalidRequestError.errorCode]: InvalidRequestError,
|
| [InvalidClientError.errorCode]: InvalidClientError,
|
| [InvalidGrantError.errorCode]: InvalidGrantError,
|
| [UnauthorizedClientError.errorCode]: UnauthorizedClientError,
|
| [UnsupportedGrantTypeError.errorCode]: UnsupportedGrantTypeError,
|
| [InvalidScopeError.errorCode]: InvalidScopeError,
|
| [AccessDeniedError.errorCode]: AccessDeniedError,
|
| [ServerError.errorCode]: ServerError,
|
| [TemporarilyUnavailableError.errorCode]: TemporarilyUnavailableError,
|
| [UnsupportedResponseTypeError.errorCode]: UnsupportedResponseTypeError,
|
| [UnsupportedTokenTypeError.errorCode]: UnsupportedTokenTypeError,
|
| [InvalidTokenError.errorCode]: InvalidTokenError,
|
| [MethodNotAllowedError.errorCode]: MethodNotAllowedError,
|
| [TooManyRequestsError.errorCode]: TooManyRequestsError,
|
| [InvalidClientMetadataError.errorCode]: InvalidClientMetadataError,
|
| [InsufficientScopeError.errorCode]: InsufficientScopeError,
|
| [InvalidTargetError.errorCode]: InvalidTargetError
|
| };
|
| |