/** * Navigates the current window to the YouTrack OAuth2 page. * * Once successfully logged in, the YouTrack OAuth2 page will redirect the browser to the given `redirectUrl`. To be * able to seamlessly proceed where the user left off, the current application state needs to be preserved. This method * stores the given application state `appState` in the * [session storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage). The rationale is: * 1. The application state could be larger than what one would reasonably encode in the redirect URL (which is another * possibility of preserving the state). * 2. The application state does not leak to a third party. * * Nonetheless, users of this method should be aware of the limitations of using the session storage as well. MDN has * some [additional information](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API) on this topic. * * @typeparam T type of the application state * @param baseUrl The YouTrack base URL to which relative paths like `youtrack/api/...` or `hub/api/...` will be * appended. The base URL is expected to and in a slash (/). See {@link YouTrackConfig.baseUrl}. * @param serviceId Identification of the particular YouTrack installation. See the * [YouTrack manual](https://www.jetbrains.com/help/youtrack/standalone/OAuth-Authorization.html). * @param appState State that will be stored in session storage and later returned by * {@link handlePotentialOauthRedirect}(). The value passed as argument needs to be serializable with * {@link JSON.stringify}(). * @param redirectUrl The URL that YouTrack will redirect back to after authorization. In order to not expose more data * than necessary to the YouTrack server, the url will be stripped from its hash, username/password, and search * query (if any). If state needs to be preserved, the `appState` argument should be used. */ export declare function goToOauthPage(baseUrl: string, serviceId: string, appState: T, redirectUrl?: string): void; /** * Parses `window.location.href` to determine whether the URL stems from a YouTrack OAuth2 redirect, and returns the * restored application state if so. * * This method is meant to be called when the page is loaded. If the current URL contains a hash that is the result of * an OAuth2 redirect, any URL component except domain and path (such as search query or hash) will be removed. Note * that `window.location.href` will be updated with `Location.replace()`. * * Finally, this keeps a record of the YouTrack authorization, making it available via {@link authorizationFor}(). * * @typeparam T type of the application state * @return object containing the application state or undefined if the current location is not the result of a YouTrack * OAuth2 redirect */ export declare function handlePotentialOauthRedirect(): T | undefined; /** * Returns the access token for the given base URL, or undefined if there is no (unexpired) one. * * This method returns the HTTP Authorization header known due to a previous call to * {@link handlePotentialOauthRedirect}(), or undefined if not known for the given URL. * * @param baseUrl The YouTrack base URL to which relative paths like `youtrack/api/...` or `hub/api/...` will be * appended. The base URL is expected to end in a slash (/). See {@link httpGet}(). * @return value for HTTP authorization header */ export declare function authorizationFor(baseUrl: string): string | undefined; //# sourceMappingURL=you-track-oauth.d.ts.map