UNPKG

@betha-plataforma/oauth

Version:

Biblioteca JavaScript para lidar com o fluxo do OAuth 2.0 em aplicações Web, com suporte a TypeScript.

48 lines (47 loc) 1.66 kB
import { ExtraConfigs } from '../..'; import { OAuthConfig } from '../../OAuthConfig'; import { AccessTokenResponse } from './AccessTokenResponse'; export interface AuthorizeParams { /** * the expected response type, which can be either `code` or `token`. */ readonly response_type: 'code' | 'token'; /** * the code challenge to secure the authorization with PKCE. {@link https://oauth.net/2/pkce/}. */ readonly code_challenge?: string; /** * the hash method to use for a PKCE authorization request. {@link https://oauth.net/2/pkce/}. */ readonly code_challenge_method?: string; /** * a parameter to prevent against CSRF attacks. {@link https://auth0.com/docs/protocols/oauth2/oauth-state} */ readonly state?: string; readonly access_mode?: string; } export interface AccessTokenParams { readonly grant_type: string; readonly code?: string; readonly code_verifier?: string; readonly refresh_token?: string; } /** * */ export declare class Authorization { private readonly config; constructor(config: OAuthConfig); /** * Builds and returns the `/authorize` URL in order to initialize a new authentication transaction. * * @method authorize * @param {AuthorizeParams} params the request params. * @param silent * @param anonymous * @param configs * @returns the `/authorize` URL */ readonly getAuthorizeURL: (params: AuthorizeParams, silent?: boolean, anonymous?: boolean, configs?: ExtraConfigs) => string; readonly token: (params: AccessTokenParams, silent?: boolean) => Promise<AccessTokenResponse>; }