License: Apache-2.0
A lightweight SDK for integrating ResVault into your web applications. This SDK simplifies the interaction with the ResVault system, allowing you to send messages and listen for events in a secure and controlled manner.
postMessage.You can install the ResVault SDK via npm:
npm install resvault-sdk
After installing the SDK, you can import and use it in your JavaScript or TypeScript projects as follows:
import ResVaultSDK from 'resvault-sdk'; const sdk = new ResVaultSDK(); // Sending a message to the content script sdk.sendMessage({ type: 'login', direction: 'login' }); // Adding a message listener to receive messages const handleMessage = (event) => { console.log('Received message:', event.data); }; sdk.addMessageListener(handleMessage); // Removing the message listener when it's no longer needed sdk.removeMessageListener(handleMessage);
new ResVaultSDK(targetOrigin?: string)postMessage. Defaults to "*". You can specify this for more security.Creates an instance of the ResVaultSDK.
sendMessage(message: Message): voidtype key.Sends a message using postMessage.
addMessageListener(handler: (event: MessageEvent) => void): voidMessageEvent object as its parameter.Adds a message listener for incoming messages.
removeMessageListener(handler: (event: MessageEvent) => void): voidRemoves a message listener when it’s no longer needed.
To build the SDK from source:
npm run build
This will compile the TypeScript source code into JavaScript and generate the dist folder.
If you're looking for a quick way to integrate this SDK with React or Vue projects, you can use the create-resilient-app npm package. It helps you scaffold a new project that already includes the ResVault SDK integration.
create-resilient-app:Run the following command with your chosen options (React/Vue, TypeScript/JavaScript):
npx create-resilient-app --framework react --language typescript --name my-resvault-app
Navigate to your newly created project:
cd my-resvault-app
Install the dependencies and start developing:
npm install
npm start
This will set up a complete React or Vue project (with TypeScript or JavaScript, depending on your choice) with the necessary setup to integrate the ResVaultSDK. You can explore the Login and TransactionForm components in the generated project to see how the SDK is integrated.
This project is licensed under the terms of the Apache 2.0 License. See the LICENSE file for details.