npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

resvault-sdk

v1.0.2

Published

A lightweight SDK for ResVault.

Downloads

182

Readme

ResVault SDK

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.

Features

  • Simple API to send and receive messages via postMessage.
  • Ability to add and remove custom message listeners.
  • Designed for integration with ResVault-based applications.

Installation

You can install the ResVault SDK via npm:

npm install resvault-sdk

Usage

Importing the 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);

API Reference

new ResVaultSDK(targetOrigin?: string)

  • targetOrigin: (optional) The target origin for postMessage. Defaults to "*". You can specify this for more security.

Creates an instance of the ResVaultSDK.

sendMessage(message: Message): void

  • message: The message object to send, which must include at least a type key.

Sends a message using postMessage.

addMessageListener(handler: (event: MessageEvent) => void): void

  • handler: A function that will be called when a message is received. This function should accept a MessageEvent object as its parameter.

Adds a message listener for incoming messages.

removeMessageListener(handler: (event: MessageEvent) => void): void

  • handler: The function that was previously registered as a listener.

Removes a message listener when it’s no longer needed.

Build

To build the SDK from source:

npm run build

This will compile the TypeScript source code into JavaScript and generate the dist folder.

Examples

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.

Steps to scaffold a project using create-resilient-app:

  1. Run the following command with your chosen options (React/Vue, TypeScript/JavaScript):

    npx create-resilient-app --framework react --language typescript --name my-resvault-app
  2. Navigate to your newly created project:

    cd my-resvault-app
  3. 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.

License

This project is licensed under the terms of the Apache 2.0 License. See the LICENSE file for details.