/** * @typedef {object} TokenResult * @property {string} token OAuth access token * @property {string} homeImmer User's home Immers Server origin * @property {Array} authorizedScopes Scopes granted by user (may differ from requested scopes) * @property {object} sessionInfo Any other params returned from the authorization server with the token */ /** * Retrieve OAuth access token and authorization details from URL after * redirect and pass it back to the opening window if in a pop-up. Returns true * if a token was found and passed from popup to opener. Returns the token response * data if a token was found but the window is not a popup * (e.g. to pass on to [ImmersClient.loginWithToken]{@link ImmersClient#loginWithToken}). * Returns false if no token found. * @returns {boolean | TokenResult} */ export function catchToken(): boolean | TokenResult; /** * For a standalone destination without its own Immers Server, * trigger OAuth flow to a user's home immer via popup window. * Must be invoked from a trusted user input event handler to allow the popup. * @param {string} handle User's Immers Handle (username[home.immer] or username@home.immer) * @param {string} preferredScope Level of access to request (remember the user can alter this before approving) * @param {string} [tokenCatcherURL=window.location] Redirect URI for OAuth, a page on your origin that runs catchToken on load * @returns {Promise} */ export function DestinationOAuthPopup(handle: string, preferredScope: string, tokenCatcherURL?: string): Promise; /** * For complete immers, trigger popup window OAuth flow starting at local immer and redirecting * as necessary. Must be invoked from a trusted user input event handler to allow the popup. * @param {string} localImmer Origin of the local Immers Server * @param {string} localImmerId IRI of the local immer Place object * @param {string} preferredScope Level of access to request (remember the user can alter this before approving) * @param {string} tokenCatcherURL Redirect URI for OAuth, a page on your origin that runs catchToken on load * @param {string} [handle] If known, you can provide the user's handle (username[home.immer]) to pre-fill login forms * @param {'Login'|'Register'|'Reset password'} [deepLink] Set the default tab to be shown on the login page * @returns {Promise} */ export function ImmerOAuthPopup(localImmer: string, localImmerId: string, preferredScope: string, tokenCatcherURL: string, handle?: string, deepLink?: 'Login' | 'Register' | 'Reset password'): Promise; export function tokenToActor(token: any, homeImmer: any): Promise; export function preprocessScopes(authorizedScopes: any): any; /** * Enum of user account access roles than can be granted */ export type SCOPES = string; export namespace SCOPES { const viewProfile: string; const viewPublic: string; const viewFriends: string; const postLocation: string; const viewPrivate: string; const creative: string; const addFriends: string; const addBlocks: string; const destructive: string; } /** * User account access roles that can be granted. * @constant allScopes * @type {string[]} */ export const allScopes: string[]; /** * User account access levels that can be requested. * @constant * @type {string[]} */ export const roles: string[]; export type TokenResult = { /** * OAuth access token */ token: string; /** * User's home Immers Server origin */ homeImmer: string; /** * Scopes granted by user (may differ from requested scopes) */ authorizedScopes: Array; /** * Any other params returned from the authorization server with the token */ sessionInfo: object; }; export type AuthResult = { /** * User's ActivityPub profile object */ actor: APActor; /** * OAuth access token */ token: string; /** * User's home Immers Server origin */ homeImmer: string; /** * Scopes granted by user (may differ from requested scopes) */ authorizedScopes: Array; /** * Any other params returned from the authorization server with the token */ sessionInfo: object; };