UNPKG

@block-auth.io/blockauth-sdk

Version:

Block-Auth Auth SDK is a SaaS service blockchain based authentication service. It provides a simple and secure way to authenticate users in your application.

111 lines (110 loc) 3.61 kB
import { RpcClient } from './clients/RpcClient'; import { WsClient } from './clients/WsClient'; /** * This class allow you to authenticate with your BlockAuth * wallet and get the data from your user and/or tenant. * * examples: * * const provider = new BlockAuthProvider(); * */ declare class BlockAuthProvider { private _rpc; private _wsc; private _apiKey; private _apiSecret; constructor(apiKey?: string, apiSecret?: string, wsUrl?: string); /** * Allow you to connect to the WebSocket API * for Block-Auth service * @param waitMs - time to wait for connection ready * @returns Promise<void> */ connect(waitMs?: number, url?: string): Promise<void>; /** * Allow you to disconnect from the WebSocket API * for Block-Auth service * @returns Promise<void> */ disconnect(): Promise<void>; /** * Check if the WebSocket API is connected * to Block-Auth service * @returns boolean */ isConnected(): any; /** * Allow to Signin with your API Key and Secret * to get the access token and refresh token. * The access token is valid for 1 hour. * The refresh token is valid for 2 hours. * You can use the refresh token to get a new * access token when the access token is expired using * the method `refresh()`. * @param apiKey - your API Key * @param apiSecret - your API Secret * @returns Promise<any> */ signin(): Promise<any>; /** * Allow to refresh the access token when it's expired. * @param refreshToken - your refresh token * @returns Promise<any> */ refresh(refreshToken?: string): Promise<any>; /** * Allow to get the data from your user. * @param success - allow to know if address is signed * @param message - extended info about signed address * @returns Promise<any> */ isAddressSigned(address: string, token?: string): Promise<any>; /** * Allow to get the data from your app. * @param token - your access token * @returns Promise<any> */ app(token?: string): Promise<any>; user(address: string, token?: string): Promise<any>; /** * Allow to get a list of users from your app, also * you can filter by role and/or permission. * @param token - your access token * @param data - the data to filter * @returns Promise<any> */ users(token?: string, data?: any): Promise<any>; /** * Allow to get a list of roles from your app. * @param token - your access token * @param data - the data to filter * @returns Promise<any> * */ roles(token?: string, data?: any): Promise<any>; /** * Allow to get a list of logs from your app. * @param token - your access token * @param data - the data to filter * @returns Promise<any> */ logs(token?: string, data?: any): Promise<any>; /** * Allow to get KYC issuer for a certain user address from your app. * @param address - the address of the user to be paid by the issuer * @param data - the data to connect to the KYC issuer * { operationId, sessionId, extraData } * @param token - your access token * @returns Promise<any> */ kycIssuer(address: string, data?: any, token?: string): Promise<any>; get rpc(): RpcClient; get wsc(): WsClient; get socket(): any; get uiConfig(): any; get appUsers(): any[]; get appRoles(): any[]; get appLogs(): any[]; get appKycIssuerByAddress(): any; } export { BlockAuthProvider };