UNPKG

adonis6_ally_yandex

Version:
103 lines (102 loc) 3.22 kB
import type { HttpContext } from '@adonisjs/core/http'; import type { HttpClient } from '@poppinss/oauth-client'; import type { YandexToken, YandexScopes, YandexDriverConfig } from './types.js'; import { Oauth2Driver, type RedirectRequest, type ApiRequest } from '@adonisjs/ally'; import type { ApiRequestContract } from '@adonisjs/ally/types'; /** * Yandex driver to login user via Yandex */ export declare class YandexDriver extends Oauth2Driver<YandexToken, YandexScopes> { config: YandexDriverConfig; protected accessTokenUrl: string; protected authorizeUrl: string; protected userInfoUrl: string; protected userAvatarUrl: string; protected userAvatarSize: string; /** * The param name for the authorization code */ protected codeParamName: string; /** * The param name for the error */ protected errorParamName: string; /** * Cookie name for storing the "yandex_oauth_state" */ protected stateCookieName: string; /** * Parameter name to be used for sending and receiving the state * from yandex */ protected stateParamName: string; /** * Parameter name for defining the scopes */ protected scopeParamName: string; /** * Scopes separator */ protected scopesSeparator: string; constructor(ctx: HttpContext, config: YandexDriverConfig); /** * Configuring the redirect request with defaults */ protected configureRedirectRequest(request: RedirectRequest<YandexScopes>): void; /** * Returns the HTTP request with the authorization header set */ protected getAuthenticatedRequest(url: string, token: string): HttpClient; /** * Fetches the user info from the Yandex API */ protected getUserInfo(token: string, callback?: (request: ApiRequest) => void): Promise<{ id: any; nickName: any; name: any; avatarUrl: string; original: any; }>; /** * Fetches the user email from the Yandex API */ protected getUserEmail(token: string, callback?: (request: ApiRequest) => void): Promise<any>; /** * Find if the current error code is for access denied */ accessDenied(): boolean; /** * Returns details for the authorized user */ user(callback?: (request: ApiRequestContract) => void): Promise<{ email: any; emailVerificationState: "unsupported"; token: YandexToken; id: any; nickName: any; name: any; avatarUrl: string; original: any; }>; /** * Finds the user by the access token */ userFromToken(token: string, callback?: (request: ApiRequest) => void): Promise<{ email: any; emailVerificationState: "unsupported"; token: { token: string; type: "bearer"; }; id: any; nickName: any; name: any; avatarUrl: string; original: any; }>; } /** * The factory function to reference the driver implementation * inside the "config/ally.ts" file. */ export declare function YandexDriverService(config: YandexDriverConfig): (ctx: HttpContext) => YandexDriver;