import { Session } from '@genesislcap/foundation-comms'; import { I18next } from '@genesislcap/foundation-i18n'; import { FASTElement } from '@microsoft/fast-element'; import { Container } from '@microsoft/fast-foundation'; import { MainRouterConfig } from '../routes'; /** * Defines the login class which handles account authentication from the front-end * * @remarks * * Add the Login class as a router element, and it will handle the account authentication for you. * Requires use of `@genesislcap/foundation-comms` for the {@link @genesislcap/foundation-comms#Auth | Auth} and * {@link @genesislcap/foundation#Session | Session} classes. * * There are a lot of configuration options available, and different authentication types (such as login via SSO). Use * the modules exported `configure` and `define` functions for more power. * * @example * The following is an example of using it in your app, setting it up in the router configuration. This isn't a complete * routes confutation, but it contains all required configuration in regard to adding Login functionality. * ```ts * // Import required dependencies from the foundation-login package * import { Login } from '@genesislcap/foundation-login'; * // Import required dependencies from the foundation-comms package * // You could also import analytics events and set them up in the NavigationContributor * import { Auth, Session } from '@genesislcap/foundation-comms'; * * type RouterSettings = { * public?: boolean; * autoAuth?: boolean; * } * * // Define your router config * export class MainRouterConfig extends RouterConfiguration { * // Ensure you inject in required dependencies * constructor( * @Auth private auth: Auth, * @Session private session: Session * ) { * super(); * } * * // Add Login as a route * public configure() { * ... * this.routes.map( * { path: '', redirect: 'login' }, * { * path: 'login', * element: Login, * title: 'Login', * name: 'login', * layout: loginLayout, * settings: { public: true }, * childRouters: true, * }, * ... // Other routes config here * ); * * const session = this.session; * const auth = this.auth; * * // Example of a FallbackRouteDefinition * this.routes.fallback(() => * auth.isLoggedIn ? { redirect: 'not-found' } : { redirect: 'login' } * ); * * // Example of a NavigationContributor * this.contributors.push({ * navigate: async (phase) => { * const settings = phase.route.settings; * * // Could add in processes such as analytics here * * // If public route don't block * if (settings && settings.public) { * return; * } * * // If logged in don't block * if (auth.isLoggedIn) { * return; * } * * // If autoAuth and session is valid try to connect+auto-login * if (settings && settings.autoAuth && (await auth.reAuthFromSession())) { * return; * } * * // Otherwise route them to login * phase.cancel(() => { * session.captureReturnUrl(); * FoundationRouteNav.name.replace(phase.router, 'login'); * }); * }, * }); * } * * ... // Other configuration/methods * * } * ``` * * @deprecated - Use '\@genesislcap/pbc-auth' instead. * 'https://www.npmjs.com/package/\@genesislcap/pbc-auth' * * @public */ export declare class Login extends FASTElement { /** * Configuration for the routes and their associated settings. * The client would override this in their app with their own settings to set * their routes up as desired * @internal */ config: MainRouterConfig; /** * The DI container used to register required components in {@link Login.registerDIDependencies} * @internal */ container: Container; /** * Session controller used to manage the user's session * @internal */ session: Session; /** * i18next instance for managing internationalization. * @internal */ i18next: I18next; /** * Marked true when remote components are loaded, currently unused. * @internal */ ready: boolean; /** * DS provider / root level template. * @internal */ provider: FASTElement; /** * @internal */ connectedCallback(): Promise; /** * Used to forward the user onto a logged-in session during an SSO journey * * @remarks * * Called when loading the login page via the connectedCallback() method. * During normal flows there will be no SSO tokens set and hence this function * will quit execution. * During an SSO journey the SSO provider will set the SSO token as a URLSearchParams * parameter and redirect back to us. In this case we will take this and forward the * user on, with their logged in session. * * There are two paths the user can take here - if they are in a popup * (window.opener exists) then we need to set the session and get the parent window * (the one which the user wants their session on) to refresh, and close the popup. * * Or if they are not in a popup then we simply set the ssoToken in the session. * When this component is loaded with the ssoToken then it will redirect the * user to their app (the `defaultRedirectUrl`). * * @internal */ checkForSSOToken(): void; /** * Called from the connectedCallback * @internal */ registerCommonComponents(): Promise; /** * @internal */ protected registerDIDependencies(): void; } /** * @beta * @privateRemarks * A hosted version of the MF that doesn't set up a design system or components. This is what apps would use to truly * customise the MF for their needs via define.ts. * * @deprecated - Please use foundation-auth instead. */ export declare class LoginHosted extends Login { registerCommonComponents(): Promise; } //# sourceMappingURL=main.d.ts.map