UNPKG

@esri/arcgis-rest-request

Version:

Common methods and utilities for @esri/arcgis-rest-js packages.

56 lines (55 loc) 2.08 kB
import { IUser } from "./types/user.js"; import { IRequestOptions } from "./utils/IRequestOptions.js"; declare class AuthenticationManagerBase { /** * The current portal the user is authenticated with. */ readonly portal: string; /** * The username of the currently authenticated user. */ get username(): string; constructor(options: any); /** * Internal varible to track the pending user request so we do not make multiple requests. */ private _pendingUserRequest; /** * Hydrated by a call to [getUser()](#getUser-summary). */ private _user; /** * Internal variable to store the username. */ private _username; /** * Returns the username for the currently logged in [user](https://developers.arcgis.com/rest/users-groups-and-items/user.htm). Subsequent calls will *not* result in additional web traffic. This is also used internally when a username is required for some requests but is not present in the options. * * ```js * manager.getUsername() * .then(response => { * console.log(response); // "casey_jones" * }) * ``` */ getUsername(): Promise<string>; /** * Returns information about the currently logged in [user](https://developers.arcgis.com/rest/users-groups-and-items/user.htm). Subsequent calls will *not* result in additional web traffic. * * ```js * manager.getUser() * .then(response => { * console.log(response.role); // "org_admin" * }) * ``` * * @param requestOptions - Options for the request. NOTE: `rawResponse` is not supported by this operation. * @returns A Promise that will resolve with the data from the response. */ getUser(requestOptions?: IRequestOptions): Promise<IUser>; /** * Clear the cached user infornation. Usefull to ensure that the most recent user information from {@linkcode AuthenticationManagerBase.getUser} is used. */ clearCachedUserInfo(): void; } export { AuthenticationManagerBase };