import { AuthenticationTokenProvider } from './AuthenticationTokenProvider'; import { AuthenticationClientOptions, Protocol } from './types'; import { HttpClient } from '../common/HttpClient'; import { User } from '../../types/graphql.v2'; import { BaseAuthenticationClient } from './BaseAuthenticationClient'; /** * @class EnterpriseAuthenticationClient * @description This client encapsulates the function of Enterprise Authentication, and can quickly use Enterprise Authentication to obtain user information through a simple API. * * Initiate a login authorization request for the Enterprise Authentication: * * \`\`\`javascript * import { AuthenticationClient } from "approw-js-sdk" * const authenticationClient = new AuthenticationClient({ * appId: "YOUR_APP_ID", * }) * await authenticationClient.enterprise.authorize("oidc", "identifierxxx" { * onSuccess: (user) => { console.log(user) }, * onError: (code, message) => { } * }) * \`\`\` * * * @name EnterpriseAuthenticationClient */ export declare class EnterpriseAuthenticationClient { options: AuthenticationClientOptions; tokenProvider: AuthenticationTokenProvider; httpClient: HttpClient; baseClient: BaseAuthenticationClient; constructor(options: AuthenticationClientOptions, tokenProvider: AuthenticationTokenProvider, httpClient: HttpClient); private initProviderContext; private getProviderConfigAndError; private getLoginUrl; /** * @name authorize * @name_zh Send authorization login request * @description Send an authorized login request. This method will directly open a new window and jump to the login authorization page of the enterprise identity provider (such as OIDC, SAML, etc.). * After the user completes the authorization, this window will be automatically closed and the onSuccess callback function will be triggered. With this function, you can get user information. * * @param {Protocol} protocol: enterprise identity provider protocol * @param {string} provider enterprise identity provider identifier * @param {object} [options] * @param {boolean} [options.popup=true] Whether to open the social login window through a pop-up window, if set to false, a new browser tab will be opened in the form of window.open. * @param {Function} [options.onSuccess] The user agrees to the authorization event callback function, the first parameter is user information. * @param {Function} [options.onError] The callback function of the enterprise identity provider failure event, the first parameter code is the error code, and the second parameter message is the error prompt. Please see the detailed error code list:[Approw error code list](https://docs.approw.com/reference/error-code.html) * @param {object} [options.position] Only valid when options.popup is ture. The default position of the pop-up window is { w: 585, h: 649 } 。 * * @example * * // Log in with the OIDC identity provider whose identity provider identifier is'oidc1' * * const authenticationClient = new AuthenticationClient({ * appId: "YOUR_APP_ID", * }) * * await authenticationClient.enterprise.authorize("oidc", "oidc1" { * onSuccess: (user) => { console.log(user) }, * onError: (code, message) => { }, * // Customize the position of the pop-up window * position: { * w: 100, * h: 100 * } * }) * * @example * * // Use the new browser tab to open the social login page * * const authenticationClient = new AuthenticationClient({ * appId: "YOUR_APP_ID", * }) * * await authenticationClient.enterprise.authorize("oidc", "oidc1", { * popup: false, * onSuccess: (user) => { console.log(user) }, * onError: (code, message) => { }, * }) * * @memberof EnterpriseAuthenticationClient */ authorize(protocol: Protocol, identifier: string, options?: { popup?: boolean; onSuccess?: (user: User) => void; onError?: (code: number, message: string) => void; position?: { w: number; h: number; }; }): Promise; }