@dscvr-one/canvas-client-sdk
v1.1.1
Published
SDK for iframes apps to connect to dscvr host using postMessage rpc
Downloads
220
Readme
@dscvr-one/canvas-client-sdk
This SDK can be used by DSCVR Canvas Applications to communicate with the DSCVR Frontend.
Current features include:
- Get the current user and content.
- Prompt the user to open an external link.
- Execute wallet transactions.
Installation
Install with your favorite package manager:
npm install @dscvr-one/canvas-client-sdk
yarn
yarn add @dscvr-one/canvas-client-sdk
Usage
To use the SDK:
- Import
CanvasClient
andCanvasInterface
into your typescript project:
import { CanvasInterface, CanvasClient } from '@dscvr-one/canvas-client-sdk';
- Instantiate the
CanvasClient
:
const canvasClient = new CanvasClient();
- Start the handshake:
const response = await canvasClient.ready();
//
if (response) {
// The handshake allows access to the user and the content that the application is embedded in.
const user: CanvasInterface.Handshake.User = response.untrusted.user;
const content: CanvasInterface.Handshake.Content = response.untrusted.content;
// ...
}
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvement, feel free to open an issue or submit a pull request.