UNPKG

aladinnetwork-blockstack

Version:

The Aladin Javascript library for authentication, identity, and storage.

126 lines (125 loc) 4.94 kB
import { AuthScope } from './authConstants'; import { UserSession } from './userSession'; import { GaiaHubConfig } from '../storage/hub'; /** * Returned from the [[UserSession.loadUserData]] function. */ export interface UserData { username: string; email?: string; decentralizedID: string; identityAddress: string; appPrivateKey: string; hubUrl: string; authResponseToken: string; coreSessionToken?: string; gaiaAssociationToken?: string; profile: any; gaiaHubConfig?: GaiaHubConfig; } /** * @deprecated * #### v19 Use [[UserSession.isUserSignedIn]] instead. * * Check if a user is currently signed in. * @return {Boolean} `true` if the user is signed in, `false` if not. */ export declare function isUserSignedIn(): boolean; /** * * * @deprecated * #### v19 Use [[UserSession.isUserSignedIn]] instead. * * Generates an authentication request and redirects the user to the Aladin * browser to approve the sign in request. * * Please note that this requires that the web browser properly handles the * `aladin:` URL protocol handler. * * Most applications should use this * method for sign in unless they require more fine grained control over how the * authentication request is generated. If your app falls into this category, * use `makeAuthRequest` and `redirectToSignInWithAuthRequest` to build your own sign in process. * * @param {String} [redirectURI=`${window.location.origin}/`] * The location to which the identity provider will redirect the user after * the user approves sign in. * @param {String} [manifestURI=`${window.location.origin}/manifest.json`] * Location of the manifest file. * @param {Array} [scopes=DEFAULT_SCOPE] Defaults to requesting write access to * this app's data store. * An array of strings indicating which permissions this app is requesting. * @return {void} */ export declare function redirectToSignIn(redirectURI?: string, manifestURI?: string, scopes?: Array<AuthScope | string>): void; /** * @deprecated * #### v19 Use [[UserSession.isSignInPending]] instead. * * Check if there is a authentication request that hasn't been handled. * * Also checks for a protocol echo reply (which if detected then the page * will be automatically redirected after this call). * * @return {Boolean} `true` if there is a pending sign in, otherwise `false` */ export declare function isSignInPending(): boolean; /** * @deprecated * #### v19 Use [[UserSession.getAuthResponseToken]] instead. * * Retrieve the authentication token from the URL query * @return {String} the authentication token if it exists otherwise `null` */ export declare function getAuthResponseToken(): string; /** * @deprecated * #### v19 Use [[UserSession.loadUserData]] instead. * * Retrieves the user data object. The user's profile is stored in the key `profile`. * @return {Object} User data object. */ export declare function loadUserData(): UserData; /** * @deprecated * #### v19 Use [[UserSession.signUserOut]] instead. * * Sign the user out and optionally redirect to given location. * @param redirectURL * Location to redirect user to after sign out. * Only used in environments with `window` available */ export declare function signUserOut(redirectURL?: string, caller?: UserSession): void; /** * @deprecated * #### v19 Use [[UserSession.redirectToSignInWithAuthRequest]] instead. * * Redirects the user to the Aladin browser to approve the sign in request * given. * * The user is redirected to the `aladinIDHost` if the `aladin:` * protocol handler is not detected. Please note that the protocol handler detection * does not work on all browsers. * @param {String} authRequest - the authentication request generated by `makeAuthRequest` * @param {String} aladinIDHost - the URL to redirect the user to if the aladin * protocol handler is not detected * @return {void} */ export declare function redirectToSignInWithAuthRequest(authRequest?: string, aladinIDHost?: string): void; /** * @deprecated * #### v19 Use [[UserSession.handlePendingSignIn]] instead. * * Try to process any pending sign in request by returning a `Promise` that resolves * to the user data object if the sign in succeeds. * * @param {String} nameLookupURL - the endpoint against which to verify public * keys match claimed username * @param {String} authResponseToken - the signed authentication response token * @param {String} transitKey - the transit private key that corresponds to the transit public key * that was provided in the authentication request * @return {Promise} that resolves to the user data object if successful and rejects * if handling the sign in request fails or there was no pending sign in request. */ export declare function handlePendingSignIn(nameLookupURL?: string, authResponseToken?: string, transitKey?: string, caller?: UserSession): Promise<UserData>;