UNPKG

@julienbenac/ally-gerermesaffaires

Version:
127 lines (117 loc) 4.56 kB
import { HttpContext } from '@adonisjs/core/http'; import Configure from '@adonisjs/core/commands/configure'; import { Oauth2DriverConfig, LiteralStringUnion, RedirectRequestContract, ApiRequestContract, AllyUserContract } from '@adonisjs/ally/types'; import * as _adonisjs_ally from '@adonisjs/ally'; import { Oauth2Driver } from '@adonisjs/ally'; /** * @julienbenac/ally-gerermesaffaires * * @author Julien Benac <contact@julienbenac.fr> * @license MIT */ declare const stubsRoot: string; /** * @julienbenac/ally-gerermesaffaires * * @author Julien Benac <contact@julienbenac.fr> * @license MIT */ declare function configure(command: Configure): Promise<void>; /** * @julienbenac/ally-gerermesaffaires * * @author Julien Benac <contact@julienbenac.fr> * @license MIT */ interface GererMesAffairesDriverConfig extends Oauth2DriverConfig { env: 'production' | 'sandbox'; scopes?: LiteralStringUnion<GererMesAffairesScopes>[]; } type GererMesAffairesToken = { /** The token value. */ token: string; /** The token type. */ type: 'bearer'; /** The refresh token. */ refreshToken: string; /** The static time in seconds when the token will expire. */ expiresIn: number; /** The timestamp at which the token expires. */ expiresAt: Date; /** The access scope defining the user's permission level. */ scope: 'collaborator' | 'owner'; /** The identification token (JWT format) for session lifecycle. */ idToken: string; } & Record<string, any>; type GererMesAffairesScopes = 'openid' | 'collaborator' | 'owner' | 'profile' | 'email' | 'address' | 'phone'; /** * GererMesAffaires driver to login user via GererMesAffaires. */ declare class GererMesAffairesDriver extends Oauth2Driver<GererMesAffairesToken, GererMesAffairesScopes> { #private; config: GererMesAffairesDriverConfig; /** * The authorization URL for the OAuth provider. * The user will be redirected to this page to authorize the request. */ protected authorizeUrl: string; /** The URL to hit to get an access token. */ protected accessTokenUrl: string; /** The URL to hit to get user details. */ protected userInfoUrl: string; /** The cookie name for storing the CSRF token. */ protected stateCookieName: string; /** * The parameter name in which to send the state to the OAuth provider. * The same input is used to retrieve the state post redirect as well. */ protected stateParamName: string; /** The parameter name from which to fetch the authorization code. */ protected codeParamName: string; /** The parameter name from which to fetch the error message post redirect. */ protected errorParamName: string; /** The parameter name for defining the authorization scopes. */ protected scopeParamName: string; /** The identifier for joining multiple scopes. */ protected scopesSeparator: string; constructor(ctx: HttpContext, config: GererMesAffairesDriverConfig); /** * Configuring the redirect request with defaults. */ protected configureRedirectRequest(request: RedirectRequestContract<GererMesAffairesScopes>): void; /** * Redirects user for authentication. */ redirect(callback?: (request: RedirectRequestContract<GererMesAffairesScopes>) => void): Promise<void>; /** * Returns the HTTP request with the authorization header set. */ protected getAuthenticatedRequest(url: string, token: string): _adonisjs_ally.ApiRequest; /** * Fetches the user details. */ protected getUserInfo(token: string, callback?: (request: ApiRequestContract) => void): Promise<Omit<AllyUserContract<GererMesAffairesToken>, 'token'>>; /** * Find if the current error message is access denied. */ accessDenied(): boolean; /** * Returns details of the authorized user. */ user(callback?: (request: ApiRequestContract) => void): Promise<AllyUserContract<GererMesAffairesToken>>; /** * Finds the user from access token. */ userFromToken(token: string, callback?: (request: ApiRequestContract) => void): Promise<AllyUserContract<{ token: string; type: 'bearer'; }>>; } /** * @julienbenac/ally-gerermesaffaires * * @author Julien Benac <contact@julienbenac.fr> * @license MIT */ declare function gerermesaffaires(config: GererMesAffairesDriverConfig): (ctx: HttpContext) => GererMesAffairesDriver; export { type GererMesAffairesToken, configure, gerermesaffaires, stubsRoot };