
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@dscvr-one/canvas-client-sdk
Advanced tools
SDK for iframes apps to connect to dscvr host using postMessage rpc
canvas-client-sdkxx is a small typescript library that can be used by iframe Apps to communicate with DSCVR's canvas hosts.
The library provides a CanvasClient
class with methods to establish communication with DSCVR to get the current context (user and content) as well as to execute wallet transactions.
You can install Frames Adapter via npm:
npm install @dscvr-one/canvas-client-sdk
yarn
yarn add @dscvr-one/canvas-client-sdk
To use the CanvasClient, simply import it into your typescript project:
import { CanvasInterface, CanvasClient } from '@dscvr-one/canvas-client-sdk';
Then, instantiate CanvasClient
const canvasClient = new CanvasClient();
Use CanvasInterface
to access the communication messages types and schemas.
const user: CanvasInterface.Handshake.User = response.untrusted.user;
const content: CanvasInterface.Handshake.Content = response.untrusted.content;
import {
CanvasInterface,
CanvasClient,
} from '@dscvr-one/canvas-client-sdk';
const canvasClient = new CanvasClient();
const startHandshake = async () => {
const response = await canvasClient.ready();
// make sure to validate response.trustedBytes using @dscvr-one/canvas-server-sdk so the app is not used by platforms other than DSCVR
if (response) {
const user: CanvasInterface.Handshake.User = response.untrusted.user;
const content: CanvasInterface.Handshake.Content = response.untrusted.content;
// ...
}
};
// Open an external link on DSCVR host
const openLink = () => {
const url = 'https://...';
canvasClient.openLink(url);
};
// Execute a wallet transaction
const createTx = async (response: CanvasInterface.User.ConnectWalletResponseMessage) => {
if (!response.success) {
console.error('Failed to connect wallet')
return
}
// make sure to validate response.trustedBytes using @dscvr-one/canvas-server-sdk so the app is not used by platforms other than DSCVR
const unsignedTx = // ...
return unsignedTx;
}
const sendTransaction = async () => {
const response = await canvasClient.connectWalletAndSignTransaction(
'solana:101',
createTx
);
if (!response) {
console.error('Transaction not created');
return;
}
// make sure to validate response.trustedBytes using @dscvr-one/canvas-server-sdk so the app is not used by platforms other than DSCVR
if (response.untrusted.success) {
const signedTx = response.untrusted.signedTx;
// ....
} else {
console.error('Transaction failed', response);
}
}
Contributions are welcome! If you find any issues or have suggestions for improvement, feel free to open an issue or submit a pull request.
Note:
FAQs
SDK for iframes apps to connect to dscvr host using postMessage rpc
The npm package @dscvr-one/canvas-client-sdk receives a total of 36 weekly downloads. As such, @dscvr-one/canvas-client-sdk popularity was classified as not popular.
We found that @dscvr-one/canvas-client-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.