You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
750 B
24 lines
750 B
export const OAuthErrorCodes = {
|
|
PROVIDER_NOT_FOUND: 'OAUTH_PROVIDER_NOT_FOUND',
|
|
STATE_INVALID: 'OAUTH_STATE_INVALID',
|
|
STATE_EXPIRED: 'OAUTH_STATE_EXPIRED',
|
|
TOKEN_EXCHANGE_FAILED: 'OAUTH_TOKEN_EXCHANGE_FAILED',
|
|
USER_INFO_FAILED: 'OAUTH_USER_INFO_FAILED',
|
|
ALREADY_BIND: 'OAUTH_ALREADY_BIND',
|
|
BINDING_USER_MISMATCH: 'OAUTH_BINDING_USER_MISMATCH',
|
|
BINDING_TOKEN_INVALID: 'OAUTH_BINDING_TOKEN_INVALID',
|
|
LAST_BIND: 'OAUTH_LAST_BIND',
|
|
} as const;
|
|
|
|
export type OAuthErrorCode = typeof OAuthErrorCodes[keyof typeof OAuthErrorCodes];
|
|
|
|
export class OAuthError extends Error {
|
|
constructor(
|
|
public code: OAuthErrorCode,
|
|
message: string,
|
|
public statusCode: number = 400
|
|
) {
|
|
super(message);
|
|
this.name = 'OAuthError';
|
|
}
|
|
}
|