blockstack
Version:
The Blockstack Javascript library for authentication, identity, and storage.
67 lines (66 loc) • 2.82 kB
TypeScript
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;
coreNode: string;
authResponseToken: string;
coreSessionToken?: string;
gaiaAssociationToken?: string;
profile: any;
gaiaHubConfig?: GaiaHubConfig;
}
/**
* 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;
/**
* Retrieve the authentication token from the URL query
* @return {String} the authentication token if it exists otherwise `null`
*/
export declare function getAuthResponseToken(): string;
/**
* 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;
/**
* Redirects the user to the Blockstack browser to approve the sign in request
* given.
*
* The user is redirected to the `blockstackIDHost` if the `blockstack:`
* 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} blockstackIDHost - the URL to redirect the user to if the blockstack
* protocol handler is not detected
* @return {void}
*/
export declare function redirectToSignInWithAuthRequest(authRequest?: string, blockstackIDHost?: string): void;
/**
* 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>;