/** * This file is part of the @egodigital/egoose distribution. * Copyright (c) e.GO Digital GmbH, Aachen, Germany (https://www.e-go-digital.com/) * * @egodigital/egoose is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, version 3. * * @egodigital/egoose is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ import * as express from 'express'; /** * Data from 'https://graph.microsoft.com/v1.0/me'. */ export interface MicrosoftMe { /** * The display name. */ "displayName"?: string; /** * The given name. */ "givenName"?: string; /** * The ID. */ "id": string; /** * The mail address. */ "mail"?: string; /** * The surname. */ "surname"?: string; /** * The user's principal name. */ "userPrincipalName"?: string; } /** * Data for a Microsoft Access token. */ export interface MicrosoftOAuthAccessToken { /** * The token. */ "access_token": string; /** * The time, in seconds, the token expires in. */ "expires_in": string; /** * The refresh token. */ "refresh_token": string; /** * The scope. */ "scope": string; /** * The type, like "Bearer". */ "token_type": string; } /** * Options for 'registerForMicrosoftOAuth()' function. */ export interface RegisterForMicrosoftOAuthOptions { /** * Is invoked, when an access token has been received. * * @param {MicrosoftOAuthAccessToken} token The token. * @param {express.Request} req The request context. * @param {express.Response} res The response context. */ onAccessToken: (token: MicrosoftOAuthAccessToken, req: express.Request, res: express.Response) => void | PromiseLike; /** * A custom error response function. * * @param {string} error The error (code). * @param {string} description The (error) description. * @param {express.Request} req The request context. * @param {express.Response} res The response context. */ onError?: (error: string, description: string, req: express.Request, res: express.Response) => any; /** * A custom server error response function. * * @param {any} err The error. * @param {express.Request} req The request context. * @param {express.Response} res The response context. */ onServerError?: (err: any, req: express.Request, res: express.Response) => any; /** * A custom success response function. * * @param {express.Request} req The request context. * @param {express.Response} res The response context. */ onSuccess?: (req: express.Request, res: express.Response) => any; /** * The custom redirect (base) path. Default: '/oauth/microsoft' */ redirectPath?: string; } /** * Returns the information from 'https://graph.microsoft.com/v1.0/me'. * * @param {string | MicrosoftOAuthAccessToken} token The token. * * @return {Promise} The promise with the data or (false) if failed. */ export declare function getMicrosoftMe(token: string | MicrosoftOAuthAccessToken): Promise; /** * Returns the login URL for Microsoft OAuth. * * @return {string} The login URL. */ export declare function getMicrosoftOAuthLoginUrl(): string; /** * Registers an Express instance for Microsoft OAuth. * * @param {express.Express | express.Router} hostOrRouter The host or router. * @param {RegisterForMicrosoftOAuthOptions} opts The options. */ export declare function registerForMicrosoftOAuth(hostOrRouter: express.Express | express.Router, opts: RegisterForMicrosoftOAuthOptions): void;