@adonisjs/ally
Version:
Social authentication provider for AdonisJS
199 lines (198 loc) • 6.14 kB
TypeScript
import { Exception } from '@adonisjs/core/exceptions';
import { type HttpContext } from '@adonisjs/core/http';
/**
* Base exception that self-handles by content-negotiating the
* HTTP response (HTML with session flash, JSON, JSONAPI)
* and supporting i18n translation.
*/
export declare abstract class HttpResponseException extends Exception {
abstract identifier: string;
/**
* Returns the message to be sent in the HTTP response.
* Feel free to override this method and return a custom
* response.
*/
getResponseMessage(error: this, ctx: HttpContext): string;
/**
* Converts exception to an HTTP response
*/
handle(error: this, ctx: HttpContext): Promise<void>;
}
/**
* Error thrown when the OAuth redirect is missing the required
* authorization code or token parameter.
*
* @example
* ```ts
* throw new errors.E_OAUTH_MISSING_CODE(['code'])
* ```
*/
export declare const E_OAUTH_MISSING_CODE: {
new (args: [string], options?: ErrorOptions): {
/**
* Translation identifier. Can be customized
*/
identifier: string;
/**
* Returns the message to be sent in the HTTP response.
* Feel free to override this method and return a custom
* response.
*/
getResponseMessage(error: /*elided*/ any, ctx: HttpContext): string;
/**
* Converts exception to an HTTP response
*/
handle(error: /*elided*/ any, ctx: HttpContext): Promise<void>;
name: string;
help?: string;
code?: string;
status: number;
toString(): string;
get [Symbol.toStringTag](): string;
message: string;
stack?: string;
cause?: unknown;
};
status: number;
code: string;
help?: string;
message?: string;
isError(error: unknown): error is Error;
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
stackTraceLimit: number;
};
/**
* Error thrown when the OAuth state parameter does not match
* the expected value, indicating a potential CSRF attack.
*
* @example
* ```ts
* throw new errors.E_OAUTH_STATE_MISMATCH()
* ```
*/
export declare const E_OAUTH_STATE_MISMATCH: {
new (message?: string, options?: ErrorOptions & {
code?: string;
status?: number;
}): {
/**
* Translation identifier. Can be customized
*/
identifier: string;
/**
* Returns the message to be sent in the HTTP response.
* Feel free to override this method and return a custom
* response.
*/
getResponseMessage(error: /*elided*/ any, ctx: HttpContext): string;
/**
* Converts exception to an HTTP response
*/
handle(error: /*elided*/ any, ctx: HttpContext): Promise<void>;
name: string;
help?: string;
code?: string;
status: number;
toString(): string;
get [Symbol.toStringTag](): string;
message: string;
stack?: string;
cause?: unknown;
};
status: number;
code: string;
message: string;
help?: string;
isError(error: unknown): error is Error;
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
stackTraceLimit: number;
};
/**
* Error thrown when attempting to use an unknown Ally provider.
*
* @example
* ```ts
* throw new errors.E_UNKNOWN_ALLY_PROVIDER(['github'])
* ```
*/
export declare const E_UNKNOWN_ALLY_PROVIDER: {
new (args: [string], options?: ErrorOptions): {
/**
* Translation identifier. Can be customized
*/
identifier: string;
/**
* Returns the message to be sent in the HTTP response.
* Feel free to override this method and return a custom
* response.
*/
getResponseMessage(error: /*elided*/ any, ctx: HttpContext): string;
/**
* Converts exception to an HTTP response
*/
handle(error: /*elided*/ any, ctx: HttpContext): Promise<void>;
name: string;
help?: string;
code?: string;
status: number;
toString(): string;
get [Symbol.toStringTag](): string;
message: string;
stack?: string;
cause?: unknown;
};
status: number;
code: string;
help?: string;
message?: string;
isError(error: unknown): error is Error;
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
stackTraceLimit: number;
};
/**
* Error thrown when a provider is used for signup but local signup
* is disabled for it.
*
* @example
* ```ts
* throw new errors.E_LOCAL_SIGNUP_DISALLOWED(['github'])
* ```
*/
export declare const E_LOCAL_SIGNUP_DISALLOWED: {
new (args: [string], options?: ErrorOptions): {
/**
* Translation identifier. Can be customized
*/
identifier: string;
/**
* Returns the message to be sent in the HTTP response.
* Feel free to override this method and return a custom
* response.
*/
getResponseMessage(error: /*elided*/ any, ctx: HttpContext): string;
/**
* Converts exception to an HTTP response
*/
handle(error: /*elided*/ any, ctx: HttpContext): Promise<void>;
name: string;
help?: string;
code?: string;
status: number;
toString(): string;
get [Symbol.toStringTag](): string;
message: string;
stack?: string;
cause?: unknown;
};
status: number;
code: string;
help?: string;
message?: string;
isError(error: unknown): error is Error;
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
stackTraceLimit: number;
};