import { AuthorizationServiceConfiguration } from '@openid/appauth'; import { BitskiProvider, BitskiProviderConfig, BitskiProviderStore } from 'bitski-provider'; import { SignInOptions } from './auth/oauth-manager'; import { OpenidAuthProvider } from './auth/openid-auth-provider'; import { User } from './auth/user'; import { AuthenticationStatus, OAuthSignInMethod } from './constants'; import { Network } from './network'; export interface BitskiSDKOptions { configuration?: AuthorizationServiceConfiguration; store?: BitskiProviderStore; } export interface PaymasterDefinition { paymasterUrl: string; policyId?: string; rpcMethod?: string; } export interface WaasDefinition { enabled: boolean; userId?: string; transactionProxyUrl?: string; } export interface ProviderOptions extends Omit, 'prependMiddleware'> { networkName?: string; network?: Network; paymaster?: PaymasterDefinition | PaymasterDefinition[]; waas?: WaasDefinition; additionalSigningContext?: Record; webBaseUrl?: string; callbackURL?: string; disableBlockTracking?: boolean; minGasPrice?: number; } /** * Bitski SDK */ export declare class BitskiSDK { protected clientId: string; protected authProvider: OpenidAuthProvider; protected signoutHandlers: Array<() => void>; protected sdkVersion: string; protected store: BitskiProviderStore; /** * @param clientId OAuth Client ID * @param redirectUri Redirect uri, defaults to the current url. This should be the location of your callback html file. * @param additionalScopes To use custom scopes, add them here. The default value is ['offline']. * Note: Make sure your app is approved for the scopes you are requesting first. * @param options Other OAuth settings. Don't change these unless you know what you are doing. */ constructor(clientId: string, redirectUri?: string, additionalScopes?: string[], options?: BitskiSDKOptions); /** * Signs in or connects to bitski depending on the user's auth state. * Since it may open a popup, this method must be called from user interaction handler, * such as a click or tap handler. * @param options Provide SignInOptions for the sign in request. See signIn() for more info. */ signInOrConnect(method?: OAuthSignInMethod, options?: SignInOptions): Promise; /** * Check the logged in state of the user */ getAuthStatus(): Promise; /** * Starts the sign in flow. Will trigger a popup window over your app, so it must be called within a user interaction handler such as a click. * @param options Optionally provide additional options for the sign in request. * * You can use the options parameter to request that we show the sign up form instead of the sign in form: * ```javascript * import { LOGIN_HINT_SIGNUP } from 'bitski'; * * await bitski.signIn({ login_hint: LOGIN_HINT_SIGNUP }); * ``` */ signIn(options?: SignInOptions): Promise; /** * Gets the current signed in user. Will reject if we are not signed in. */ getUser(): Promise; /** * Connects to bitski to get a valid access token if possible. */ connect(): Promise; /** * Starts redirect sign in flow. This is an alternative flow to the popup that all takes place in the same browser window. * @param options Optionally provide additional options for the sign in request. See signIn() for more info. */ signInRedirect(options?: SignInOptions): void; /** * Call from your oauth redirect page. */ redirectCallback(): Promise; /** * Retrieves the current access token for the user, if logged in. */ getCurrentAccessToken(): Promise; /** * Retrieves the current ID token for the user, if logged in. */ getCurrentIdToken(): Promise; /** * Retrieves the current refresh token for the user, if logged in. * Requires that the user has approved your application for offline access. */ getCurrentRefreshToken(): Promise; /** * Register a callback to be called on sign out. This is a good practice, * since there may be situations where you are signed out unexpectedly. * @param fn Your callback function */ addSignOutHandler(fn: () => void): void; /** * Remove a registered signout callback * @param fn Your callback function */ removeSignOutHandler(fn: () => void): void; /** * Sign the current user out of your application. */ signOut(): Promise; /** * Used to refresh the auth provider's state if the user is logged in/out in a * different process */ reloadAuthState(): void; createProvider(options?: ProviderOptions): BitskiProvider; protected onSignOut(): void; /** * Embeds Bitski's UI styles */ protected injectStyles(): void; }