2020-12-13 14:36:07 +00:00
|
|
|
export class OAuth2Error extends Error {
|
2017-08-23 20:13:45 +00:00
|
|
|
constructor (code, msg, status) {
|
|
|
|
super()
|
|
|
|
Error.captureStackTrace(this, this.constructor)
|
|
|
|
|
|
|
|
this.code = code
|
|
|
|
this.message = msg
|
|
|
|
this.status = status
|
|
|
|
|
|
|
|
this.name = 'OAuth2AbstractError'
|
|
|
|
this.logLevel = 'error'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-13 14:36:07 +00:00
|
|
|
export class AccessDenied extends OAuth2Error {
|
2017-08-23 20:13:45 +00:00
|
|
|
constructor (msg) {
|
|
|
|
super('access_denied', msg, 403)
|
|
|
|
|
|
|
|
this.name = 'OAuth2AccessDenied'
|
|
|
|
this.logLevel = 'info'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-13 14:36:07 +00:00
|
|
|
export class InvalidClient extends OAuth2Error {
|
2017-08-23 20:13:45 +00:00
|
|
|
constructor (msg) {
|
|
|
|
super('invalid_client', msg, 401)
|
|
|
|
|
|
|
|
this.name = 'OAuth2InvalidClient'
|
|
|
|
this.logLevel = 'info'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-13 14:36:07 +00:00
|
|
|
export class InvalidGrant extends OAuth2Error {
|
2017-08-23 20:13:45 +00:00
|
|
|
constructor (msg) {
|
|
|
|
super('invalid_grant', msg, 400)
|
|
|
|
|
|
|
|
this.name = 'OAuth2InvalidGrant'
|
|
|
|
this.logLevel = 'info'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-13 14:36:07 +00:00
|
|
|
export class InvalidRequest extends OAuth2Error {
|
2017-08-23 20:13:45 +00:00
|
|
|
constructor (msg) {
|
|
|
|
super('invalid_request', msg, 400)
|
|
|
|
|
|
|
|
this.name = 'OAuth2InvalidRequest'
|
|
|
|
this.logLevel = 'info'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-13 14:36:07 +00:00
|
|
|
export class InvalidScope extends OAuth2Error {
|
2017-08-23 20:13:45 +00:00
|
|
|
constructor (msg) {
|
|
|
|
super('invalid_scope', msg, 400)
|
|
|
|
|
|
|
|
this.name = 'OAuth2InvalidScope'
|
|
|
|
this.logLevel = 'info'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-13 14:36:07 +00:00
|
|
|
export class ServerError extends OAuth2Error {
|
2017-08-23 20:13:45 +00:00
|
|
|
constructor (msg) {
|
|
|
|
super('server_error', msg, 500)
|
|
|
|
|
|
|
|
this.name = 'OAuth2ServerError'
|
|
|
|
this.logLevel = 'error'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-13 14:36:07 +00:00
|
|
|
export class UnauthorizedClient extends OAuth2Error {
|
2017-08-23 20:13:45 +00:00
|
|
|
constructor (msg) {
|
|
|
|
super('unauthorized_client', msg, 400)
|
|
|
|
|
|
|
|
this.name = 'OAuth2UnauthorizedClient'
|
|
|
|
this.logLevel = 'info'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-13 14:36:07 +00:00
|
|
|
export class UnsupportedGrantType extends OAuth2Error {
|
2017-08-23 20:13:45 +00:00
|
|
|
constructor (msg) {
|
|
|
|
super('unsupported_grant_type', msg, 400)
|
|
|
|
|
|
|
|
this.name = 'OAuth2UnsupportedGrantType'
|
|
|
|
this.logLevel = 'info'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-13 14:36:07 +00:00
|
|
|
export class UnsupportedResponseType extends OAuth2Error {
|
2017-08-23 20:13:45 +00:00
|
|
|
constructor (msg) {
|
|
|
|
super('unsupported_response_type', msg, 400)
|
|
|
|
|
|
|
|
this.name = 'OAuth2UnsupportedResponseType'
|
|
|
|
this.logLevel = 'info'
|
|
|
|
}
|
|
|
|
}
|