@cubist-labs/cubesigner-react
v0.0.98
Published
CubeSigner Core React Library. Contains our CubeSigner Provider for accessing the sdk in external React applications and widgets for basic CubeSigner interactions.
Downloads
56
Readme
CubeSigner React
Package for interacting with CubeSigner sessions within your React application.
Provider
// filename: main.tsx
import { Provider } from "@cubist-labs/cubesigner-react";
... your setup code ...
createRoot(document.getElementById('root')!).render(
<CubeSignerProvider env='gamma'>
<App />
</CubeSignerProvider>
)
// Establish the environment your CubeSigner API is targeting.
env: "beta" | "gamma" | "prod";
// For portfolio and asset data, provide an ankr api key
ankrApiKey: string;
When your provider is established, you will be able to establish a CubeSigner session in your local
storage by adding a <Login />
component in your application.
// filename: someView.tsx
// ...
return (
<>
Please log in
<Login />
</>
);
<Login/>
also provides callbacks to interact with various states of the login process.
/**
* Optional callback for reacting to an initialized login.
* @return {Promise<void>}
*/
onLoginInitialized?: () => void;
/**
* Optional callback for reacting to an mfa request for login.
* @return {Promise<void>}
*/
onMfaRequired?: () => void;
/**
* Optional callback for reacting to a successful login.
* @return {Promise<void>}
*/
onSuccess?: () => void;
/**
* Optional callback for reacting to an error in the login process.
* @param {Error} e - error thrown.
* @return {Promise<void>}
*/
onError?: (e?: Error) => void;